Ann top menu event + manage on quit event request
This commit is contained in:
@@ -19,7 +19,7 @@ class MainWindow(tk.Tk):
|
||||
__frame_id: int = None
|
||||
|
||||
# Constructor
|
||||
def __init__(self, controller: MainController):
|
||||
def __init__(self, controller: MainController) -> None:
|
||||
super().__init__()
|
||||
|
||||
# Init view repository
|
||||
@@ -29,12 +29,13 @@ class MainWindow(tk.Tk):
|
||||
self.__controller = controller
|
||||
controller.set_view(self)
|
||||
|
||||
# Init view components
|
||||
# Init view components & more
|
||||
self.__init_window()
|
||||
self.__init_top_menu()
|
||||
self.__init_bind_protocol()
|
||||
|
||||
# START Internal methods
|
||||
def __init_window(self):
|
||||
def __init_window(self) -> None:
|
||||
"""
|
||||
[internal function]
|
||||
=> Initialize window parameters
|
||||
@@ -44,7 +45,7 @@ class MainWindow(tk.Tk):
|
||||
self.resizable(False, False)
|
||||
self.config(bg='#f7ef38')
|
||||
|
||||
def __init_top_menu(self):
|
||||
def __init_top_menu(self) -> None:
|
||||
"""
|
||||
[internal function]
|
||||
=> Initialize top menu of the window.
|
||||
@@ -52,21 +53,24 @@ 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.alert)
|
||||
col1_menu.add_command(label="Open folder", command=self.__controller.on_open_folder)
|
||||
col1_menu.add_separator()
|
||||
col1_menu.add_command(label="Quit", command=self.alert)
|
||||
col1_menu.add_command(label="Quit", command=self.__controller.on_quite)
|
||||
main_menu.add_cascade(label="File", menu=col1_menu)
|
||||
|
||||
col2_menu = tk.Menu(main_menu, tearoff=0)
|
||||
col2_menu.add_command(label="Check for update", command=self.__controller.on_check_for_update)
|
||||
col2_menu.add_command(label="About", command=self.alert)
|
||||
col2_menu.add_command(label="About", command=self.__controller.on_about)
|
||||
main_menu.add_cascade(label="Help", menu=col2_menu)
|
||||
|
||||
self.config(menu=main_menu)
|
||||
|
||||
def alert(self):
|
||||
# TODO remove
|
||||
print("You clicked")
|
||||
def __init_bind_protocol(self) -> None:
|
||||
"""
|
||||
[internal function]
|
||||
=> Initialize the function bindding on events of the main window.
|
||||
"""
|
||||
self.protocol("WM_DELETE_WINDOW", self.__controller.on_quite)
|
||||
# END Internal methods
|
||||
|
||||
# START App methods
|
||||
@@ -95,4 +99,11 @@ class MainWindow(tk.Tk):
|
||||
self.__frame_id = frame
|
||||
else:
|
||||
raise ValueError("Unable to find the requested Frame")
|
||||
|
||||
def close_window(self) -> None:
|
||||
"""
|
||||
[function for app & controller]
|
||||
TODO
|
||||
"""
|
||||
self.destroy()
|
||||
# END Controller methods
|
||||
|
||||
Reference in New Issue
Block a user