Ejemplo n.º 1
0
def find_remembered():
    """
    找到已经记住的记录并返回
    :return:
    """
    sql = "SELECT * FROM record WHERE EF>=3.0"
    remembered_list = DBFun.select('db_pymemo.db', sql)
    return remembered_list
Ejemplo n.º 2
0
 def fetch_lib():
     select_sql = "SELECT * FROM library"
     result_list = DBFun.select('db_pymemo.db', select_sql)
     LIBRARIES.clear()
     LIBRARY_ID[:] = []
     for rows in result_list:
         LIBRARY_ID.append(rows[0])
         LIBRARIES[rows[0]] = rows[1]
Ejemplo n.º 3
0
def find_hard():
    """
    找到始终记不住的记录并返回
    :return:
    """
    sql = "SELECT * FROM record WHERE EF=1.3"
    hard_list = DBFun.select('db_pymemo.db', sql)
    return hard_list
Ejemplo n.º 4
0
def find_remembered():
    """
    找到已经记住的记录并返回
    :return:
    """
    sql = "SELECT * FROM record WHERE EF>=3.0"
    remembered_list = DBFun.select('db_pymemo.db', sql)
    return remembered_list
Ejemplo n.º 5
0
def find_hard():
    """
    找到始终记不住的记录并返回
    :return:
    """
    sql = "SELECT * FROM record WHERE EF=1.3"
    hard_list = DBFun.select('db_pymemo.db', sql)
    return hard_list
Ejemplo n.º 6
0
def find_learned():
    """
    找到已经记住的单词卡片并返回
    :return:
    """
    today = datetime.date.today().strftime('%Y/%m/%d')
    sql = "SELECT * FROM record WHERE reviewTime == '" + today + "'"
    learned_record = DBFun.select('db_pymemo.db', sql)
    return learned_record
Ejemplo n.º 7
0
def find_learned():
    """
    找到已经记住的单词卡片并返回
    :return:
    """
    today = datetime.date.today().strftime('%Y/%m/%d')
    sql = "SELECT * FROM record WHERE reviewTime == '" + today + "'"
    learned_record = DBFun.select('db_pymemo.db', sql)
    return learned_record
Ejemplo n.º 8
0
 def on_refresh():
     """
     在单词卡片信息修改之后,刷新右侧列表的显示。
     调用load_data_right(RECORDS)
     :return:
     """
     window = wx.FindWindowByName('ListControlOnRight', parent=None)
     select_sql = "SELECT * FROM record"
     RECORDS = DBFun.select('db_pymemo.db', select_sql)
     window.load_data_right(RECORDS)
Ejemplo n.º 9
0
def find_new(flag):
    """
    找到新单词卡片并返回
    :return:
    """
    if flag == -1:
        sql = "SELECT * FROM record WHERE  interval = -1"
    else:
        sql = "SELECT * FROM record WHERE interval = -1 AND recordId LIKE '%" + flag + "'"
    return DBFun.select('db_pymemo.db', sql)
Ejemplo n.º 10
0
 def on_refresh():
     """
     在单词卡片信息修改之后,刷新右侧列表的显示。
     调用load_data_right(RECORDS)
     :return:
     """
     window = wx.FindWindowByName('ListControlOnRight', parent=None)
     select_sql = "SELECT * FROM record"
     RECORDS = DBFun.select('db_pymemo.db', select_sql)
     window.load_data_right(RECORDS)
Ejemplo n.º 11
0
def find_new(flag):
    """
    找到新记录并返回
    :return:
    """
    if flag == -1:
        sql = "SELECT * FROM record WHERE  interval = -1"
    else:
        sql = "SELECT * FROM record WHERE interval = -1 AND recordId LIKE '%" + flag + "'"
    return DBFun.select('db_pymemo.db', sql)
Ejemplo n.º 12
0
 def on_lib_select(evt):
     index = evt.GetIndex()
     sql = "SELECT * FROM record WHERE recordId LIKE '%" + LIBRARY_ID[index] + "'"
     cursor = DBFun.select('db_pymemo.db', sql)
     r = []
     for rows in cursor:
         r.append(rows)
     RECORDS = r
     window = wx.FindWindowByName('ListControlOnRight', parent=None)
     window.load_data_right(RECORDS)
Ejemplo n.º 13
0
def find_all(flag):
    """
    获取record表中的所有单词记录,并返回结果集
    :param flag:
    :return:
    """
    if flag == -1:
        sql = "SELECT * FROM record"
    else:
        sql = "SELECT * FROM record WHERE recordId LIKE '%" + flag + "'"
    return DBFun.select('db_pymemo.db', sql)
Ejemplo n.º 14
0
def find_all(flag):
    """
    获取record表中的所有单词记录,并返回结果集
    :param flag:
    :return:
    """
    if flag == -1:
        sql = "SELECT * FROM record"
    else:
        sql = "SELECT * FROM record WHERE recordId LIKE '%" + flag + "'"
    return DBFun.select('db_pymemo.db', sql)
Ejemplo n.º 15
0
 def fetch_lib():
     """
     获取词库,并初始化全局变量LIBRARIES(字典)和LIBRARY_ID(列表)
     :return:
     """
     select_sql = "SELECT * FROM library"
     result_list = DBFun.select('db_pymemo.db', select_sql)
     LIBRARIES.clear()
     LIBRARY_ID[:] = []
     for rows in result_list:
         LIBRARY_ID.append(rows[0])
         LIBRARIES[rows[0]] = rows[1]
Ejemplo n.º 16
0
 def on_lib_rename(evt, i):
     lib_desc = ''
     lib_id = LIBRARY_ID[i]
     lib_name = LIBRARIES[LIBRARY_ID[i]].decode('utf-8')
     select_sql = "SELECT * FROM library WHERE libId = '" + lib_id + "'"
     cursor = DBFun.select('db_pymemo.db', select_sql)
     for rows in cursor:
         lib_desc = rows[2].decode('utf-8')
     rename_dlg = Dialog.RenameLib(lib_name, lib_desc, lib_id)
     rename_dlg.ShowModal()
     rename_dlg.Destroy()
     pass
Ejemplo n.º 17
0
 def __init__(self, parent, i):
     """
     继承wx.ListCtrl,并载入单词卡片
     :param parent:
     :param i:
     :return:
     """
     wx.ListCtrl.__init__(self, parent, i, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_SINGLE_SEL)
     self.parent = parent
     select_sql = 'SELECT * FROM record'
     RECORDS = DBFun.select('db_pymemo.db', select_sql)
     self.load_data_right(RECORDS)
Ejemplo n.º 18
0
 def fetch_lib():
     """
     获取词库,并初始化全局变量LIBRARIES(字典)和LIBRARY_ID(列表)
     :return:
     """
     select_sql = "SELECT * FROM library"
     result_list = DBFun.select('db_pymemo.db', select_sql)
     LIBRARIES.clear()
     LIBRARY_ID[:] = []
     for rows in result_list:
         LIBRARY_ID.append(rows[0])
         LIBRARIES[rows[0]] = rows[1]
Ejemplo n.º 19
0
    def on_item_info(evt, i):
        lib_info = ()
        lib_id = LIBRARY_ID[i]
        lib_name = LIBRARIES[LIBRARY_ID[i]].decode('utf-8')

        select_sql = "SELECT * FROM library WHERE libId = '" + lib_id + "'"
        cursor = DBFun.select('db_pymemo.db', select_sql)
        for rows in cursor:
            lib_info = rows

        info_dlg = Dialog.LibInfo(lib_info)
        info_dlg.ShowModal()
        info_dlg.Destroy()
        pass
Ejemplo n.º 20
0
def find_today():
    """
    找到今天添加的记录并返回
    :return:
    """
    today_record = []
    sql = "SELECT * FROM record WHERE interval = -1"
    for rows in DBFun.select('db_pymemo.db', sql):
        add_date = rows[3]
        add_time = time.mktime(time.strptime(str(add_date), '%Y/%m/%d'))
        now_time = time.mktime(time.strptime(str(datetime.date.today()), '%Y-%m-%d'))
        if add_time == now_time:
            today_record.append(rows)
    return today_record
Ejemplo n.º 21
0
def find_today():
    """
    找到今天添加的记录并返回
    :return:
    """
    today_record = []
    sql = "SELECT * FROM record WHERE interval = -1"
    for rows in DBFun.select('db_pymemo.db', sql):
        add_date = rows[3]
        add_time = time.mktime(time.strptime(str(add_date), '%Y/%m/%d'))
        now_time = time.mktime(
            time.strptime(str(datetime.date.today()), '%Y-%m-%d'))
        if add_time == now_time:
            today_record.append(rows)
    return today_record
Ejemplo n.º 22
0
 def __init__(self, parent, i):
     """
     继承wx.ListCtrl,并载入单词卡片
     :param parent:
     :param i:
     :return:
     """
     wx.ListCtrl.__init__(self,
                          parent,
                          i,
                          style=wx.LC_REPORT | wx.LC_HRULES
                          | wx.LC_SINGLE_SEL)
     self.parent = parent
     select_sql = 'SELECT * FROM record'
     RECORDS = DBFun.select('db_pymemo.db', select_sql)
     self.load_data_right(RECORDS)
Ejemplo n.º 23
0
 def on_lib_select(evt):
     """
     定义选择某词库事件,调用load_data_right(RECORDS),刷新右侧单词卡片的显示。
     刷新后显示当前选择的词库中的单词卡片。
     :param evt:
     :return:
     """
     index = evt.GetIndex()
     sql = "SELECT * FROM record WHERE recordId LIKE '%" + LIBRARY_ID[index] + "'"
     cursor = DBFun.select('db_pymemo.db', sql)
     r = []
     for rows in cursor:
         r.append(rows)
     RECORDS = r
     window = wx.FindWindowByName('ListControlOnRight', parent=None)
     window.load_data_right(RECORDS)
Ejemplo n.º 24
0
 def on_lib_select(evt):
     """
     定义选择某词库事件,调用load_data_right(RECORDS),刷新右侧单词卡片的显示。
     刷新后显示当前选择的词库中的单词卡片。
     :param evt:
     :return:
     """
     index = evt.GetIndex()
     sql = "SELECT * FROM record WHERE recordId LIKE '%" + LIBRARY_ID[
         index] + "'"
     cursor = DBFun.select('db_pymemo.db', sql)
     r = []
     for rows in cursor:
         r.append(rows)
     RECORDS = r
     window = wx.FindWindowByName('ListControlOnRight', parent=None)
     window.load_data_right(RECORDS)
Ejemplo n.º 25
0
 def on_lib_rename(evt, i):
     """
     修改词库的名称和描述。
     传递当前的词库名称和描述给Dialog.RenameLib,初始化修改词库名称和描述的对话框。
     :param evt:
     :param i: 选中词库在LIBRARIES字典中的编号
     :return:
     """
     lib_desc = ''
     lib_id = LIBRARY_ID[i]
     lib_name = LIBRARIES[LIBRARY_ID[i]].decode('utf-8')
     select_sql = "SELECT * FROM library WHERE libId = '" + lib_id + "'"
     cursor = DBFun.select('db_pymemo.db', select_sql)
     for rows in cursor:
         lib_desc = rows[2].decode('utf-8')
     rename_dlg = Dialog.RenameLib(lib_name, lib_desc, lib_id)
     rename_dlg.ShowModal()
     rename_dlg.Destroy()
     pass
Ejemplo n.º 26
0
 def on_lib_rename(evt, i):
     """
     修改词库的名称和描述。
     传递当前的词库名称和描述给Dialog.RenameLib,初始化修改词库名称和描述的对话框。
     :param evt:
     :param i: 选中词库在LIBRARIES字典中的编号
     :return:
     """
     lib_desc = ''
     lib_id = LIBRARY_ID[i]
     lib_name = LIBRARIES[LIBRARY_ID[i]].decode('utf-8')
     select_sql = "SELECT * FROM library WHERE libId = '" + lib_id + "'"
     cursor = DBFun.select('db_pymemo.db', select_sql)
     for rows in cursor:
         lib_desc = rows[2].decode('utf-8')
     rename_dlg = Dialog.RenameLib(lib_name, lib_desc, lib_id)
     rename_dlg.ShowModal()
     rename_dlg.Destroy()
     pass
Ejemplo n.º 27
0
    def on_item_info(evt, i):
        """
        查看词库的详细信息。
        传递当前的词库信息lib_info(元组)给Dialog.LibInfo(lib_info),初始化词库信息对话框。
        :param evt:
        :param i: 选中词库在LIBRARIES字典中的编号
        :return:
        """
        lib_info = ()
        lib_id = LIBRARY_ID[i]
        lib_name = LIBRARIES[LIBRARY_ID[i]].decode('utf-8')

        select_sql = "SELECT * FROM library WHERE libId = '" + lib_id + "'"
        cursor = DBFun.select('db_pymemo.db', select_sql)
        for rows in cursor:
            lib_info = rows

        info_dlg = Dialog.LibInfo(lib_info)
        info_dlg.ShowModal()
        info_dlg.Destroy()
        pass
Ejemplo n.º 28
0
    def on_item_info(evt, i):
        """
        查看词库的详细信息。
        传递当前的词库信息lib_info(元组)给Dialog.LibInfo(lib_info),初始化词库信息对话框。
        :param evt:
        :param i: 选中词库在LIBRARIES字典中的编号
        :return:
        """
        lib_info = ()
        lib_id = LIBRARY_ID[i]
        lib_name = LIBRARIES[LIBRARY_ID[i]].decode('utf-8')

        select_sql = "SELECT * FROM library WHERE libId = '" + lib_id + "'"
        cursor = DBFun.select('db_pymemo.db', select_sql)
        for rows in cursor:
            lib_info = rows

        info_dlg = Dialog.LibInfo(lib_info)
        info_dlg.ShowModal()
        info_dlg.Destroy()
        pass
Ejemplo n.º 29
0
def find_expired(flag):
    """
    找到已经到期的记录并返回
    :return:
    """
    expired_list = []
    if flag == -1:
        sql = "SELECT * FROM record WHERE interval != -1"
    else:
        sql = "SELECT * FROM record WHERE interval != -1 AND recordId LIKE '%" + flag + "'"
    today = datetime.date.today()
    for rows in DBFun.select('db_pymemo.db', sql):
        interval = rows[6]
        review_time = rows[4]
        # 下次应该复习时间
        review_time_date = datetime.datetime.strptime(review_time, '%Y/%m/%d').date()
        a_time_date = review_time_date + datetime.timedelta(days=interval)
        # 比较秒数
        a_time = time.mktime(time.strptime(str(a_time_date), '%Y-%m-%d'))
        b_time = time.mktime(time.strptime(str(today), '%Y-%m-%d'))
        if b_time >= a_time:
            expired_list.append(rows)
    return expired_list
Ejemplo n.º 30
0
def find_expired(flag):
    """
    找到已经到期的记录并返回
    :return:
    """
    expired_list = []
    if flag == -1:
        sql = "SELECT * FROM record WHERE interval != -1"
    else:
        sql = "SELECT * FROM record WHERE interval != -1 AND recordId LIKE '%" + flag + "'"
    today = datetime.date.today()
    for rows in DBFun.select('db_pymemo.db', sql):
        interval = rows[6]
        review_time = rows[4]
        # 下次应该复习时间
        review_time_date = datetime.datetime.strptime(review_time,
                                                      '%Y/%m/%d').date()
        a_time_date = review_time_date + datetime.timedelta(days=interval)
        # 比较秒数
        a_time = time.mktime(time.strptime(str(a_time_date), '%Y-%m-%d'))
        b_time = time.mktime(time.strptime(str(today), '%Y-%m-%d'))
        if b_time >= a_time:
            expired_list.append(rows)
    return expired_list
Ejemplo n.º 31
0
def find_all(flag):
    if flag == -1:
        sql = "SELECT * FROM record"
    else:
        sql = "SELECT * FROM record WHERE recordId LIKE '%" + flag + "'"
    return DBFun.select('db_pymemo.db', sql)
Ejemplo n.º 32
0
 def on_refresh():
     window = wx.FindWindowByName('ListControlOnRight', parent=None)
     select_sql = "SELECT * FROM record"
     RECORDS = DBFun.select('db_pymemo.db', select_sql)
     window.load_data_right(RECORDS)
Ejemplo n.º 33
0
def find_all(flag):
    if flag == -1:
        sql = "SELECT * FROM record"
    else:
        sql = "SELECT * FROM record WHERE recordId LIKE '%" + flag + "'"
    return DBFun.select('db_pymemo.db', sql)