-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the MVC model in gui package
- Loading branch information
1 parent
f6807b0
commit 656db5c
Showing
6 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Main entrypoint for the GUI application. | ||
""" | ||
|
||
from antares_web_installer.gui.wizard_controller import WizardController | ||
|
||
|
||
def main(): | ||
controller = WizardController() | ||
controller.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import tkinter as tk | ||
|
||
|
||
class Model: | ||
""" | ||
Base class of the MVC model. | ||
Attributes: | ||
controller: The controller of the MVC. | ||
""" | ||
|
||
def __init__(self, controller: "Controller"): | ||
self.controller = controller | ||
|
||
|
||
class View(tk.Tk): | ||
""" | ||
Base class of the MVC view. | ||
Attributes: | ||
controller: The controller of the MVC. | ||
""" | ||
|
||
def __init__(self, controller: "Controller"): | ||
super().__init__() | ||
self.controller = controller | ||
self.init_window() | ||
self.init_handlers() | ||
|
||
def init_window(self) -> None: | ||
self.title("MVC Demo") | ||
|
||
def init_handlers(self) -> None: | ||
self.protocol("WM_DELETE_WINDOW", self.controller.quit) | ||
self.bind("<Escape>", lambda e: self.controller.quit()) | ||
|
||
|
||
class Controller: | ||
""" | ||
Base class of the MVC controller. | ||
Attributes: | ||
model: The model of the MVC. | ||
view: The view of the MVC. | ||
""" | ||
|
||
def __init__(self): | ||
self.model = self.init_model() | ||
self.view = self.init_view() | ||
|
||
def init_model(self) -> Model: | ||
return Model(self) | ||
|
||
def init_view(self) -> View: | ||
return View(self) | ||
|
||
def run(self) -> None: | ||
self.view.mainloop() | ||
|
||
def quit(self) -> None: | ||
self.view.destroy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from .mvc import Controller, Model, View | ||
from .wizard_model import WizardModel | ||
from .wizard_view import WizardView | ||
|
||
|
||
class WizardController(Controller): | ||
|
||
def init_model(self) -> Model: | ||
return WizardModel(self) | ||
|
||
def init_view(self) -> View: | ||
return WizardView(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .mvc import Model | ||
|
||
|
||
class WizardModel(Model): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .mvc import View | ||
|
||
|
||
class WizardView(View): | ||
def init_window(self) -> None: | ||
super().init_window() | ||
self.title("Antares Web Installer") |