wxpython 第二个窗口如何始终保持在顶部直到关闭?就像对话框那样子的

茫然99 2019-04-18 09:48:53
wxpython 写的二个窗口,点击按钮显示第二个窗口。问题:
第二个窗口显示后,怎么做到不让点击第一个窗口?必须关闭窗口2才能点击窗口1。就像对话框一样,显示了对话框就不能点击后面的窗口?
谢谢!

[code=pythonclass InfoPanel(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, "Sysniffer", pos=(0, 0), size=(860, 600))
panel = wx.Panel(self, -1)
button = wx.Button(panel, wx.ID_ANY, pos=(70, 300), size=(150, 40), label='Windows2')
button.Bind(wx.EVT_BUTTON, self.windows_trigger)

def windows_trigger(self, event):
self.frame2 = windows2(None, -1)
self.frame2.Center()
self.frame2.Show(True)

class windows2 (wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, "参数设置", pos=(0, 0), size=(1040, 700))
panel = wx.Panel(self, -1)][/code]
...全文
211 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
茫然99 2019-04-18
  • 打赏
  • 举报
回复
引用 1 楼 陈年椰子的回复:
模式对话框

import wx

class SubclassDialog(wx.Dialog):
    def __init__(self):
        wx.Dialog.__init__(self, None, -1, 'Dialog Subclass', size=(300, 100))
        okButton = wx.Button(self, wx.ID_OK, "OK", pos=(15, 15))
        okButton.SetDefault()
        cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel", pos=(115, 15))

if __name__ == '__main__':
    app = wx.PySimpleApp()
    dialog = SubclassDialog()
    result = dialog.ShowModal()
    if result == wx.ID_OK:
        print "OK"
    else:
        print "Cancel"
    dialog.Destroy()

谢谢,解决了。真是难者不会,会者不难
陈年椰子 2019-04-18
  • 打赏
  • 举报
回复
模式对话框

import wx

class SubclassDialog(wx.Dialog):
    def __init__(self):
        wx.Dialog.__init__(self, None, -1, 'Dialog Subclass', size=(300, 100))
        okButton = wx.Button(self, wx.ID_OK, "OK", pos=(15, 15))
        okButton.SetDefault()
        cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel", pos=(115, 15))

if __name__ == '__main__':
    app = wx.PySimpleApp()
    dialog = SubclassDialog()
    result = dialog.ShowModal()
    if result == wx.ID_OK:
        print "OK"
    else:
        print "Cancel"
    dialog.Destroy()

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧