def OnSync(self, event): dlg = dialogs.SyncDialog(self, self.conf) dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_OK: ret = dlg.value() # self.conf['sync_auto'] = str(ret) if ret != self.conf["sync_way"]: self.conf["sync_way"] = ret self.conf.dump() if ret: sync.synchronization(self) self.reload() dlg.Destroy()
def OnSync(self, event): dlg = dialogs.SyncDialog(self, self.conf) dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_OK: ret = dlg.value() #self.conf['sync_auto'] = str(ret) if ret != self.conf['sync_way']: self.conf['sync_way'] = ret self.conf.dump() if ret: sync.synchronization(self) self.reload() dlg.Destroy()
def OnCloseWindow(self, event): if self.conf['sync_way'] == 'user': busy = wx.BusyInfo(_("One moment please, waiting for commit modification...")) wx.Yield() sync.synchronization(self, onlyci=True) task.taskq.put(None) logfile.info('task thread end') vi = sys.version_info if vi[0] == 2 and vi[1] >= 6: task.server.shutdown() else: task.server.server_close() logfile.info('server thread end') self.Destroy() sys.exit()
def __init__(self, parent, id, title, cf): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(900,600), name=u'YouMoney', style=wx.DEFAULT_FRAME_STYLE) config.cf = cf self.rundir = os.path.dirname(os.path.abspath(sys.argv[0])) self.bmpdir = os.path.join(self.rundir, 'images') icon = wx.EmptyIcon() iconpath = os.path.join(self.bmpdir, 'small.png') icon.CopyFromBitmap(wx.BitmapFromImage(wx.Image(iconpath, wx.BITMAP_TYPE_PNG))) self.SetIcon(icon) self.CenterOnScreen() if config.cf: self.conf = config.cf else: raise ValueError, 'config.cf is None' self.lang2id = {} self.id2lang = {} self.make_menu() self.make_toolbar() self.make_statusbar() self.initdb() self.load() self.book = panels.ContentTab(self) self.book.load_category(self.category) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.book, 1, wx.EXPAND|wx.ALL) self.SetSizer(sizer) self.SetAutoLayout(True) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.Bind(event.EVT_UPDATE_NOTIFY, self.OnUpdateNotify) self.Bind(event.EVT_MYALERT, self.OnMyAlert) self.initcate() self.check_password() # start server th = threading.Thread(target=task.start_server, args=(self,)) th.start() # start check update task.taskq.put({'id':1, 'type':'update', 'frame':self}) # sync if self.conf['sync_way'] == 'user': if sync.synchronization(self): self.reload() wx.CallLater(100, self.notify)