问题
I'm trying to do a TextEntryDialog followed by another TextEntryDialog. I can only get the first one to appear and then after I hit ok a second one does not appear. I'm sure it's something easy, anyone have any suggestions? Thanks.
#! /usr/bin/env python
import wx
class bucky(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'Frame aka window', size=(300,200))
panel = wx.Panel(self)
user = wx.TextEntryDialog(None, "Login", "Username", "")
if user.ShowModal() == wx.ID_OK:
username = user.GetValue()
user.Destroy()
password = wx.TextEntryDialog(None, "Password", "Password", "")
if __name__ =='__main__':
app = wx.PySimpleApp()
frame = bucky(parent=None, id=-1)
frame.Show()
app.MainLoop()
回答1:
You need ShowModal
again to see your entry:
user = wx.TextEntryDialog(None, "Login", "Username", "")
if user.ShowModal() == wx.ID_OK:
print 'here'
password = wx.TextEntryDialog(None, "Password", "Password", "")
if password.ShowModal() == wx.ID_OK:
print 'there'
Note you do not need to destroy
the dialog
来源:https://stackoverflow.com/questions/11912784/wxpython-multiple-textentrydialog-windows