Fixed an issue where the update popup would crash EDMC

This commit is contained in:
Kiel 2020-05-21 19:49:27 +02:00
parent b866bc1752
commit 79c7f98850
2 changed files with 17 additions and 12 deletions

12
SpanshRouter/SpanshRouter.py Executable file → Normal file
View File

@ -116,18 +116,6 @@ class SpanshRouter():
self.jumpcounttxt_lbl.grid_remove()
self.clear_route_btn.grid_remove()
if self.update_available:
update_txt = "New Spansh update available!\n"
update_txt += "If you choose to install it, you will have to restart EDMC for it to take effect.\n\n"
update_txt += self.spansh_updater.changelogs
update_txt += "\n\nInstall?"
install_update = confirmDialog.askyesno("SpanshRouter", update_txt)
if install_update:
confirmDialog.showinfo("SpanshRouter", "The update will be installed as soon as you quit EDMC.")
else:
self.update_available = False
self.update_gui()
return self.frame

17
load.py
View File

@ -2,8 +2,10 @@ import sys
is_py2 = sys.version[0] == '2'
if is_py2:
from SpanshRouter import SpanshRouter
import tkMessageBox as confirmDialog
else:
from SpanshRouter.SpanshRouter import SpanshRouter
import tkinter.messagebox as confirmDialog
def plugin_start3(plugin_dir):
global spansh_router
@ -35,6 +37,21 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
elif entry['event'] == 'FSSDiscoveryScan' and entry['SystemName'] == spansh_router.next_stop:
spansh_router.update_route()
def ask_for_update():
global spansh_router
if spansh_router.update_available:
update_txt = "New Spansh Router update available!\n"
update_txt += "If you choose to install it, you will have to restart EDMC for it to take effect.\n\n"
update_txt += spansh_router.spansh_updater.changelogs
update_txt += "\n\nInstall?"
install_update = confirmDialog.askyesno("SpanshRouter", update_txt)
if install_update:
confirmDialog.showinfo("SpanshRouter", "The update will be installed as soon as you quit EDMC.")
else:
spansh_router.update_available = False
def plugin_app(parent):
global spansh_router
spansh_router.init_gui(parent)
parent.master.after_idle(ask_for_update)