fork download
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. #
  4. # generated by wxGlade 1.0.4 on Sun Apr 23 13:13:06 2023
  5. #
  6.  
  7. import wx
  8.  
  9. # begin wxGlade: dependencies
  10. # end wxGlade
  11.  
  12. # begin wxGlade: extracode
  13. from pubsub import pub
  14. from mvc_example import Env, install_package, interp # CLI 版のプログラムファイル
  15.  
  16. class Controller(object):
  17. def __init__(self):
  18. pub.subscribe(self.read, "Controller")
  19. def read(self, x, env):
  20. pub.sendMessage("Model.eval", x = x, env = env)
  21.  
  22. class Model(object):
  23. def __init__(self):
  24. pub.subscribe(self.eval, "Model")
  25. def eval(self, x, env):
  26. pub.sendMessage("View.setProperty", env = interp(x, env))
  27. # end wxGlade
  28.  
  29.  
  30. class View(wx.Frame):
  31. def __init__(self, *args, **kwds):
  32. # begin wxGlade: View.__init__
  33. self.env = Env(install_package())
  34. kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
  35. wx.Frame.__init__(self, *args, **kwds)
  36. self.SetSize((400, 300))
  37. self.SetTitle("ModelViewController")
  38.  
  39. grid_sizer_1 = wx.GridSizer(2, 2, 0, 0)
  40.  
  41. text = wx.StaticText(self, wx.ID_ANY, "My Money")
  42. grid_sizer_1.Add(text, 0, wx.ALIGN_CENTER, 0)
  43.  
  44. self.add = wx.Button(self, wx.ID_ANY, "Add Money")
  45. grid_sizer_1.Add(self.add, 0, wx.ALIGN_CENTER, 0)
  46.  
  47. self.ctrl = wx.TextCtrl(self, wx.ID_ANY, "\"\"")
  48. self.ctrl.Enable(False)
  49. grid_sizer_1.Add(self.ctrl, 0, wx.ALIGN_CENTER, 0)
  50.  
  51. self.remove = wx.Button(self, wx.ID_ANY, "Remove Money")
  52. grid_sizer_1.Add(self.remove, 0, wx.ALIGN_CENTER, 0)
  53.  
  54. self.SetSizer(grid_sizer_1)
  55.  
  56. self.Layout()
  57. pub.subscribe(self.setProperty, "View")
  58.  
  59. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x = self.add.GetLabel(), env = self.env), self.add)
  60. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x = self.remove.GetLabel(), env = self.env), self.remove)
  61. # end wxGlade
  62.  
  63. # end of class View
  64.  
  65. class MyApp(wx.App):
  66. def OnInit(self):
  67. self.View = View(None, wx.ID_ANY, "")
  68. self.SetTopWindow(self.View)
  69. self.View.Show()
  70. return True
  71.  
  72. # end of class MyApp
  73.  
  74. if __name__ == "__main__":
  75. app = MyApp(0)
  76. app.MainLoop()
  77.  
Runtime error #stdin #stdout #stderr 0.14s 25920KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 7, in <module>
ModuleNotFoundError: No module named 'wx'