def select(self, evt): count = get_puzzle_loader().getCount( MODE_STR_MAP[self.curModeID] ) dlg = wx.TextEntryDialog( self, message=_('Please input a ID number : (1~%d)' % count), caption='Select ID' ) if dlg.ShowModal() == wx.ID_OK: v = dlg.GetValue() try: v = int(v) if 0 < v <= count: self.selectId(v) else: raise Exception('Number Error!') except: msg = wx.MessageDialog(None, _('Please input a correctly number!'), _('Information'), style=wx.OK) msg.ShowModal() msg.Destroy() dlg.Destroy()
def selectId(self, _id): self.setDefault( *get_puzzle_loader().pick(MODE_STR_MAP[self.curModeID], _id) )
def new(self, evt): _id, puzzle = get_puzzle_loader().pick(MODE_STR_MAP[self.curModeID]) self.setDefault(_id, puzzle)
mode = util.config.get('APP', 'level', 'easy') user = util.config.get('APP', 'user', '') time = 0 cur_puzzle = [] if app.bRecordLastPuzzle and app.lastPuzzle: _id = app.lastPuzzle['id'] time = app.lastPuzzle['time'] puzzle = util.str2puzzle(app.lastPuzzle['puzzleDefault']) cur_puzzle = util.str2puzzle(app.lastPuzzle['puzzleCurrent']) logger.info('RecordLastPuzzle! id=%d, time=%s', _id, util.time_format(time)) logger.info('puzzle=%s', app.lastPuzzle['puzzleDefault']) logger.info('cur puzzle=%s', app.lastPuzzle['puzzleCurrent']) else: #puzzle loader _id, puzzle = get_puzzle_loader().pick(mode) #anim anim.InitAnimManager() #frame frame = MainFrame(None, 'Sudoku Boxer') frame.setDefault(_id, puzzle, cur_puzzle) if user: frame._setUser(user) if time: frame.setSpendTime(time) mainApp.MainLoop() app.SetConfig()