【问题标题】:WXPYTHON - How Do I Get Users Input in a MessageDialog?WXPYTHON - 如何在 MessageDialog 中获取用户输入?
【发布时间】:2019-03-12 17:59:29
【问题描述】:

这是我的代码:

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 并拒绝关闭。

【问题讨论】:

    标签: python python-3.x wxwidgets wxpython


    【解决方案1】:

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

    所以,我把我的代码改成了这个:

       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()
    

    它就像一个魅力!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-03
      • 1970-01-01
      • 1970-01-01
      • 2010-11-10
      • 2011-07-14
      • 1970-01-01
      相关资源
      最近更新 更多