#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# generated by wxGlade 1.0.4 on Sat Mar 25 10:32:30 2023
#
import wx
# begin wxGlade: dependencies
# end wxGlade
# begin wxGlade: extracode
from pubsub import pub
from hangman import dictionary, count_max, Env, initialize, interp
msg = {"lossmsg": 'あなたの負けです! 正解: \n\t{}',
"playmsg": '当てる言葉 : \n\t {}',
"successmsg": '正解!あなたの勝ちです。\nおめでとう。'}
class Controller(object):
def __init__(self):
pub.subscribe(self.read, "Controller")
def read(self, x, env):
pub.sendMessage("Model.eval", x='y' if x == 'リセット' else 'n'
if x == '終了' else x, env=env)
class Model(object):
def __init__(self):
pub.subscribe(self.eval, "Model")
def eval(self, x, env):
pub.sendMessage("View.SetProperties", env=interp(x, env))
# end wxGlade
class View(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: View.__init__
kwds["style"] = kwds.get("style", 0) | wx.CAPTION | wx.CLIP_CHILDREN | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.SYSTEM_MENU
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((400, 300))
self.SetTitle(u"ハングマン")
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("img/gallows1.png", wx.BITMAP_TYPE_ANY))
sizer_2.Add(bitmap_1, 0, 0, 0)
grid_sizer_1 = wx.GridSizer(7, 4, 0, 0)
sizer_2.Add(grid_sizer_1, 1, wx.EXPAND, 0)
self.A = wx.Button(self, wx.ID_ANY, "A")
self.A.SetMinSize((50, 28))
grid_sizer_1.Add(self.A, 0, 0, 0)
self.B = wx.Button(self, wx.ID_ANY, "B")
self.B.SetMinSize((50, 28))
grid_sizer_1.Add(self.B, 0, 0, 0)
self.C = wx.Button(self, wx.ID_ANY, "C")
self.C.SetMinSize((50, 28))
grid_sizer_1.Add(self.C, 0, 0, 0)
self.D = wx.Button(self, wx.ID_ANY, "D")
self.D.SetMinSize((50, 28))
grid_sizer_1.Add(self.D, 0, 0, 0)
self.E = wx.Button(self, wx.ID_ANY, "E")
self.E.SetMinSize((50, 28))
grid_sizer_1.Add(self.E, 0, 0, 0)
self.F = wx.Button(self, wx.ID_ANY, "F")
self.F.SetMinSize((50, 28))
grid_sizer_1.Add(self.F, 0, 0, 0)
self.G = wx.Button(self, wx.ID_ANY, "G")
self.G.SetMinSize((50, 28))
grid_sizer_1.Add(self.G, 0, 0, 0)
self.H = wx.Button(self, wx.ID_ANY, "H")
self.H.SetMinSize((50, 28))
grid_sizer_1.Add(self.H, 0, 0, 0)
self.I = wx.Button(self, wx.ID_ANY, "I")
self.I.SetMinSize((50, 28))
grid_sizer_1.Add(self.I, 0, 0, 0)
self.J = wx.Button(self, wx.ID_ANY, "J")
self.J.SetMinSize((50, 28))
grid_sizer_1.Add(self.J, 0, 0, 0)
self.K = wx.Button(self, wx.ID_ANY, "K")
self.K.SetMinSize((50, 28))
grid_sizer_1.Add(self.K, 0, 0, 0)
self.L = wx.Button(self, wx.ID_ANY, "L")
self.L.SetMinSize((50, 28))
grid_sizer_1.Add(self.L, 0, 0, 0)
self.M = wx.Button(self, wx.ID_ANY, "M")
self.M.SetMinSize((50, 28))
grid_sizer_1.Add(self.M, 0, 0, 0)
self.N = wx.Button(self, wx.ID_ANY, "N")
self.N.SetMinSize((50, 28))
grid_sizer_1.Add(self.N, 0, 0, 0)
self.O = wx.Button(self, wx.ID_ANY, "O")
self.O.SetMinSize((50, 28))
grid_sizer_1.Add(self.O, 0, 0, 0)
self.P = wx.Button(self, wx.ID_ANY, "P")
self.P.SetMinSize((50, 28))
grid_sizer_1.Add(self.P, 0, 0, 0)
self.Q = wx.Button(self, wx.ID_ANY, "Q")
self.Q.SetMinSize((50, 28))
grid_sizer_1.Add(self.Q, 0, 0, 0)
self.R = wx.Button(self, wx.ID_ANY, "R")
self.R.SetMinSize((50, 28))
grid_sizer_1.Add(self.R, 0, 0, 0)
self.S = wx.Button(self, wx.ID_ANY, "S")
self.S.SetMinSize((50, 28))
grid_sizer_1.Add(self.S, 0, 0, 0)
self.T = wx.Button(self, wx.ID_ANY, "T")
self.T.SetMinSize((50, 28))
grid_sizer_1.Add(self.T, 0, 0, 0)
self.U = wx.Button(self, wx.ID_ANY, "U")
self.U.SetMinSize((50, 28))
grid_sizer_1.Add(self.U, 0, 0, 0)
self.V = wx.Button(self, wx.ID_ANY, "V")
self.V.SetMinSize((50, 28))
grid_sizer_1.Add(self.V, 0, 0, 0)
self.W = wx.Button(self, wx.ID_ANY, "W")
self.W.SetMinSize((50, 28))
grid_sizer_1.Add(self.W, 0, 0, 0)
self.X = wx.Button(self, wx.ID_ANY, "X")
self.X.SetMinSize((50, 28))
grid_sizer_1.Add(self.X, 0, 0, 0)
grid_sizer_1.Add((50, 28), 0, 0, 0)
self.Y = wx.Button(self, wx.ID_ANY, "Y")
self.Y.SetMinSize((50, 28))
grid_sizer_1.Add(self.Y, 0, 0, 0)
self.Z = wx.Button(self, wx.ID_ANY, "Z")
self.Z.SetMinSize((50, 28))
grid_sizer_1.Add(self.Z, 0, 0, 0)
grid_sizer_1.Add((50, 28), 0, 0, 0)
self.panel_1 = wx.Panel(self, wx.ID_ANY)
self.panel_1.SetBackgroundColour(wx.Colour(50, 153, 204))
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, "")
label_1.SetMinSize((200, 100))
sizer_3.Add(label_1, 0, 0, 0)
self.Reset = wx.Button(self.panel_1, wx.ID_ANY, u"リセット")
self.Reset.Enable(False)
sizer_3.Add(self.Reset, 0, wx.ALIGN_CENTER_VERTICAL, 0)
self.Quit = wx.Button(self.panel_1, wx.ID_ANY, u"終了")
self.Quit.Enable(False)
sizer_3.Add(self.Quit, 0, wx.ALIGN_CENTER_VERTICAL, 0)
self.panel_1.SetSizer(sizer_3)
self.SetSizer(sizer_1)
self.Layout()
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.A.GetLabel(), env=self.env), self.A)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.B.GetLabel(), env=self.env), self.B)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.C.GetLabel(), env=self.env), self.C)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.D.GetLabel(), env=self.env), self.D)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.E.GetLabel(), env=self.env), self.E)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.F.GetLabel(), env=self.env), self.F)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.G.GetLabel(), env=self.env), self.G)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.H.GetLabel(), env=self.env), self.H)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.I.GetLabel(), env=self.env), self.I)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.J.GetLabel(), env=self.env), self.J)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.K.GetLabel(), env=self.env), self.K)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.L.GetLabel(), env=self.env), self.L)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.M.GetLabel(), env=self.env), self.M)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.N.GetLabel(), env=self.env), self.N)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.O.GetLabel(), env=self.env), self.O)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.P.GetLabel(), env=self.env), self.P)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Q.GetLabel(), env=self.env), self.Q)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.R.GetLabel(), env=self.env), self.R)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.S.GetLabel(), env=self.env), self.S)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.T.GetLabel(), env=self.env), self.T)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.U.GetLabel(), env=self.env), self.U)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.V.GetLabel(), env=self.env), self.V)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.W.GetLabel(), env=self.env), self.W)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.X.GetLabel(), env=self.env), self.X)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Y.GetLabel(), env=self.env), self.Y)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Z.GetLabel(), env=self.env), self.Z)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Reset.GetLabel(), env=self.env), self.Reset)
self.Bind(wx.EVT_BUTTON, lambda event: pub.sendMessage("Controller.read", x=self.Quit.GetLabel(), env=self.env), self.Quit)
# end wxGlade
# end of class View
class Hangman(wx.App):
def OnInit(self):
self.View = View(None, wx.ID_ANY, "")
self.SetTopWindow(self.View)
self.View.Show()
return True
# end of class Hangman
if __name__ == "__main__":
Hangman = Hangman(0)
Hangman.MainLoop()
IyEvdXNyL2Jpbi9lbnYgcHl0aG9uMwojIC0qLSBjb2Rpbmc6IFVURi04IC0qLQojCiMgZ2VuZXJhdGVkIGJ5IHd4R2xhZGUgMS4wLjQgb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