wxpython - Multiple TextEntryDialog windows

女生的网名这么多〃 提交于 2019-12-12 02:20:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!