def SetCardsLeft(self): """ 改变剩余卡片数量的显示 :return: """ dic = file.fetch_statistic(self.fn) self.cl.SetLabel("剩余卡片数: %d %d %d".decode('utf-8') % (len(self.n_list), len(self.s_list), len(self.r_list)))
def SetCardsLeft(self): dic = file.fetch_statistic(self.fn) self.cl.SetLabel("剩余卡片数: %d %d %d" % (len(self.n_list), len(self.s_list), len(self.r_list)))
def __init__(self, lib, i): wx.Dialog.__init__(self, None, -1, 'Study', size=(-1, 470), style=wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX) self.fn = 'recordstack_' + str(i) + '.txt' self.n_list = file.fetch_nsr(self.fn, 'N') self.s_list = file.fetch_nsr(self.fn, 'S') self.r_list = file.fetch_nsr(self.fn, 'R') self.done = [] self.undone = [] self.lib = lib self.i = i self.panel = wx.Panel(self) v_box_main = wx.BoxSizer(wx.VERTICAL) title = wx.StaticText(self.panel, -1, lib[i].encode('utf8')) more = wx.BitmapButton(self.panel, -1, wx.Bitmap('images/other-size/more26.png'), style=wx.NO_BORDER) line_1 = wx.StaticLine(self.panel, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) h_box_title = wx.BoxSizer(wx.HORIZONTAL) h_box_title.Add(title, 1, wx.TOP | wx.RIGHT, 10) h_box_title.Add(more, 0, wx.ALIGN_RIGHT | wx.LEFT | wx.TOP, 5) v_box_main.Add(h_box_title, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10) v_box_main.Add(line_1, 0, wx.EXPAND) # --------------- dic = file.fetch_statistic(self.fn) self.cl = wx.StaticText(self.panel, -1, "剩余卡片数: %d %d %d" % (dic['N'], dic['S'], dic['R'])) h_box_info = wx.BoxSizer(wx.HORIZONTAL) h_box_info.Add(self.cl, 1, wx.RIGHT, 10) v_box_main.Add(h_box_info, 0, wx.EXPAND | wx.ALL, 10) # --------------- panel_qa = wx.Panel(self.panel, -1, style=wx.BORDER_MASK) panel_qa.SetBackgroundColour('white') v_box_qa = wx.BoxSizer(wx.VERTICAL) # 当前显示的卡片的详细信息 self.nrs_list = self.fetch() self.ques = wx.StaticText(panel_qa, -1, self.nrs_list[2].encode('utf-8')) self.ans = wx.StaticText(panel_qa, -1, "") line_2 = wx.StaticLine(panel_qa, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) v_box_qa.Add(self.ques, 0, wx.LEFT | wx.TOP, 20) v_box_qa.Add(line_2, 0, wx.EXPAND | wx.ALL, 10) v_box_qa.Add(self.ans, 0, wx.LEFT, 20) panel_qa.SetSizer(v_box_qa) v_box_main.Add(panel_qa, 18, wx.EXPAND | wx.ALL, 10) # ---------------- self.panel_btn = wx.Panel(self.panel, -1) v_box_btn = wx.BoxSizer(wx.VERTICAL) h_box_btn = wx.BoxSizer(wx.HORIZONTAL) self.show_ans = buttons.GenButton(self.panel_btn, -1, "显示答案") self.show_ans.SetBezelWidth(1) self.show_ans.SetBackgroundColour('white') self.show_ans.Enable() line_3 = wx.StaticLine(self.panel_btn, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) self.again = buttons.GenButton(self.panel_btn, -1, "重来") self.again.SetBezelWidth(1) self.again.SetBackgroundColour('white') self.again.Disable() self.hard = buttons.GenButton(self.panel_btn, -1, "困难") self.hard.SetBezelWidth(1) self.hard.SetBackgroundColour('white') self.hard.Disable() self.good = buttons.GenButton(self.panel_btn, -1, "一般") self.good.SetBezelWidth(1) self.good.SetBackgroundColour('white') self.good.Disable() self.easy = buttons.GenButton(self.panel_btn, -1, "简单") self.easy.SetBezelWidth(1) self.easy.SetBackgroundColour('white') self.easy.Disable() self.show_ans.Bind(wx.EVT_BUTTON, self.OnShowAns) self.again.Bind(wx.EVT_BUTTON, self.OnAgain) self.hard.Bind(wx.EVT_BUTTON, self.OnHard) self.good.Bind(wx.EVT_BUTTON, self.OnGood) self.easy.Bind(wx.EVT_BUTTON, self.OnEasy) h_box_btn.Add(self.again, 1, wx.RIGHT, 5) h_box_btn.Add(self.hard, 1, wx.RIGHT, 5) h_box_btn.Add(self.good, 1, wx.RIGHT, 5) h_box_btn.Add(self.easy, 1, wx.RIGHT, 5) v_box_btn.Add(self.show_ans, 1, wx.EXPAND) v_box_btn.Add(line_3, 1, wx.EXPAND) v_box_btn.Add(h_box_btn, 1, wx.EXPAND) self.panel_btn.SetSizer(v_box_btn) v_box_main.Add(self.panel_btn, 0, wx.EXPAND | wx.ALL, 10) self.panel.SetSizer(v_box_main) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Centre() self.Show(True)
def __init__(self, i, lib): """ 看工作目录下是否存在recordstack_i,如果不存在则创建然后写入前三行: NSR的统计数据(0, 0, 0) 根据设置中每日学习和复习向recordstack_xxx.txt中添加记录信息 不足设置的每日学习和复习的数量则补足(有多少补多少) :param i: 词库id :param lib: :return: """ wx.Dialog.__init__(self, None, -1, '准备学习', size=(-1, 350), style=wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX) # ----------------------------------------- file_name = 'recordstack_' + i + '.txt' if file.is_exist(os.getcwd(), file_name) == 0: f = open(file_name, 'w') f.write('N:0\nS:0\nR:0') f.close() pass file.no_blank(file_name) nsr = file.fetch_statistic(file_name) n_num = nsr['N'] s_num = nsr['S'] r_num = nsr['R'] sql = "SELECT * FROM library WHERE libId = '" + i + "'" result = DBFun.select('db_pymemo.db', sql) r_s = result[0][4] n_s = result[0][5] review_list = file.filter_repeat(file_name, FrameFun.find_expired(i)) new_list = file.filter_repeat(file_name, FrameFun.find_new(i)) file.write_rs(file_name, new_list[:50], 'N') file.write_rs(file_name, review_list[:50], 'R') # ----------------------------------------- v_box = wx.BoxSizer(wx.VERTICAL) # panel_1 panel_1 = wx.Panel(self, -1, style=wx.BORDER_MASK) panel_1.SetBackgroundColour('white') v_box_1 = wx.BoxSizer(wx.VERTICAL) big_font_bold = wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD, False) text_head = wx.StaticText(panel_1, -1, lib[i].decode('utf-8')) text_head.SetFont(big_font_bold) v_box_1.Add(text_head, 0, wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL, 10) if n_num + r_num + s_num > 0: gs = wx.GridSizer(rows=3, cols=2, vgap=5, hgap=25) text_statistic = wx.StaticText(panel_1, -1, "今日到期:") text_new = wx.StaticText(panel_1, -1, "新卡片合计:") text_all = wx.StaticText(panel_1, -1, "全部卡片:") gs.Add(text_statistic, 0, wx.EXPAND) gs.Add(wx.StaticText(panel_1, -1, str(n_num) + ' ' + str(s_num) + ' ' + str(r_num)), 0, wx.EXPAND) gs.Add(text_new, 0, wx.EXPAND) gs.Add(wx.StaticText(panel_1, -1, str(len(new_list)))) gs.Add(text_all, 0, wx.EXPAND) gs.Add(wx.StaticText(panel_1, -1, str(len(FrameFun.find_all(i))))) v_box_1.Add(gs, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.BOTTOM, 10) else: done_text = '''恭喜!你已经完成今天的学习计划。 今天的复习数量限制已经达到,但仍有一些卡片需要复习。 为了更好的记忆效果,你可以考虑调整你的学习计划。 点击下面词库选项,调整学习计划''' tips = wx.StaticText(panel_1, -1, done_text, style=wx.ALIGN_CENTER_HORIZONTAL) v_box_1.Add(tips, 0, wx.EXPAND | wx.ALL, 10) panel_1.SetSizer(v_box_1) v_box.Add(panel_1, 1, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10) # ----------------------------------------- # panel_2 if n_num + r_num + s_num > 0: panel_2 = wx.Panel(self, -1, style=wx.BORDER_MASK) panel_2.SetBackgroundColour('white') h_box_2 = wx.BoxSizer(wx.HORIZONTAL) temp = wx.Image('images/other-size/flashcard48.jpg', wx.BITMAP_TYPE_JPEG).ConvertToBitmap() flashcard = wx.StaticBitmap(panel_2, -1, temp) h_box_2.Add(flashcard, 0, wx.ALL, 10) start = buttons.GenButton(panel_2, -1, '开始学习') start.SetBezelWidth(0) start.SetBackgroundColour('white') start.Bind(wx.EVT_BUTTON, lambda evt, l=lib, index=i: self.on_study(evt, l, index)) h_box_2.Add(start, 1, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 10) panel_2.SetSizer(h_box_2) v_box.Add(panel_2, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10) else: pass line = wx.StaticLine(self, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) v_box.Add(line, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10) setting_button = buttons.GenButton(self, -1, "词库选项") setting_button.SetBezelWidth(1) setting_button.SetBackgroundColour('white') setting_button.Bind(wx.EVT_BUTTON, lambda evt, l=lib, index=i: self.on_setting(evt, lib, i)) v_box.Add(setting_button, 0, wx.EXPAND | wx.ALL, 10) self.SetSizer(v_box) self.Centre() self.Show(True)
def SetCardsLeft(self): dic = file.fetch_statistic(self.fn) self.cl.SetLabel( "剩余卡片数: %d %d %d" % (len(self.n_list), len(self.s_list), len(self.r_list)))
def __init__(self, lib, i): wx.Dialog.__init__(self, None, -1, 'Study', size=(-1, 470), style=wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX) self.fn = 'recordstack_' + str(i) + '.txt' self.n_list = file.fetch_nsr(self.fn, 'N') self.s_list = file.fetch_nsr(self.fn, 'S') self.r_list = file.fetch_nsr(self.fn, 'R') self.done = [] self.undone = [] self.lib = lib self.i = i self.panel = wx.Panel(self) v_box_main = wx.BoxSizer(wx.VERTICAL) title = wx.StaticText(self.panel, -1, lib[i].encode('utf8')) more = wx.BitmapButton(self.panel, -1, wx.Bitmap('images/other-size/more26.png'), style=wx.NO_BORDER) line_1 = wx.StaticLine(self.panel, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) h_box_title = wx.BoxSizer(wx.HORIZONTAL) h_box_title.Add(title, 1, wx.TOP | wx.RIGHT, 10) h_box_title.Add(more, 0, wx.ALIGN_RIGHT | wx.LEFT | wx.TOP, 5) v_box_main.Add(h_box_title, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10) v_box_main.Add(line_1, 0, wx.EXPAND) # --------------- dic = file.fetch_statistic(self.fn) self.cl = wx.StaticText( self.panel, -1, "剩余卡片数: %d %d %d" % (dic['N'], dic['S'], dic['R'])) h_box_info = wx.BoxSizer(wx.HORIZONTAL) h_box_info.Add(self.cl, 1, wx.RIGHT, 10) v_box_main.Add(h_box_info, 0, wx.EXPAND | wx.ALL, 10) # --------------- panel_qa = wx.Panel(self.panel, -1, style=wx.BORDER_MASK) panel_qa.SetBackgroundColour('white') v_box_qa = wx.BoxSizer(wx.VERTICAL) # 当前显示的卡片的详细信息 self.nrs_list = self.fetch() self.ques = wx.StaticText(panel_qa, -1, self.nrs_list[2].encode('utf-8')) self.ans = wx.StaticText(panel_qa, -1, "") line_2 = wx.StaticLine(panel_qa, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) v_box_qa.Add(self.ques, 0, wx.LEFT | wx.TOP, 20) v_box_qa.Add(line_2, 0, wx.EXPAND | wx.ALL, 10) v_box_qa.Add(self.ans, 0, wx.LEFT, 20) panel_qa.SetSizer(v_box_qa) v_box_main.Add(panel_qa, 18, wx.EXPAND | wx.ALL, 10) # ---------------- self.panel_btn = wx.Panel(self.panel, -1) v_box_btn = wx.BoxSizer(wx.VERTICAL) h_box_btn = wx.BoxSizer(wx.HORIZONTAL) self.show_ans = buttons.GenButton(self.panel_btn, -1, "显示答案") self.show_ans.SetBezelWidth(1) self.show_ans.SetBackgroundColour('white') self.show_ans.Enable() line_3 = wx.StaticLine(self.panel_btn, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) self.again = buttons.GenButton(self.panel_btn, -1, "重来") self.again.SetBezelWidth(1) self.again.SetBackgroundColour('white') self.again.Disable() self.hard = buttons.GenButton(self.panel_btn, -1, "困难") self.hard.SetBezelWidth(1) self.hard.SetBackgroundColour('white') self.hard.Disable() self.good = buttons.GenButton(self.panel_btn, -1, "一般") self.good.SetBezelWidth(1) self.good.SetBackgroundColour('white') self.good.Disable() self.easy = buttons.GenButton(self.panel_btn, -1, "简单") self.easy.SetBezelWidth(1) self.easy.SetBackgroundColour('white') self.easy.Disable() self.show_ans.Bind(wx.EVT_BUTTON, self.OnShowAns) self.again.Bind(wx.EVT_BUTTON, self.OnAgain) self.hard.Bind(wx.EVT_BUTTON, self.OnHard) self.good.Bind(wx.EVT_BUTTON, self.OnGood) self.easy.Bind(wx.EVT_BUTTON, self.OnEasy) h_box_btn.Add(self.again, 1, wx.RIGHT, 5) h_box_btn.Add(self.hard, 1, wx.RIGHT, 5) h_box_btn.Add(self.good, 1, wx.RIGHT, 5) h_box_btn.Add(self.easy, 1, wx.RIGHT, 5) v_box_btn.Add(self.show_ans, 1, wx.EXPAND) v_box_btn.Add(line_3, 1, wx.EXPAND) v_box_btn.Add(h_box_btn, 1, wx.EXPAND) self.panel_btn.SetSizer(v_box_btn) v_box_main.Add(self.panel_btn, 0, wx.EXPAND | wx.ALL, 10) self.panel.SetSizer(v_box_main) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Centre() self.Show(True)
def __init__(self, i, lib): """ 看工作目录下是否存在recordstack_i,如果不存在则创建然后写入前三行: NSR的统计数据(0, 0, 0) 根据设置中每日学习和复习向recordstack_xxx.txt中添加记录信息 不足设置的每日学习和复习的数量则补足(有多少补多少) :param i: 词库id :param lib: :return: """ wx.Dialog.__init__(self, None, -1, '准备学习', size=(-1, 350), style=wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX) # ----------------------------------------- file_name = 'recordstack_' + i + '.txt' if file.is_exist(os.getcwd(), file_name) == 0: f = open(file_name, 'w') f.write('N:0\nS:0\nR:0') f.close() pass file.no_blank(file_name) nsr = file.fetch_statistic(file_name) n_num = nsr['N'] s_num = nsr['S'] r_num = nsr['R'] sql = "SELECT * FROM library WHERE libId = '" + i + "'" result = DBFun.select('db_pymemo.db', sql) r_s = result[0][4] n_s = result[0][5] review_list = file.filter_repeat(file_name, FrameFun.find_expired(i)) new_list = file.filter_repeat(file_name, FrameFun.find_new(i)) file.write_rs(file_name, new_list[:50], 'N') file.write_rs(file_name, review_list[:50], 'R') # ----------------------------------------- v_box = wx.BoxSizer(wx.VERTICAL) # panel_1 panel_1 = wx.Panel(self, -1, style=wx.BORDER_MASK) panel_1.SetBackgroundColour('white') v_box_1 = wx.BoxSizer(wx.VERTICAL) big_font_bold = wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD, False) text_head = wx.StaticText(panel_1, -1, lib[i].decode('utf-8')) text_head.SetFont(big_font_bold) v_box_1.Add(text_head, 0, wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL, 10) if n_num + r_num + s_num > 0: gs = wx.GridSizer(rows=3, cols=2, vgap=5, hgap=25) text_statistic = wx.StaticText(panel_1, -1, "今日到期:") text_new = wx.StaticText(panel_1, -1, "新卡片合计:") text_all = wx.StaticText(panel_1, -1, "全部卡片:") gs.Add(text_statistic, 0, wx.EXPAND) gs.Add( wx.StaticText(panel_1, -1, str(n_num) + ' ' + str(s_num) + ' ' + str(r_num)), 0, wx.EXPAND) gs.Add(text_new, 0, wx.EXPAND) gs.Add(wx.StaticText(panel_1, -1, str(len(new_list)))) gs.Add(text_all, 0, wx.EXPAND) gs.Add(wx.StaticText(panel_1, -1, str(len(FrameFun.find_all(i))))) v_box_1.Add(gs, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.BOTTOM, 10) else: done_text = '''恭喜!你已经完成今天的学习计划。 今天的复习数量限制已经达到,但仍有一些卡片需要复习。 为了更好的记忆效果,你可以考虑调整你的学习计划。 点击下面词库选项,调整学习计划''' tips = wx.StaticText(panel_1, -1, done_text, style=wx.ALIGN_CENTER_HORIZONTAL) v_box_1.Add(tips, 0, wx.EXPAND | wx.ALL, 10) panel_1.SetSizer(v_box_1) v_box.Add(panel_1, 1, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10) # ----------------------------------------- # panel_2 if n_num + r_num + s_num > 0: panel_2 = wx.Panel(self, -1, style=wx.BORDER_MASK) panel_2.SetBackgroundColour('white') h_box_2 = wx.BoxSizer(wx.HORIZONTAL) temp = wx.Image('images/other-size/flashcard48.jpg', wx.BITMAP_TYPE_JPEG).ConvertToBitmap() flashcard = wx.StaticBitmap(panel_2, -1, temp) h_box_2.Add(flashcard, 0, wx.ALL, 10) start = buttons.GenButton(panel_2, -1, '开始学习') start.SetBezelWidth(0) start.SetBackgroundColour('white') start.Bind( wx.EVT_BUTTON, lambda evt, l=lib, index=i: self.on_study(evt, l, index)) h_box_2.Add(start, 1, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 10) panel_2.SetSizer(h_box_2) v_box.Add(panel_2, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10) else: pass line = wx.StaticLine(self, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) v_box.Add(line, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10) setting_button = buttons.GenButton(self, -1, "词库选项") setting_button.SetBezelWidth(1) setting_button.SetBackgroundColour('white') setting_button.Bind( wx.EVT_BUTTON, lambda evt, l=lib, index=i: self.on_setting(evt, lib, i)) v_box.Add(setting_button, 0, wx.EXPAND | wx.ALL, 10) self.SetSizer(v_box) self.Centre() self.Show(True)