Trying ro fix multi-threading issue
This commit is contained in:
@@ -20,14 +20,20 @@ class HomeView(ttk.Frame):
|
||||
|
||||
# Constructor
|
||||
def __init__(self, parent, controller: HomeController):
|
||||
super().__init__(parent)
|
||||
"""
|
||||
Constructor
|
||||
|
||||
# Init view
|
||||
self.__init_content()
|
||||
* :parent: -> The main windows container.
|
||||
* :controller: -> The view controller
|
||||
"""
|
||||
super().__init__(parent)
|
||||
|
||||
# Save and setup main controller
|
||||
self.__controller = controller
|
||||
controller.set_view(self)
|
||||
|
||||
# Init view
|
||||
self.__init_content()
|
||||
|
||||
# START Internal function
|
||||
def __init_content(self) -> None:
|
||||
|
||||
@@ -19,6 +19,12 @@ class InfoView(ttk.Frame):
|
||||
|
||||
# Constructor
|
||||
def __init__(self, parent, controller: InfoController):
|
||||
"""
|
||||
Constructor
|
||||
|
||||
* :parent: -> The main windows container.
|
||||
* :controller: -> The view controller
|
||||
"""
|
||||
super().__init__(parent)
|
||||
|
||||
# create widgets
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
from controller.MainController import MainController
|
||||
|
||||
|
||||
@@ -6,12 +7,12 @@ class MainWindow(tk.Tk):
|
||||
"""
|
||||
View - MainWindow
|
||||
|
||||
dec...
|
||||
TODO dec...
|
||||
|
||||
@author Jérémi Nihart / EndMove
|
||||
@link https://git.endmove.eu/EndMove/WebPicDownloader
|
||||
@version 1.0.0
|
||||
@since 2022-08-30
|
||||
@version 1.0.1
|
||||
@since 2022-09-04
|
||||
"""
|
||||
# Variables
|
||||
__controller: MainController = None
|
||||
@@ -20,6 +21,11 @@ class MainWindow(tk.Tk):
|
||||
|
||||
# Constructor
|
||||
def __init__(self, controller: MainController) -> None:
|
||||
"""
|
||||
Constructor
|
||||
|
||||
* :controller: -> The main application cpntroller.
|
||||
"""
|
||||
super().__init__()
|
||||
|
||||
# Init view repository
|
||||
@@ -40,10 +46,10 @@ class MainWindow(tk.Tk):
|
||||
[internal function]
|
||||
=> Initialize window parameters
|
||||
"""
|
||||
self.title('Tkinter app')
|
||||
# self.title('My tkinter app')
|
||||
# self.geometry('450x250')
|
||||
self.resizable(False, False)
|
||||
self.config(bg='#f7ef38')
|
||||
# self.config(bg='#f7ef38')
|
||||
|
||||
def __init_top_menu(self) -> None:
|
||||
"""
|
||||
@@ -53,7 +59,7 @@ class MainWindow(tk.Tk):
|
||||
main_menu = tk.Menu(self)
|
||||
|
||||
col1_menu = tk.Menu(main_menu, tearoff=0)
|
||||
col1_menu.add_command(label="Open folder", command=self.__controller.on_open_folder)
|
||||
col1_menu.add_command(label="Open app folder", command=self.__controller.on_open_folder)
|
||||
col1_menu.add_separator()
|
||||
col1_menu.add_command(label="Quit", command=self.__controller.on_quite)
|
||||
main_menu.add_cascade(label="File", menu=col1_menu)
|
||||
@@ -74,23 +80,32 @@ class MainWindow(tk.Tk):
|
||||
# END Internal methods
|
||||
|
||||
# START App methods
|
||||
def add_view(self, frame, view):
|
||||
def add_view(self, frame, view) -> None:
|
||||
"""
|
||||
[function for app]
|
||||
|
||||
:frame: -> the frame id of the view to add.
|
||||
* :frame: -> the frame id of the view to add.
|
||||
"""
|
||||
self.__views[frame] = view
|
||||
# END App methods
|
||||
|
||||
# START Controller methods
|
||||
def show_frame(self, frame):
|
||||
def set_window_title(self, title: str) -> None:
|
||||
"""
|
||||
[function for controller]
|
||||
=> Sets the title of the main window.
|
||||
|
||||
* :title: -> Window title.
|
||||
"""
|
||||
self.title(title)
|
||||
|
||||
def show_frame(self, frame) -> None:
|
||||
"""
|
||||
[function for app & controller]
|
||||
=> Allows to display the selected frame provided that it
|
||||
has been previously added to the frame dictionary.
|
||||
|
||||
:frame: -> the frame if of the view to display.
|
||||
* :frame: -> the frame if of the view to display.
|
||||
"""
|
||||
if self.__views.get(frame):
|
||||
if self.__frame_id:
|
||||
@@ -102,8 +117,28 @@ class MainWindow(tk.Tk):
|
||||
|
||||
def close_window(self) -> None:
|
||||
"""
|
||||
[function for app & controller]
|
||||
TODO
|
||||
[function for controller]
|
||||
=> Closes the main window and stops the program from the controller.
|
||||
"""
|
||||
self.destroy()
|
||||
|
||||
def show_question_dialog(self, title: str, message: str, icon: str='question') -> bool:
|
||||
"""
|
||||
[function for controller]
|
||||
=> TODO DESC
|
||||
|
||||
* :message: ->
|
||||
* RETURN ->
|
||||
"""
|
||||
return messagebox.askquestion(title, message, icon=icon)
|
||||
|
||||
def show_information_dialog(self, title: str, message: str, icon: str='information') -> None:
|
||||
"""
|
||||
[function for controller]
|
||||
=> TODO DESC
|
||||
|
||||
* :message: ->
|
||||
* RETURN ->
|
||||
"""
|
||||
messagebox.showinfo(self, title, message, icon=icon)
|
||||
# END Controller methods
|
||||
|
||||
Reference in New Issue
Block a user