刚刚学习python,想做个函数来动态控制弹出框的内容,如下:
[code="python"]import wx
class App(wx.App):
def OnInit(self):
dlg = wx.MessageDialog(None, "hello world", 'name', wx.YES_NO|wx.ICON_QUESTION)
result = dlg.ShowModal()
dlg.Destroy()
def alert():
app = App()
app.MainLoop()
alert()
[/code]
但是这里的hello world是写死的,name也是写死的,不知道怎么写alert()函数才能使得可以控制弹出框的参数呢?
上面代码缩进有问题:alert()调用要缩进
[code="Python"]#!usr/bin/python
import wx
class App(wx.App):
def OnInit(self):
alert("Hello world!","My second Python script.")
return True
def alert(msg,tittle):
dlg = wx.MessageDialog(None, msg,tittle,wx.YES_NO|wx.ICON_QUESTION)
result = dlg.ShowModal()
dlg.Destroy()
if name == '__main__':
app = App()
app.MainLoop()
[/code]