【发布时间】:2009-08-04 19:42:49
【问题描述】:
我有一个作为启动屏幕存在的框架,供用户在主程序启动之前进行选择。在用户做出选择后,我需要将屏幕保持为一种启动屏幕,直到主程序完成加载。
我通过创建一个应用程序并启动一个线程来做到这一点:
class App(wx.App):
'''
Creates the main frame and displays it
Returns true if successful
'''
def OnInit(self):
try:
'''
Initialization
'''
self.newFile = False
self.fileName = ""
self.splashThread = Splash.SplashThread(logging, self)
self.splashThread.start()
#...More to the class
它启动一个框架:
class SplashThread(threading.Thread):
def __init__(self, logger, app):
threading.Thread.__init__(self)
self.logger = logger
self.app = app
def run(self):
frame = Frame(self.logger, self.app)
frame.Show()
app 值是必需的,因为它包含允许主程序在用户做出选择时继续执行的回调。问题是启动屏幕只闪烁一毫秒然后消失,不允许用户进行选择并阻止其余的启动。
有什么想法吗?提前致谢!
【问题讨论】:
标签: python multithreading wxpython