【发布时间】:2014-04-11 09:00:09
【问题描述】:
我正在尝试使用 wxPython 创建一个 GUI。创建 GUI 后,我希望代码继续执行,因此我尝试将 app.MainLoop() 扔到一个新线程上。这给我带来了问题。此外,例如,当我尝试更改背景颜色时,它会冻结 GUI。
导入 wx 导入线程 从线程导入线程 从多处理导入进程
类显示(wx.Frame):
def __init__(self, *args, **kwargs):
print 'here'
self.app = wx.App(False)
super(Display, self).__init__(*args, **kwargs)
self.SetTitle("Yo mama")
self.Show(True)
thread = Thread(target = self.app.MainLoop)
thread.start()
self.Close()
def DisplayGUI(self):
self.SetTitle("MyTitle")
self.Show(True)
def Changetitle(self):
self.SetTitle("Title2")
显示 = 显示(无)
做事
display.ChangeTitle()
做事
所以基本上我希望能够运行一个 GUI,并稍后在我的程序中控制它(而不是通过带有事件的 GUI 本身)。我打算让图片随机显示。
感谢您的帮助。
-布雷登
【问题讨论】:
标签: multithreading user-interface process wxpython