import tkinter as tk from tkinter import ttk from tkinter import scrolledtext as st from controller.Frames import Frames from controller.HomeController import HomeController class HomeView(ttk.Frame): """ View - MainWindow dec... @author Jérémi Nihart / EndMove @link https://git.endmove.eu/EndMove/WebPicDownloader @version 1.0.0 @since 2022-08-30 """ # Variables __controller: HomeController = None # Constructor def __init__(self, parent, controller: HomeController): super().__init__(parent) # Init view self.__init_content() # create widgets # label # self.label = ttk.Label(self, text='Email:') # self.label.grid(row=1, column=0) # email entry # self.email_var = tk.StringVar() # self.email_entry = ttk.Entry(self, textvariable=self.email_var, width=30) # self.email_entry.grid(row=1, column=1, sticky=tk.NSEW) # save button # self.save_button = ttk.Button(self, text='Save', command=self.event_btn) # self.save_button.grid(row=1, column=3, padx=10) # message # self.message_label = ttk.Label(self, text='coucou toi :D JE SUIS SUPER MAN héhéh', foreground='red') # self.message_label.grid(row=2, column=1, sticky=tk.W) # place this frame # self.grid(row=0, column=0, padx=5, pady=5) # self.pack(fill='both', expand=True) # Save and setup main controller self.__controller = controller controller.set_view(self) # START Internal function def __init_content(self) -> None: """ [internal function] => Initialize the view content. """ self.columnconfigure(0, weight=1) self.columnconfigure(1, weight=3) # Website link self.web_label = ttk.Label(self, text="Website URL:") self.web_label.grid(column=0, row=0, sticky=tk.W, padx=5, pady=5) self.web_entry = ttk.Entry(self, width=50) # show="-" self.web_entry.grid(column=1, row=0, sticky=tk.E, padx=5, pady=5, ipadx=2, ipady=2) # Download name self.name_label = ttk.Label(self, text="Download Name:") self.name_label.grid(column=0, row=1, sticky=tk.W, padx=5, pady=5) self.name_entry = ttk.Entry(self, width=50) self.name_entry.grid(column=1, row=1, sticky=tk.E, padx=5, pady=5, ipadx=2, ipady=2) # Logs area self.log_area = st.ScrolledText(self, wrap=tk.WORD, state = tk.DISABLED, width=40, height=8)#, font=("Times New Roman", 15)) self.log_area.grid(column=0, row=3, sticky=tk.EW, columnspan=2, pady=10, padx=10) # Download button self.download_button = ttk.Button(self, text="Start downloading", command=self.event_btn) self.download_button.grid(column=1, row=4, sticky=tk.E, padx=5, pady=5, ipadx=5, ipady=2) # END Internal function # START Controller methods def add_log(self, line: str) -> None: """ [function for controller] TODO desc """ print("ADD: ", line) self.log_area.configure(state=tk.NORMAL) self.log_area.insert(tk.END, f"{line}\n") self.log_area.configure(state=tk.DISABLED) def clear_log(self) -> None: """ [function for controller] TODO desc """ self.log_area.delete(0, tk.END) # END Controller methods def event_btn(self) -> None:# TODO remove print("you clicked ! And now you are on info page ... :D") self.__controller.on_change_view(Frames.Info)