0

我正在尝试做一个TextEntryDialog,然后是另一个TextEntryDialog。我只能让第一个出现,然后在我点击确定后第二个不出现。我敢肯定这很容易,有人有什么建议吗?谢谢。

#! /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()
4

1 回答 1

0

您需要ShowModal再次查看您的条目:

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'

请注意,您不需要destroy对话框

于 2012-08-11T07:19:49.267 回答