quickgui は便利なのだけれど、ちょっと好みに合わないところがあるので、手を入れてみることにした。最初に、シンプルな msgbox を作って、ソースに追加してみた。これで easygui みたいなメッセージボックスを表示できるようになった。
class _SimpleMessageDialog(wx.Dialog):
def __init__(self, message, title, ok_button):
wx.Dialog.__init__(self, None, -1, title,size=(400, 80))
self.CenterOnScreen(wx.BOTH)
button = wx.Button(self, label=ok_button)
stMsg = wx.StaticText(self, -1, message)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(stMsg, 1, wx.ALIGN_CENTER|wx.TOP, 10)
vbox.Add(button,1, wx.ALIGN_CENTER|wx.TOP, 10)
self.SetSizer(vbox)
self.Bind(wx.EVT_BUTTON, self.OnExit, id=button.GetId())
def OnExit(self, event):
self.Close()
def MessageBox(msg, title='Message', ok_button="OK"):
"""Messagebox(msg, title='Message', ok_button="OK")
Displays simple message box
"""
dlg = _SimpleMessageDialog(msg, title, ok_button)
result = dlg.ShowModal()
return result
msgbox = MessageBox