wxpython - 多个 TextEntryDialog 窗口 [英] wxpython - Multiple TextEntryDialog windows

查看:42
本文介绍了wxpython - 多个 TextEntryDialog 窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试先执行一个 TextEntryDialog,然后再执行另一个 TextEntryDialog.我只能让第一个出现,然后在我点击确定后第二个没有出现.我确定这很容易,有人有什么建议吗?谢谢.

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()

推荐答案

您需要再次 ShowModal 才能看到您的条目:

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'

注意你不需要销毁对话框

这篇关于wxpython - 多个 TextEntryDialog 窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆