< wxPython GUI

wxPython MVC

Szerző: Sallai András

Copyright © Sallai András, 2020

Licenc: CC Attribution-Share Alike 4.0 International

Web: https://szit.hu

Ablak nyomógombbal

Könyvtárszerkezet

projekt01/
|-controllers/
| `-main_controller.py
|-models/
| `-main_model.py
|-views/
| `-main_frame.py
`-projekt01.py

UML diagram

Kód

import wx from controllers.main_controller import MainController class Prog01App(wx.App): def OnInit(self): MainController() return True prog01 = Prog01App() prog01.MainLoop()
import wx from views.main_frame import MainFrame from models.main_model import MainModel class MainController: def __init__(self): self.frame = MainFrame(None) self.frame.Bind(wx.EVT_BUTTON, self.on_click_button, self.frame.button) self.main_model = MainModel() self.frame.Show() def on_click_button(self, event): name = self.main_model.get_name(); self.frame.SetTitle(name)
import wx class MainFrame(wx.Frame): def __init__(self, parent): super(MainFrame, self).__init__(parent) self.SetSize((400, 300)) self.button = wx.Button(self, label="Mehet")
class MainModel: def get_name(self): return 'Nagy János'

Egyéb irodalom

https://wiki.wxpython.org/ModelViewController (2020)