async def mpUpdater(self, mp, queueCmd, queueData): self.updateCmd = queueCmd self.queueData = queueData while self.running: try: result = await queueData.coro_get(timeout=1) if result['st'] == 'noupdate': self.ConnectionStatusBar.SetStatusText(result['version'], 1) sel = configini().get('Version', 'updateChannel', appchannel) queueCmd.put({'act': 'CheckForUpdates', 'arg': sel}) elif result['st'] == 'new': self.ConnectionStatusBar.SetStatusText('Found New Version:%s' % result['version'], 1) self.btnUpdate.Show(True) elif result['st'] == 'Downing': self.btnUpdate.Show(False) self.ConnectionStatusBar.SetStatusText('Downing %s%%' % result['per'], 1) elif result['st'] == 'restart': wx.PostEvent(self, wx.CommandEvent(wx.EVT_MENU.typeId, wx.ID_EXIT)) break elif result['st'] == 'msg': self.ConnectionStatusBar.SetStatusText(result['msg'], 1) except Empty as ex: pass except CancelledError as ex: pass except Exception as ex: print(ex) print(traceback.format_exc()) queueCmd.put('exit') await mp.coro_join() logging.info('mpUpdater Quited .')
def __init__(self, parent, info): title = _("About") + " " + info.Name wx.Dialog.__init__(self, parent, title=title) self.info = info if parent and parent.GetIcon(): self.SetIcon(parent.GetIcon()) image = None # if self.info.Icon: # bitmap = wx.Bitmap(self.info.Icon) # image = wx.StaticBitmap(self, bitmap=bitmap) name = wx.StaticText(self, label="%s %s" % (info.Name, info.Version)) # description = wx.StaticText(self, label=info.Description) # description.Wrap(400) copyright = wx.StaticText(self, label=info.Copyright) # url = HyperLinkCtrl(self, label=info.WebSite[0], URL=info.WebSite[1]) font = name.GetClassDefaultAttributes().font font.SetWeight(wx.FONTWEIGHT_BOLD) font.SetPointSize(18) name.SetFont(font) sel = configini().get('Version', "updateChannel", appchannel) upbox = wx.StaticBox(self, label=_("update channel")) updatechannel = wx.StaticBoxSizer(upbox, wx.HORIZONTAL) beta = wx.RadioButton(self, label=_('beta')) stable = wx.RadioButton(self, label=_('stable')) if sel == 'beta': beta.SetValue(True) else: stable.SetValue(True) self.Bind(wx.EVT_RADIOBUTTON, self.on_channel_beta, beta) self.Bind(wx.EVT_RADIOBUTTON, self.on_channel_stable, stable) updatechannel.Add(beta, flag=wx.GROW | wx.LEFT, border=5) updatechannel.Add(stable, flag=wx.GROW | wx.LEFT, border=5) # credits = wx.Button(self, id=wx.ID_ABOUT, label=_("C&redits")) # license = wx.Button(self, label=_("&License")) close = wx.Button(self, id=wx.ID_CANCEL, label=_("&Close")) btnSizer = wx.BoxSizer(wx.HORIZONTAL) # btnSizer.Add(credits, flag=wx.CENTER | wx.LEFT | wx.RIGHT, border=5) # btnSizer.Add(license, flag=wx.CENTER | wx.RIGHT, border=5) btnSizer.Add(close, flag=wx.CENTER | wx.RIGHT, border=5) sizer = wx.BoxSizer(wx.VERTICAL) if image: sizer.Add(image, flag=wx.CENTER | wx.TOP | wx.BOTTOM, border=5) sizer.Add(name, flag=wx.CENTER | wx.BOTTOM, border=10) # sizer.Add(description, flag=wx.CENTER | wx.BOTTOM, border=10) sizer.Add(copyright, flag=wx.CENTER | wx.BOTTOM, border=10) # sizer.Add(url, flag=wx.CENTER | wx.BOTTOM, border=15) sizer.Add(updatechannel, flag=wx.GROW | wx.LEFT, border=5) sizer.Add(btnSizer, flag=wx.CENTER | wx.BOTTOM, border=5) container = wx.BoxSizer(wx.VERTICAL) container.Add(sizer, flag=wx.ALL, border=10) self.SetSizer(container) self.Layout() self.Fit() self.Centre() self.Show(True) self.SetEscapeId(close.GetId()) # credits.Bind(wx.EVT_BUTTON, self.on_credits) # license.Bind(wx.EVT_BUTTON, self.on_license) close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy())
def on_channel_beta(self, event): configini().put('Version', "updateChannel", "beta")
def on_channel_stable(self, event): configini().put('Version', "updateChannel", "stable")