2012-08-11 45 views
0

我想要做一個TextEntryDialog,然後是另一個TextEntryDialog。我只能得到第一個出現,然後我點擊確定後,第二個不出現。我確定這很容易,任何人有任何建議?謝謝。wxpython - 多個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() 

回答

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對話框

+0

嗯,這很容易!非常感謝(這是我的第一篇文章,一定會回來的!)我也發現我可以使用password.Show(True)並且很明顯工作。再次感謝! – 2012-08-11 07:33:32