简体   繁体   English

wxMessageBox在python中返回什么?

[英]What does wxMessageBox return in python?

I'm looking for simple wx.MessageBox return value example. 我正在寻找简单的wx.MessageBox返回值示例。 I've seen some basic examples and they look a lot like this. 我已经看到了一些基本的例子,它们看起来很像这样。 So far I have: 到目前为止,我有:

dlg = wx.MessageBox( 'What do you choose?, 'Test Dialog', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION )
if dlg == wx.ID_YES:
    print 'You picked yes'

dlg seems to return 8 for No and 2 for yes. dlg似乎返回8表示否,2表示肯定。 However wx.ID_YES = 2503 and wx.ID_NO = 5104 但是wx.ID_YES = 2503和wx.ID_NO = 5104

Thanks for your time. 谢谢你的时间。

wx.MessageBox returns one of wx.YES , wx.NO , wx.OK , wx.CANCEL . wx.MessageBox返回wx.YESwx.NOwx.OKwx.CANCEL

Use wx.YES instead of wx.ID_YES , wx.NO instead of wx.ID_NO : 使用wx.YES而不是wx.ID_YESwx.NO而不是wx.ID_NO

>>> import wx
>>> wx.YES
2
>>> wx.NO
8

See ::wxMessageBox 请参阅::wxMessageBox

You can also try this: 你也可以试试这个:

yesNobox = wx.MessageDialog(None,"What do you choose?",'Question',wx.YES_NO)
yesNoAnswer = yesNobox.ShowModal()

so you have your answer in the yesNoAnswer to see if its yes or no you can use this 所以你在yesNoAnswer中得到答案,看看是否可以使用它

yesNoAnswer == wx.ID_YES: 
yesNoAnswer == wx.ID_NO:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM