代码演示
import wx
class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(parent=None, title="提示框")
panel = wx.Panel(frame, -1)
self.button1 = wx.Button(panel, -1, "hahaha1", (10, 0))
self.Bind(wx.EVT_BUTTON, self.get_message, self.button1)
self.button2 = wx.Button(panel, -1, "hahaha2", (10, 30))
self.Bind(wx.EVT_BUTTON, self.yes_no, self.button2)
self.button3 = wx.Button(panel, -1, "hahaha3", (10, 60))
self.Bind(wx.EVT_BUTTON, self.ok_cancel, self.button3)
self.button4 = wx.Button(panel, -1, "hahaha4", (10, 90))
self.Bind(wx.EVT_BUTTON, self.ok_cancel_2, self.button4)
self.button5 = wx.Button(panel, -1, "hahaha5", (10, 120))
self.Bind(wx.EVT_BUTTON, self.yes_no_2, self.button5)
frame.Show()
return True
def get_message(self, event):
'''弹出信息'''
wx.MessageBox("information", "hahaha1", wx.OK | wx.ICON_INFORMATION)
def yes_no(self, event):
'''弹出选择yes或no的框'''
wx.MessageBox("are you ready", "提示框", wx.YES_NO | wx.ICON_QUESTION)
def ok_cancel(self, event):
'''弹出选择ok或cancel的提示框'''
wx.MessageBox("OK", "info", wx.OK | wx.CANCEL | wx.ICON_ERROR)
def ok_cancel_2(self, event):
'''弹出选择ok或cancel的提示框'''
wx.MessageBox("OK", "info", wx.OK | wx.CANCEL | wx.ICON_EXCLAMATION)
def yes_no_2(self, event):
'''弹出yes或no的提示框'''
wx.MessageBox("OK", "info", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_HAND)
app = MyApp()
app.MainLoop()