WXPYTHON-如何使用户在MessageDialog中输入?

时间:2018-10-08 05:33:11

标签: python python-3.x wxpython wxwidgets wxpython-phoenix

这是我的代码:

def Quit(self, e):
    suremsg = wx.MessageDialog(None, "Are you sure you want to close the program?","Are you sure?", wx.YES_NO | wx.ICON_QUESTION).ShowModal()

def Close(self):
    self.Close()

从技术上讲,我希望该程序在用户单击“是”时关闭,并关闭MessageDialog,并在用户单击“否”时拒绝关闭。

1 个答案:

答案 0 :(得分:0)

好的,我浏览了很多文章,这些文章解释了如何获得用户输入的结果。

因此,我将代码切换为:

   def Quit(self, e):
    suremsg = wx.MessageDialog(None, "Are you sure you want to close the program?","Are you sure?", wx.YES_NO | wx.ICON_QUESTION)
    result = suremsg.ShowModal()
    if result == wx.ID_YES:
       self.Close()
    else:
       suremsg.Destroy()

它就像一个魅力!