浏览代码

feat: 更新db程序

SongZihuan 3 年之前
父节点
当前提交
73573a1dfc
共有 3 个文件被更改,包括 79 次插入553 次删除
  1. 79 122
      db.py
  2. 0 121
      tktool.py
  3. 0 310
      ui.py

+ 79 - 122
db.py

@@ -1,11 +1,8 @@
 import sqlite3
 import sqlite3
-import threading
 from typing import Optional, Union, List, Tuple, Dict
 from typing import Optional, Union, List, Tuple, Dict
 import traceback
 import traceback
 
 
 import pandas
 import pandas
-import pandas as pd
-
 import word
 import word
 import re
 import re
 
 
@@ -134,38 +131,33 @@ class WordDatabase(DataBase):
         )''')
         )''')
         self.wd = word.WordDict()
         self.wd = word.WordDict()
 
 
-    def find_word(self, q: str) -> Optional[word.Word]:
-        res = self.search(columns=["id", "word", "part", "english", "chinese", "eg"],
-                          table="Word",
-                          where=f"LOWER(word)='{q.lower()}'")
-        if res is None:
-            res = []
-
-        if len(res) <= 0:
-            r = self.wd.get_requests(q)
-            if not r.is_find:
-                return None
-            ret = None
-            for i in r.res:
-                w = r.res[i]
-                if ret is None:
-                    ret = w
-                name = w.name
-                name_lower = name.lower().replace("'", "''")
-                res = self.search(columns=["word"], table="Word", where=f"LOWER(word)='{name_lower}'")
-                if res is not None and len(res) > 0:
-                    continue
-                for c in w.comment:
-                    comment = r.res[i].comment[c]
-                    eg = '@@'.join(comment.eg).replace("'", "''")
-                    part = comment.part.replace("'", "''")
-                    english = comment.english.replace("'", "''")
-                    chinese = comment.chinese.replace("'", "''")
-                    self.insert(table='Word',
-                                columns=['word', 'part', 'english', 'chinese', 'eg'],
-                                values=f"'{name_lower}', '{part}', '{english}', '{chinese}', '{eg} '")
-            return ret
+    def __add_word(self, q: str):
+        r = self.wd.get_requests(q)
+        if not r.is_find:
+            return None
+        ret = None
+        for i in r.res:
+            w = r.res[i]
+            if ret is None:
+                ret = w
+            name = w.name
+            name_lower = name.lower().replace("'", "''")
+            res = self.search(columns=["word"], table="Word", where=f"LOWER(word)='{name_lower}'")
+            if res is not None and len(res) > 0:
+                continue
+            for c in w.comment:
+                comment = r.res[i].comment[c]
+                eg = '@@'.join(comment.eg).replace("'", "''")
+                part = comment.part.replace("'", "''")
+                english = comment.english.replace("'", "''")
+                chinese = comment.chinese.replace("'", "''")
+                self.insert(table='Word',
+                            columns=['word', 'part', 'english', 'chinese', 'eg'],
+                            values=f"'{name_lower}', '{part}', '{english}', '{chinese}', '{eg} '")
+        return ret
 
 
+    @staticmethod
+    def __make_word(q: str, res: list):
         w = word.Word(q)
         w = word.Word(q)
         for i in res:
         for i in res:
             c = word.Word.Comment(i[2], i[3], i[4])
             c = word.Word.Comment(i[2], i[3], i[4])
@@ -174,11 +166,15 @@ class WordDatabase(DataBase):
             w.add_comment(c)
             w.add_comment(c)
         return w
         return w
 
 
-    def delete_word(self, q: str):
-        self.delete(table="Word", where=f"LOWER(word)='{q.lower()}'")
-
-    def delete_all(self):
-        self.delete(table="Word")
+    def find_word(self, q: str) -> Optional[word.Word]:
+        res = self.search(columns=["id", "word", "part", "english", "chinese", "eg"],
+                          table="Word",
+                          where=f"LOWER(word)='{q.lower()}'")
+        if res is None:
+            res = []
+        if len(res) <= 0:
+            return self.__add_word(q)
+        return self.__make_word(q, res)
 
 
     class UpdateResponse:
     class UpdateResponse:
         def __init__(self):
         def __init__(self):
@@ -192,116 +188,77 @@ class WordDatabase(DataBase):
         def add_error(self, q: str):
         def add_error(self, q: str):
             self._error += 1
             self._error += 1
             self._error_list.append(q)
             self._error_list.append(q)
-            print(f"Error: {q}")
 
 
         def response(self):
         def response(self):
             return self._success, self._error, self._error_list
             return self._success, self._error, self._error_list
 
 
-    def update_from_txt(self, file: str):
+    def import_txt(self, line: str):
         response = self.UpdateResponse()
         response = self.UpdateResponse()
-        with open(file, encoding='utf-8') as f:
-            for i in f.readlines():
-                word_list = self.word_pattern.findall(i)
-                for w in word_list:
-                    try:
-                        if self.find_word(w) is None:
-                            response.add_error(w)
-                        else:
-                            response.add_success()
-                    except:
-                        response.add_error(w)
-                        traceback.print_exc()
-        return True, response
-
-    def update_from_table(self, file: str, t: str = 'csv'):
-        if t == 'txt':
-            return self.update_from_txt(file)
-        elif t == 'csv':
-            df = pd.read_csv(file, encoding='utf-8', header=None)
-        elif t == 'excel':
-            df = pd.read_excel(file, encoding='utf-8', header=None)
-        elif t == 'json':
-            df = pd.read_json(file, encoding='utf-8')
-        else:
-            return False, []
-
-        print(df)
-        response = self.UpdateResponse()
-        for i in df.itertuples():
-            print(i[1])  # i[0]是序号
+        word_list = self.word_pattern.findall(line)
+        for w in word_list:
             try:
             try:
-                if self.find_word(str(i[1])) is None:
-                    response.add_error(str(i[1]))
+                if self.find_word(w) is None:
+                    response.add_error(w)
                 else:
                 else:
                     response.add_success()
                     response.add_success()
-            except:
-                response.add_error(str(i[1]))
+            except Exception as e:
+                response.add_error(w)
                 traceback.print_exc()
                 traceback.print_exc()
         return True, response
         return True, response
 
 
-    def export_as_txt(self, file: str):
-        res = self.search(columns=["word"],
-                          table="Word",
-                          order_by=[('box', 'DESC')])
-        if res is None:
-            return False
-        export = []
-        with open(file + '.txt', encoding='utf-8', mode="w") as f:
-            for i in res:
-                if i[0] in export:
-                    continue
-                f.write(i[0] + '\n')
-                export.append(i[0])
-        return True
-
-    def export_as_table(self, file: str, t: str = 'excel', max_eg: int = 3):
-        if t == 'txt':
-            return self.export_as_txt(file)
+    @staticmethod
+    def eg_to_str(eg_filed: str, max_eg: int):
+        eg = eg_filed.split("@@")
+        eg_str = ""
+        count_eg = 0
+        for e in eg:
+            count_eg += 1
+            if max_eg != -1 and count_eg > max_eg:
+                break
+
+            ec = e.split("##")
+            if len(ec) == 2:
+                eng, chi = ec
+            else:
+                eng = ec[0]
+                chi = ""
+            if len(eng.replace(" ", "")) == 0:
+                continue
+            eg_str += f"{eng} ({chi})\n"
+        return eg_str
 
 
+    def export_frame(self, max_eg: int = 3) -> Optional[pandas.DataFrame]:
         res = self.search(columns=["box", "word", "part", "english", "chinese", "eg"],
         res = self.search(columns=["box", "word", "part", "english", "chinese", "eg"],
                           table="Word",
                           table="Word",
                           order_by=[('box', 'DESC')])
                           order_by=[('box', 'DESC')])
         if res is None:
         if res is None:
-            return False
+            return None
+
         df = pandas.DataFrame(columns=["Box", "Word", "Part", "English", "Chinese", "Eg"])
         df = pandas.DataFrame(columns=["Box", "Word", "Part", "English", "Chinese", "Eg"])
         export = []
         export = []
+
         for i in res:
         for i in res:
             if i[1] in export:
             if i[1] in export:
                 continue
                 continue
             export.append(i[1])
             export.append(i[1])
-            eg = i[5].split("@@")
-            eg_str = ""
-            count_eg = 0
-            for e in eg:
-                count_eg += 1
-                if max_eg != -1 and count_eg > max_eg:
-                    break
-
-                ec = e.split("##")
-                if len(ec) == 2:
-                    eng, chi = ec
-                else:
-                    eng = ec[0]
-                    chi = ""
-                if len(eng.replace(" ", "")) == 0:
-                    continue
-                eg_str += f"{eng} ({chi})\n"
+            eg_str = self.eg_to_str(i[5], max_eg)
             df = df.append({"Box": str(i[0]),
             df = df.append({"Box": str(i[0]),
                             "Word": str(i[1]),
                             "Word": str(i[1]),
                             "Part": str(i[2]),
                             "Part": str(i[2]),
                             "English": str(i[3]),
                             "English": str(i[3]),
                             "Chinese": str(i[4]),
                             "Chinese": str(i[4]),
                             "Eg": eg_str}, ignore_index=True)
                             "Eg": eg_str}, ignore_index=True)
-        if t == 'csv':
-            df.to_csv(file + ".csv", encoding='utf-8')
-        elif t == 'excel':
-            df.to_excel(file + ".xlsx", encoding='utf-8')
-        elif t == 'json':
-            df.to_json(file + ".json", encoding='utf-8')
-        else:
-            return False
+        return df
 
 
+    def delete_txt(self, line: str):
+        count = 0
+        word_list = self.word_pattern.findall(line)
+        for w in word_list:
+            cur = self.delete(table="Word", where=f"LOWER(word)='{w.lower()}'")
+            if cur[1].rowcount != -1:
+                count += 1
+        return count
 
 
-if __name__ == '__main__':
-    db = WordDatabase()
-    db.export_as_table("resource/English-Word")
+    def delete_all(self):
+        cur = self.delete(table="Word")
+        return cur[1].rowcount

+ 0 - 121
tktool.py

@@ -1,121 +0,0 @@
-import abc
-import traceback
-import threading
-from tkinter.font import Font
-from typing import Optional, List
-
-
-def make_font(**kwargs):
-    return Font(family=r"./noto/NotoSansSC-Thin.otf", **kwargs)
-
-
-class TkEventMain(metaclass=abc.ABCMeta):
-    """
-    Tkinter 处理子线程基类
-    """
-    tk_refresh_delay = 50
-
-    def __init__(self):
-        self._event_list: List[TkEventBase] = []
-        self.set_after_run(self.tk_refresh_delay, lambda: self.run_event())
-
-    def push_event(self, event: "TkEventBase"):  # 添加子线程
-        self._event_list.append(event)
-        self.show_loading(event.get_title())
-        self.run_event()
-
-    def run_event(self):  # 定时任务, 检测子线程是否结束, 并运行 done_after_event
-        if len(self._event_list) == 0:
-            return
-
-        new_event: List[TkEventBase] = []
-        done_event: List[TkEventBase] = []
-        for event in self._event_list:
-            if event.is_end():
-                done_event.append(event)
-            else:
-                new_event.append(event)
-        self._event_list = new_event
-        if len(self._event_list) == 0:
-            self.stop_loading()
-
-        for event in done_event:  # 隐藏进度条后执行Event-GUI任务
-            try:
-                event.done_after_event()
-            except:
-                traceback.print_exc()
-        self.set_after_run_now(self.tk_refresh_delay, self.run_event)
-
-    @abc.abstractmethod
-    def show_loading(self, title: str):  # 有子线程时显示加载
-        ...
-
-    @abc.abstractmethod
-    def stop_loading(self):  # 子线程运行完成后关闭加载
-        ...
-
-    @abc.abstractmethod
-    def set_after_run(self, ms, func, *args):
-        ...
-
-    @abc.abstractmethod
-    def set_after_run_now(self, ms, func, *args):
-        ...
-
-
-class TkEventBase(metaclass=abc.ABCMeta):
-    """
-    Tkinter 子线程任务
-    """
-
-    def __init__(self):
-        self.thread: Optional[TkThreading] = None  # 子线程
-
-    def is_end(self) -> bool:  # 判断子线程是否结束
-        if self.thread is not None and not self.thread.is_alive():
-            return True
-        return False
-
-    @abc.abstractmethod
-    def get_title(self) -> str:  # 获取任务名字
-        ...
-
-    def done_after_event(self):  # 子线程结束后, 在GUI线程执行的代码
-        if self.thread is not None:
-            self.thread.wait_event()
-
-
-class TkThreading(threading.Thread):
-    """
-    tkinter 子线程
-    """
-
-    def __init__(self, func, *args, start_now: bool = True):
-        """
-        :param func: 子线程函数
-        :param args: 子线程参数
-        :param start_now: 是否马上运行 (否则要回调.start函数)
-        """
-        threading.Thread.__init__(self)
-        self.func = func
-        self.args = args
-        self.result = None
-
-        if start_now:
-            self.start()
-
-    def run(self):
-        try:
-            self.result = self.func(*self.args)
-        except:
-            traceback.print_exc()
-        finally:
-            del self.func, self.args
-
-    def wait_event(self) -> any:
-        """
-        等待线程结束
-        :return: 线程函数的返回值
-        """
-        self.join()
-        return self.result

+ 0 - 310
ui.py

@@ -1,310 +0,0 @@
-import tktool
-import tkinter
-import tkinter.ttk as ttk
-import tkinter.filedialog as fd
-import tkinter.messagebox as msg
-from typing import List, Tuple, Callable, Optional
-import abc
-
-import db
-import word
-
-
-class HEnglishTkinter(tktool.TkEventMain, metaclass=abc.ABCMeta):
-    tk_zoom = 1
-
-    def set_after_run(self, ms, func, *args):  # 正常运行前设置定时任务 super.__init__可能会调用
-        self.init_after_run_list.append((ms, func, args))
-
-    def __conf_set_after_run(self):  # 配合 set_after_run 使用
-        for ms, func, args in self.init_after_run_list:
-            self.set_after_run_now(ms, func, *args)
-
-    def set_after_run_now(self, ms, func, *args):  # 正常运行时设置定时任务
-        self._window.after(ms, func, *args)
-
-    def __init__(self, title: str,
-                 top: Optional["HEnglishTkinter"] = None,
-                 size: Tuple[float, float] = ((1 / 3), (2 / 3))):
-        self.init_after_run_list: List[Tuple[int, Callable, Tuple]] = []
-        super(HEnglishTkinter, self).__init__()
-
-        if top:
-            self._window = tkinter.Toplevel(top._window)
-            top._window.lift()
-        else:
-            self._window = tkinter.Tk()
-
-        self._sys_height = self._window.winfo_screenheight()
-        self._sys_width = self._window.winfo_screenwidth()
-
-        self._win_height = int(self._sys_height * size[1] * self.tk_zoom)  # 窗口高度
-        self._win_width = int(self._sys_width * size[0] * self.tk_zoom)  # 窗口宽度
-
-        self.__conf_windows(title)
-        self.__conf_set_after_run()
-
-    def __conf_windows(self, title: str):
-        self._window.title(title)
-        self._window.geometry(f'{self._win_width}x{self._win_height}')
-        self._window['bg'] = '#F0FFFF'
-        self._window.resizable(True, True)  # 禁止缩放
-        self._window.overrideredirect(False)  # 显示标题栏
-        self._window.bind('<Configure>', self.__window_resize)  # 调整界面大小
-        self._window.minsize(int(self._sys_width * (1 / 3) * self.tk_zoom),
-                             int(self._sys_height * (1 / 3) * self.tk_zoom))
-
-        self._create_windows()
-        self._set_windows()
-
-    def __window_resize(self, event=None):
-        if self._win_width != self._window.winfo_width() or self._win_height != self._window.winfo_height():
-            self._win_height = self._window.winfo_height()
-            self._win_width = self._window.winfo_width()
-            self._set_windows()
-
-    @abc.abstractmethod
-    def _create_windows(self):
-        pass
-
-    @abc.abstractmethod
-    def _set_windows(self):
-        pass
-
-    def mainloop(self):
-        self._window.mainloop()
-
-
-class HEnglish(HEnglishTkinter):
-    about_info = """H-English 是一个使用剑桥词典的英语学习小工具。
-使用Python+SQLite作为实现,爬取剑桥词典的英语单词。
-本项目为开源项目,供免费学习使用。
-产生任何法律问题本人概不负责。"""
-
-    def __init__(self):
-        super(HEnglish, self).__init__("H-English")
-        self.db = db.WordDatabase()
-        self.wd = self.db.wd
-
-    def _create_windows(self):
-        self._title_label = tkinter.Label(self._window)
-        self._control_frame = tkinter.Frame(self._window)
-        self._control_btn = [tkinter.Button(self._control_frame) for _ in range(6)]
-
-    def _set_windows(self):
-        self.__conf_title()
-        self.__conf_control_btn()
-
-    def __conf_title(self):
-        if self._win_width >= self._win_height:
-            font = tktool.make_font(size=int(self._win_height * 0.06), weight="bold")
-        else:
-            font = tktool.make_font(size=int(self._win_width * 0.05), weight="bold")
-        self._title_label['font'] = font
-        self._title_label['bg'] = '#F0FFFF'
-        self._title_label['text'] = "Huan-English-Dictionary"  # 使用英语标题在GUI更美观
-        self._title_label['anchor'] = 'c'
-        self._title_label.place(relx=0.0, rely=0.03, relwidth=1.0, relheight=0.13)
-        self._title = tkinter.Label()
-
-    def __conf_control_btn(self):
-        if self._win_width >= self._win_height:
-            font = tktool.make_font(size=int(self._win_height * 0.03))
-            self._control_btn[0].place(relx=0.07, rely=0.10, relwidth=0.4, relheight=0.2)
-            self._control_btn[1].place(relx=0.53, rely=0.10, relwidth=0.4, relheight=0.2)
-            self._control_btn[2].place(relx=0.07, rely=0.40, relwidth=0.4, relheight=0.2)
-            self._control_btn[3].place(relx=0.53, rely=0.40, relwidth=0.4, relheight=0.2)
-            self._control_btn[4].place(relx=0.07, rely=0.70, relwidth=0.4, relheight=0.2)
-            self._control_btn[5].place(relx=0.53, rely=0.70, relwidth=0.4, relheight=0.2)
-        else:
-            font = tktool.make_font(size=int(self._win_width * 0.03))
-            self._control_btn[0].place(relx=0.1, rely=0.08, relwidth=0.8, relheight=0.1)
-            self._control_btn[1].place(relx=0.1, rely=0.23, relwidth=0.8, relheight=0.1)
-            self._control_btn[2].place(relx=0.1, rely=0.38, relwidth=0.8, relheight=0.1)
-            self._control_btn[3].place(relx=0.1, rely=0.53, relwidth=0.8, relheight=0.1)
-            self._control_btn[4].place(relx=0.1, rely=0.68, relwidth=0.8, relheight=0.1)
-            self._control_btn[5].place(relx=0.1, rely=0.83, relwidth=0.8, relheight=0.1)
-
-        self._control_frame['bg'] = "#FFFFFF"
-        self._control_frame['relief'] = "ridge"
-        self._control_frame['bd'] = 5
-        self._control_frame.place(relx=0.05, rely=0.20, relwidth=0.90, relheight=0.75)
-
-        for i in zip(self._control_btn,
-                     ["Word Test", "Dictionary", "Export", "Import", "Delete", "About"],
-                     ["#DCDCDC", "#DCDCDC", "#DCDCDC", "#DCDCDC", "#DCDCDC", "#DCDCDC"],
-                     [None, None, None, self.import_word, None, self.about]):
-            i[0]['font'] = font
-            i[0]['fg'] = "#000000"
-            i[0]['bg'] = i[2]
-            i[0]['activeforeground'] = "#FFFFFF"
-            i[0]['activebackground'] = i[2]
-            i[0]['anchor'] = 'c'
-            i[0]['relief'] = "ridge"
-            i[0]['bd'] = 5
-            i[0]['text'] = i[1]
-            i[0]['command'] = i[3]
-
-    def import_word(self):
-        Import(self, self._window)
-
-    def about(self):
-        msg.showinfo("关于", self.about_info)
-
-    def show_loading(self, title: str):  # 有子线程时显示加载
-        ...
-
-    def stop_loading(self):  # 子线程运行完成后关闭加载
-        ...
-
-    def disable(self):
-        self._window.state('icon')
-        for i in self._control_btn:
-            i['state'] = 'disable'
-
-    def enable(self):
-        self._window.state('normal')
-        for i in self._control_btn:
-            i['state'] = 'normal'
-
-
-class Import(HEnglishTkinter):
-    class ImportEvent(tktool.TkEventBase, metaclass=abc.ABCMeta):
-        def __init__(self, imp: "Import"):
-            super().__init__()
-            self.imp = imp
-            self.thread = None
-            self.file = ""
-
-        @abc.abstractmethod
-        def func(self, *args):
-            ...
-
-        def get_title(self) -> str:
-            return "Import"
-
-        def start(self, *args):
-            self.thread = tktool.TkThreading(self.func, *args)
-            return self
-
-        def done_after_event(self):
-            res = self.thread.wait_event()
-            if res:
-                msg.showinfo("操作成功", f"成功从{self.file}中读取单词")
-
-    class ImportFromText(ImportEvent):
-        def __init__(self, imp: "Import"):
-            super().__init__(imp)
-
-        def func(self, file: str):
-            self.file = file
-            return self.imp._father.db.update_from_txt(file)
-
-    class ImportFromTable(ImportEvent):
-        def __init__(self, imp: "Import"):
-            super().__init__(imp)
-
-        def func(self, file: str, t: str):
-            self.file = file
-            return self.imp._father.db.update_from_table(file, t)
-
-    def __init__(self, father: HEnglish, father_windows: tkinter.Tk):
-        super(Import, self).__init__("Import", father, size=(1 / 3, 1 / 3))
-        self._father = father
-        self._father_windows = father_windows
-        self._father.disable()
-        self._window.protocol("WM_DELETE_WINDOW", self.close)
-
-    def close(self):
-        self._window.destroy()
-        self._father.enable()
-
-    def _create_windows(self):
-        self._title_label = tkinter.Label(self._window)
-        self._loading_pro = ttk.Progressbar(self._window)
-        self._control_btn = [tkinter.Button(self._window) for _ in range(6)]
-
-    def _set_windows(self):
-        self.__conf_title()
-        self.__conf_loader()
-        self.__conf_control_btn()
-
-    def __conf_title(self):
-        if self._win_width >= self._win_height:
-            font = tktool.make_font(size=int(self._win_height * 0.06), weight="bold")
-        else:
-            font = tktool.make_font(size=int(self._win_width * 0.05), weight="bold")
-        self._title_label['font'] = font
-        self._title_label['bg'] = '#F0FFFF'
-        self._title_label['text'] = "Import Word"  # 使用英语标题在GUI更美观
-        self._title_label['anchor'] = 'c'
-        self._title_label.place(relx=0.0, rely=0.03, relwidth=1.0, relheight=0.13)
-        self._title = tkinter.Label()
-
-    def __conf_loader(self):
-        self._loading_pro['mode'] = 'indeterminate'  # 来回显示
-        self._loading_pro['orient'] = 'horizontal'  # 横向进度条
-        self._loading_pro['maximum'] = 100
-
-    def __conf_control_btn(self):
-        if self._win_width >= self._win_height:
-            font = tktool.make_font(size=int(self._win_height * 0.04))
-            self._control_btn[0].place(relx=0.07, rely=0.28, relwidth=0.4, relheight=0.2)
-            self._control_btn[1].place(relx=0.53, rely=0.28, relwidth=0.4, relheight=0.2)
-            self._control_btn[2].place(relx=0.07, rely=0.66, relwidth=0.4, relheight=0.2)
-            self._control_btn[3].place(relx=0.53, rely=0.66, relwidth=0.4, relheight=0.2)
-        else:
-            font = tktool.make_font(size=int(self._win_width * 0.04))
-            self._control_btn[0].place(relx=0.1, rely=0.20, relwidth=0.8, relheight=0.1)
-            self._control_btn[1].place(relx=0.1, rely=0.33, relwidth=0.8, relheight=0.1)
-            self._control_btn[2].place(relx=0.1, rely=0.46, relwidth=0.8, relheight=0.1)
-            self._control_btn[3].place(relx=0.1, rely=0.59, relwidth=0.8, relheight=0.1)
-
-        for i in zip(self._control_btn,
-                     ["From Text", "From CSV", "From Excel", "From Json"],
-                     ["#DCDCDC", "#DCDCDC", "#DCDCDC", "#DCDCDC"],
-                     [self.import_from_text, self.import_from_csv, self.import_from_excel, self.import_from_json]):
-            i[0]['font'] = font
-            i[0]['fg'] = "#000000"
-            i[0]['bg'] = i[2]
-            i[0]['activeforeground'] = "#FFFFFF"
-            i[0]['activebackground'] = i[2]
-            i[0]['anchor'] = 'c'
-            i[0]['relief'] = "ridge"
-            i[0]['bd'] = 5
-            i[0]['text'] = i[1]
-            i[0]['command'] = i[3]
-
-    def import_from_text(self):
-        file = fd.askopenfilename(filetypes=[("Text", ".txt"), ("All", "*")])
-        if file != "":
-            self.push_event(self.ImportFromText(self).start(file))
-
-    def import_from_csv(self):
-        file = fd.askopenfilename(filetypes=[("CSV", ".csv"), ("All", "*")])
-        if file != "":
-            self.push_event(self.ImportFromTable(self).start(file, "csv"))
-
-    def import_from_excel(self):
-        file = fd.askopenfilename(filetypes=[("Excel", ".xlsx"), ("All", "*")])
-        if file != "":
-            self.push_event(self.ImportFromTable(self).start(file, "excel"))
-
-    def import_from_json(self):
-        file = fd.askopenfilename(filetypes=[("Json", ".json"), ("All", "*")])
-        if file != "":
-            self.push_event(self.ImportFromTable(self).start(file, "json"))
-
-    def show_loading(self, title: str):
-        self._loading_pro['value'] = 0
-        self._loading_pro.place(relx=0.10, rely=0.17, relwidth=0.80, relheight=0.05)
-        self._loading_pro.start(50)
-
-    def stop_loading(self):
-        self._loading_pro.place_forget()
-        self._loading_pro.stop()
-
-
-if __name__ == '__main__':
-    hgui = HEnglish()
-    hgui.mainloop()