【发布时间】:2013-10-31 09:18:30
【问题描述】:
我用 wxPython 和 cefPython 构建了一个应用程序。现在我正在构建一个更新程序来更新我的软件。
流程如下:
- 应用启动后会调用更新程序
- 更新程序使用 API 检查
- 如果版本低于 API,则下载新的压缩包
- 下载完成后关闭应用程序
- 已关闭,现在应该提取新文件,
- 已解压,现在必须重新打开程序。
我认为问题出现在 第 4 点,因为我认为流程已关闭,因此现在其余步骤不会发生。
如果这是问题,我应该如何做到这一点,以便更新程序(我从主程序导入和调用)也不会关闭。
这里有一些代码:
import updater (updater.py)
class MyApp(wx.App):
timer = None
timerID = 1
def OnInit(self):
if not USE_EVT_IDLE:
print("Using TIMER to execute the CEF message loop work")
self.CreateTimer()
global frame
frame = MainFrame()
self.SetTopWindow(frame)
frame.Show(False)
**thread.start_new_thread(checkForUpdate, ()) --- This is where im calling the update function**
return True
def checkForUpdate():
print("Checking for update: %s" % time.ctime())
updater.callAPI()
threading.Timer(120, checkForUpdate).start()
谢谢
【问题讨论】:
-
一种解决方案是拥有一个外部帮助应用程序,它将再次启动主应用程序。这可能是一个简单的 C/C++ 程序,因此任何依赖项都最小化,因此将来不需要任何更新。
-
嘿,我最终使更新程序成为一个单独的 EXE 文件,然后在 udpate 函数中使用一些参数启动该过程。现在它运行良好.. 现在我只需要在杀死应用程序时从任务栏中删除图标
标签: python python-2.7 wxpython