为了账号安全,请及时绑定邮箱和手机立即绑定

ShowModal之后,wxPython对话框冻结

ShowModal之后,wxPython对话框冻结

jeck猫 2021-03-10 15:58:41
直接在这里的代码,值得一千个单词来解释它。#!/usr/bin/env python2import wxclass TestDialog(wx.Dialog):    def __init__self(*arg, **args):        wx.Dialog.__init__(self, parent, id, title, size=(350,300))        sizer = self.CreateTextSizer('My Buttons')        # bad()        sizer = wx.BoxSizer(wx.VERTICAL)        sizer.Add(wx.Button(self, -1, 'Button'), 0, wx.ALL, 5)        sizer.Add(wx.Button(self, -1, 'Button'), 0, wx.ALL, 5)        sizer.Add(wx.Button(self, -1, 'Button'), 0, wx.ALL, 5)        sizer.Add(wx.Button(self, -1, 'Button'), 0, wx.ALL|wx.ALIGN_CENTER, 5)        sizer.Add(wx.Button(self, -1, 'Button'), 0, wx.ALL|wx.EXPAND, 5)        sizer.Fit(self)        self.SetSizer(sizer)    def InitUI(self):        pnl = wx.Panel(self)        vbox = wx.BoxSizer(wx.VERTICAL)        btn = wx.Button(pnl, label='Ok')        vbox.Add(btn, 1, flag=wx.LEFT)        pnl.SetSizer(vbox)    def OnClose(self):        self.Destroy()class MyFrame(wx.Frame):    def __init__(self, parent, id, title):        wx.Frame.__init__(self, parent, id, title, size=(550,500))        panel = wx.Panel(self, -1)        wx.Button(panel, 1, 'Show Custom Dialog', (100,100))        self.Bind (wx.EVT_BUTTON, self.OnShowCustomDialog)    def OnShowCustomDialog(self, event):        dia = TestDialog(self, -1, 'buttons')        dia.ShowModal()        # dia.Destroy()if __name__ == "__main__":    try:        app = wx.App()        frame = MyFrame(None, wx.ID_ANY, 'dialog')        frame.Show()        # import wx.lib.inspection        # wx.lib.inspection.InspectionTool().Show()        app.MainLoop()    except:        import sys        import traceback        xc = traceback.format_exception(*sys.exc_info())        wx.MessageBox(''.join(xc))显示了主窗口,但显示对话框后似乎什么也没有执行。即使取消注释,bad()呼叫似乎也不会显示任何内容。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 265 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号