fork download
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. #
  4. # generated by wxGlade 1.0.4 on Sat Mar 25 10:32:30 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 hangman import dictionary, count_max, Env, initialize, interp
  15.  
  16. msg = {"lossmsg": 'あなたの負けです! 正解: \n\t{}',
  17. "playmsg": '当てる言葉 : \n\t {}',
  18. "successmsg": '正解!あなたの勝ちです。\nおめでとう。'}
  19.  
  20. class Controller(object):
  21. def __init__(self):
  22. pub.subscribe(self.read, "Controller")
  23. def read(self, x, env):
  24. pub.sendMessage("Model.eval", x='y' if x == 'リセット' else 'n'
  25. if x == '終了' else x, env=env)
  26.  
  27. class Model(object):
  28. def __init__(self):
  29. pub.subscribe(self.eval, "Model")
  30. def eval(self, x, env):
  31. pub.sendMessage("View.SetProperties", env=interp(x, env))
  32. # end wxGlade
  33.  
  34.  
  35. class View(wx.Frame):
  36. def __init__(self, *args, **kwds):
  37. # begin wxGlade: View.__init__
  38. kwds["style"] = kwds.get("style", 0) | wx.CAPTION | wx.CLIP_CHILDREN | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.SYSTEM_MENU
  39. wx.Frame.__init__(self, *args, **kwds)
  40. self.SetSize((400, 300))
  41. self.SetTitle(u"ハングマン")
  42.  
  43. sizer_1 = wx.BoxSizer(wx.VERTICAL)
  44.  
  45. sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
  46. sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
  47.  
  48. bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("img/gallows1.png", wx.BITMAP_TYPE_ANY))
  49. sizer_2.Add(bitmap_1, 0, 0, 0)
  50.  
  51. grid_sizer_1 = wx.GridSizer(7, 4, 0, 0)
  52. sizer_2.Add(grid_sizer_1, 1, wx.EXPAND, 0)
  53.  
  54. self.A = wx.Button(self, wx.ID_ANY, "A")
  55. self.A.SetMinSize((50, 28))
  56. grid_sizer_1.Add(self.A, 0, 0, 0)
  57.  
  58. self.B = wx.Button(self, wx.ID_ANY, "B")
  59. self.B.SetMinSize((50, 28))
  60. grid_sizer_1.Add(self.B, 0, 0, 0)
  61.  
  62. self.C = wx.Button(self, wx.ID_ANY, "C")
  63. self.C.SetMinSize((50, 28))
  64. grid_sizer_1.Add(self.C, 0, 0, 0)
  65.  
  66. self.D = wx.Button(self, wx.ID_ANY, "D")
  67. self.D.SetMinSize((50, 28))
  68. grid_sizer_1.Add(self.D, 0, 0, 0)
  69.  
  70. self.E = wx.Button(self, wx.ID_ANY, "E")
  71. self.E.SetMinSize((50, 28))
  72. grid_sizer_1.Add(self.E, 0, 0, 0)
  73.  
  74. self.F = wx.Button(self, wx.ID_ANY, "F")
  75. self.F.SetMinSize((50, 28))
  76. grid_sizer_1.Add(self.F, 0, 0, 0)
  77.  
  78. self.G = wx.Button(self, wx.ID_ANY, "G")
  79. self.G.SetMinSize((50, 28))
  80. grid_sizer_1.Add(self.G, 0, 0, 0)
  81.  
  82. self.H = wx.Button(self, wx.ID_ANY, "H")
  83. self.H.SetMinSize((50, 28))
  84. grid_sizer_1.Add(self.H, 0, 0, 0)
  85.  
  86. self.I = wx.Button(self, wx.ID_ANY, "I")
  87. self.I.SetMinSize((50, 28))
  88. grid_sizer_1.Add(self.I, 0, 0, 0)
  89.  
  90. self.J = wx.Button(self, wx.ID_ANY, "J")
  91. self.J.SetMinSize((50, 28))
  92. grid_sizer_1.Add(self.J, 0, 0, 0)
  93.  
  94. self.K = wx.Button(self, wx.ID_ANY, "K")
  95. self.K.SetMinSize((50, 28))
  96. grid_sizer_1.Add(self.K, 0, 0, 0)
  97.  
  98. self.L = wx.Button(self, wx.ID_ANY, "L")
  99. self.L.SetMinSize((50, 28))
  100. grid_sizer_1.Add(self.L, 0, 0, 0)
  101.  
  102. self.M = wx.Button(self, wx.ID_ANY, "M")
  103. self.M.SetMinSize((50, 28))
  104. grid_sizer_1.Add(self.M, 0, 0, 0)
  105.  
  106. self.N = wx.Button(self, wx.ID_ANY, "N")
  107. self.N.SetMinSize((50, 28))
  108. grid_sizer_1.Add(self.N, 0, 0, 0)
  109.  
  110. self.O = wx.Button(self, wx.ID_ANY, "O")
  111. self.O.SetMinSize((50, 28))
  112. grid_sizer_1.Add(self.O, 0, 0, 0)
  113.  
  114. self.P = wx.Button(self, wx.ID_ANY, "P")
  115. self.P.SetMinSize((50, 28))
  116. grid_sizer_1.Add(self.P, 0, 0, 0)
  117.  
  118. self.Q = wx.Button(self, wx.ID_ANY, "Q")
  119. self.Q.SetMinSize((50, 28))
  120. grid_sizer_1.Add(self.Q, 0, 0, 0)
  121.  
  122. self.R = wx.Button(self, wx.ID_ANY, "R")
  123. self.R.SetMinSize((50, 28))
  124. grid_sizer_1.Add(self.R, 0, 0, 0)
  125.  
  126. self.S = wx.Button(self, wx.ID_ANY, "S")
  127. self.S.SetMinSize((50, 28))
  128. grid_sizer_1.Add(self.S, 0, 0, 0)
  129.  
  130. self.T = wx.Button(self, wx.ID_ANY, "T")
  131. self.T.SetMinSize((50, 28))
  132. grid_sizer_1.Add(self.T, 0, 0, 0)
  133.  
  134. self.U = wx.Button(self, wx.ID_ANY, "U")
  135. self.U.SetMinSize((50, 28))
  136. grid_sizer_1.Add(self.U, 0, 0, 0)
  137.  
  138. self.V = wx.Button(self, wx.ID_ANY, "V")
  139. self.V.SetMinSize((50, 28))
  140. grid_sizer_1.Add(self.V, 0, 0, 0)
  141.  
  142. self.W = wx.Button(self, wx.ID_ANY, "W")
  143. self.W.SetMinSize((50, 28))
  144. grid_sizer_1.Add(self.W, 0, 0, 0)
  145.  
  146. self.X = wx.Button(self, wx.ID_ANY, "X")
  147. self.X.SetMinSize((50, 28))
  148. grid_sizer_1.Add(self.X, 0, 0, 0)
  149.  
  150. grid_sizer_1.Add((50, 28), 0, 0, 0)
  151.  
  152. self.Y = wx.Button(self, wx.ID_ANY, "Y")
  153. self.Y.SetMinSize((50, 28))
  154. grid_sizer_1.Add(self.Y, 0, 0, 0)
  155.  
  156. self.Z = wx.Button(self, wx.ID_ANY, "Z")
  157. self.Z.SetMinSize((50, 28))
  158. grid_sizer_1.Add(self.Z, 0, 0, 0)
  159.  
  160. grid_sizer_1.Add((50, 28), 0, 0, 0)
  161.  
  162. self.panel_1 = wx.Panel(self, wx.ID_ANY)
  163. self.panel_1.SetBackgroundColour(wx.Colour(50, 153, 204))
  164. sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
  165.  
  166. sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
  167.  
  168. label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, "")
  169. label_1.SetMinSize((200, 100))
  170. sizer_3.Add(label_1, 0, 0, 0)
  171.  
  172. self.Reset = wx.Button(self.panel_1, wx.ID_ANY, u"リセット")
  173. self.Reset.Enable(False)
  174. sizer_3.Add(self.Reset, 0, wx.ALIGN_CENTER_VERTICAL, 0)
  175.  
  176. self.Quit = wx.Button(self.panel_1, wx.ID_ANY, u"終了")
  177. self.Quit.Enable(False)
  178. sizer_3.Add(self.Quit, 0, wx.ALIGN_CENTER_VERTICAL, 0)
  179.  
  180. self.panel_1.SetSizer(sizer_3)
  181.  
  182. self.SetSizer(sizer_1)
  183.  
  184. self.Layout()
  185.  
  186. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.A.GetLabel(), env=self.env), self.A)
  187. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.B.GetLabel(), env=self.env), self.B)
  188. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.C.GetLabel(), env=self.env), self.C)
  189. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.D.GetLabel(), env=self.env), self.D)
  190. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.E.GetLabel(), env=self.env), self.E)
  191. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.F.GetLabel(), env=self.env), self.F)
  192. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.G.GetLabel(), env=self.env), self.G)
  193. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.H.GetLabel(), env=self.env), self.H)
  194. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.I.GetLabel(), env=self.env), self.I)
  195. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.J.GetLabel(), env=self.env), self.J)
  196. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.K.GetLabel(), env=self.env), self.K)
  197. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.L.GetLabel(), env=self.env), self.L)
  198. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.M.GetLabel(), env=self.env), self.M)
  199. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.N.GetLabel(), env=self.env), self.N)
  200. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.O.GetLabel(), env=self.env), self.O)
  201. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.P.GetLabel(), env=self.env), self.P)
  202. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Q.GetLabel(), env=self.env), self.Q)
  203. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.R.GetLabel(), env=self.env), self.R)
  204. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.S.GetLabel(), env=self.env), self.S)
  205. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.T.GetLabel(), env=self.env), self.T)
  206. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.U.GetLabel(), env=self.env), self.U)
  207. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.V.GetLabel(), env=self.env), self.V)
  208. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.W.GetLabel(), env=self.env), self.W)
  209. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.X.GetLabel(), env=self.env), self.X)
  210. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Y.GetLabel(), env=self.env), self.Y)
  211. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Z.GetLabel(), env=self.env), self.Z)
  212. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Reset.GetLabel(), env=self.env), self.Reset)
  213. self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Quit.GetLabel(), env=self.env), self.Quit)
  214. # end wxGlade
  215.  
  216. # end of class View
  217.  
  218. class Hangman(wx.App):
  219. def OnInit(self):
  220. self.View = View(None, wx.ID_ANY, "")
  221. self.SetTopWindow(self.View)
  222. self.View.Show()
  223. return True
  224.  
  225. # end of class Hangman
  226.  
  227. if __name__ == "__main__":
  228. Hangman = Hangman(0)
  229. Hangman.MainLoop()
  230.  
Runtime error #stdin #stdout #stderr 0.15s 26352KB
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'