Ver código fonte

设置API继承UIAPI,添加函数系统遗漏的UIAPI

Huan 5 anos atrás
pai
commit
d03bef908b
8 arquivos alterados com 1027 adições e 1027 exclusões
  1. 213 213
      algebraicfactory/gui.py
  2. 58 58
      crawler/gui.py
  3. 163 163
      datascience/gui.py
  4. 0 1
      funcsystem/controller.py
  5. 210 209
      funcsystem/factory.py
  6. 179 179
      funcsystem/map.py
  7. 124 124
      gitrepo/gui.py
  8. 80 80
      machinelearning/gui.py

Diferenças do arquivo suprimidas por serem muito extensas
+ 213 - 213
algebraicfactory/gui.py


+ 58 - 58
crawler/gui.py

@@ -225,7 +225,7 @@ class UIAPI:
     @staticmethod
     def update_cookies_box_gui(cookies):
         global cookies_BOX, cookies_list
-        if UIAPI.get_cookies_fix_gui():
+        if API.get_cookies_fix_gui():
             cookies_list = cookies
             cookies_BOX.delete(0, tkinter.END)
             cookies_BOX.insert(0, *cookies)
@@ -280,8 +280,8 @@ class UIAPI:
             element_value=operation_object.get(),
             index=index,
             url_name=url_tag.get(),
-            update_func=UIAPI.update_url_box_gui,
-            url_args=UIAPI.get_url_parameter_gui(),
+            update_func=API.update_url_box_gui,
+            url_args=API.get_url_parameter_gui(),
         )
 
     @staticmethod
@@ -292,14 +292,14 @@ class UIAPI:
 
     @staticmethod
     def to_database_gui():
-        index = UIAPI.get_db_index_gui(object_index)
+        index = API.get_db_index_gui(object_index)
         return dict(element_value=operation_object.get(),
                     index=index,
                     data=data_format.get(),
-                    dataBase_name=UIAPI.get_datadase_name_gui(),)
+                    dataBase_name=API.get_datadase_name_gui(),)
 
 
-class API:
+class API(UIAPI):
     @staticmethod
     def to_database(is_tag=True):
         global object_index, operation_object, data_format, page_parser
@@ -307,56 +307,56 @@ class API:
             func = page_parser.to_database
         else:
             func = page_parser.to_database_by_re
-        func(**UIAPI.to_database_gui())
-        UIAPI.update_parser_func_box_gui()
+        func(**API.to_database_gui())
+        API.update_parser_func_box_gui()
 
     @staticmethod
     def close():
-        name = UIAPI.get_datadase_name_gui()
+        name = API.get_datadase_name_gui()
         database.close(name)
-        UIAPI.update_database_box_gui()
+        API.update_database_box_gui()
 
     @staticmethod
     def out():
-        name = UIAPI.get_datadase_name_gui()
+        name = API.get_datadase_name_gui()
         database.out(name, save_dir)
-        UIAPI.update_database_box_gui()
+        API.update_database_box_gui()
 
     @staticmethod
     def remove_database():
-        name = UIAPI.get_datadase_name_gui()
+        name = API.get_datadase_name_gui()
         database.rm_database(name)
-        UIAPI.update_database_box_gui()
+        API.update_database_box_gui()
 
     @staticmethod
     def add_database():
         name = database_name.get()
         database.add_database(name)
-        UIAPI.update_database_box_gui()
+        API.update_database_box_gui()
 
     @staticmethod
     def clean_attributes():
         global attributes_dict
         attributes_dict = {}
-        UIAPI.update_attributes_box_gui()
+        API.update_attributes_box_gui()
 
     @staticmethod
     def del_attributes():
-        del attributes_dict[list(attributes_dict.keys())[UIAPI.get_attributes_box_index_gui()]]
-        UIAPI.update_attributes_box_gui()
+        del attributes_dict[list(attributes_dict.keys())[API.get_attributes_box_index_gui()]]
+        API.update_attributes_box_gui()
 
     @staticmethod
     def add_attributes():
         try:
-            name, value = UIAPI.add_attributes_gui()
+            name, value = API.add_attributes_gui()
         except BaseException:
             return False
         attributes_dict[name] = value
-        UIAPI.update_attributes_box_gui()
+        API.update_attributes_box_gui()
 
     @staticmethod
     def third_add_action_func(func):
-        args = UIAPI.third_func_args_gui()
+        args = API.third_func_args_gui()
         func = {
             "make_ActionChains": page_parser.make_action_chains,
             "click": page_parser.action_click,
@@ -373,11 +373,11 @@ class API:
             "ActionChains_run": page_parser.action_run,
         }.get(func, page_parser.make_action_chains)
         func(**args)
-        UIAPI.update_parser_func_box_gui()
+        API.update_parser_func_box_gui()
 
     @staticmethod
     def second_add_action_func(func):
-        args = UIAPI.second_func_args_gui()
+        args = API.second_func_args_gui()
         func = {
             "del_all_cookies": page_parser.del_all_cookies,
             "del_cookies": page_parser.del_cookies,
@@ -398,11 +398,11 @@ class API:
             "to_json": page_parser.to_json,
         }.get(func, page_parser.make_bs)
         func(**args)
-        UIAPI.update_parser_func_box_gui()
+        API.update_parser_func_box_gui()
 
     @staticmethod
     def first_add_action_func(func):
-        args = UIAPI.first_func_args_gui()
+        args = API.first_func_args_gui()
         func = {
             "send_keys": page_parser.send_keys,
             "clear": page_parser.clear,
@@ -430,19 +430,19 @@ class API:
             "switch_to_windwos": page_parser.switch_to_windwos,
         }.get(func, page_parser.send_keys)
         func(**args)
-        UIAPI.update_parser_func_box_gui()
+        API.update_parser_func_box_gui()
 
     @staticmethod
     def add_frame_func_father(is_main=True):
         search = None if is_main else ""
         page_parser.find_switch_to_frame(search, True)
-        UIAPI.update_parser_func_box_gui()
+        API.update_parser_func_box_gui()
 
     @staticmethod
     def add_frame_func_id():
         search = API.get_search_key()
         page_parser.find_switch_to_frame(search, True)
-        UIAPI.update_parser_func_box_gui()
+        API.update_parser_func_box_gui()
 
     @staticmethod
     def add_find_func(func):
@@ -462,7 +462,7 @@ class API:
             "frame": page_parser.find_switch_to_frame,
         }.get(func, page_parser.find_id)
         func(search, not_all=not_all)
-        UIAPI.update_parser_func_box_gui()
+        API.update_parser_func_box_gui()
 
     @staticmethod
     def get_search_key():
@@ -472,9 +472,9 @@ class API:
     @staticmethod
     def del_parser_func():
         try:
-            index = UIAPI.get_parser_func_box_index_gui()
+            index = API.get_parser_func_box_index_gui()
             page_parser.del_func(index, True)
-            UIAPI.update_parser_func_box_gui()
+            API.update_parser_func_box_gui()
         except BaseException:
             pass
 
@@ -482,17 +482,17 @@ class API:
     def clean_parser_func():
         try:
             page_parser.tra_func()
-            UIAPI.update_parser_func_box_gui()
+            API.update_parser_func_box_gui()
         except BaseException:
             pass
 
     @staticmethod
     def update_cookies():
-        cookies = UIAPI.get_new_cookies_gui()
-        if UIAPI.get_cookies_fix_gui():
+        cookies = API.get_new_cookies_gui()
+        if API.get_cookies_fix_gui():
             return False
         try:
-            name = cookies_list[UIAPI.get_cookies_box_index_gui()].get("name")
+            name = cookies_list[API.get_cookies_box_index_gui()].get("name")
             loader.monitoring_update_cookies(name, cookies)
             API.set_cookies_fix()
         except BaseException:
@@ -500,8 +500,8 @@ class API:
 
     @staticmethod
     def add_cookies():
-        cookies = UIAPI.get_new_cookies_gui()
-        if UIAPI.get_cookies_fix_gui():
+        cookies = API.get_new_cookies_gui()
+        if API.get_cookies_fix_gui():
             return False
         try:
             loader.monitoring_add_cookies(cookies)
@@ -511,7 +511,7 @@ class API:
 
     @staticmethod
     def clean_cookies():
-        if UIAPI.get_cookies_fix_gui():
+        if API.get_cookies_fix_gui():
             return False
         try:
             loader.monitoring_clear_cookier()
@@ -525,10 +525,10 @@ class API:
 
     @staticmethod
     def del_cookies():
-        if UIAPI.get_cookies_fix_gui():
+        if API.get_cookies_fix_gui():
             return False
         try:
-            name = cookies_list[UIAPI.get_cookies_box_index_gui()].get("name")
+            name = cookies_list[API.get_cookies_box_index_gui()].get("name")
             loader.monitoring_del_cookies(name)
             API.set_cookies_fix()
         except BaseException:
@@ -549,14 +549,14 @@ class API:
             while start_loader_stop:
                 if url.is_finish():
                     break
-                loader.start_to_run(func_cookie=UIAPI.update_cookies_box_gui)
-                UIAPI.update_url_box_gui()
-                page_parser.element_interaction(UIAPI.update_run_status_gui)
+                loader.start_to_run(func_cookie=API.update_cookies_box_gui)
+                API.update_url_box_gui()
+                page_parser.element_interaction(API.update_run_status_gui)
             loader.stop()
 
         new = threading.Thread(target=start_loader)
         new.start()
-        UIAPI.update_url_box_gui()
+        API.update_url_box_gui()
 
     @staticmethod
     def crawler_run_one():
@@ -564,9 +564,9 @@ class API:
             global loader, page_parser
             if url.is_finish():
                 return
-            loader.start_to_run(func_cookie=UIAPI.update_cookies_box_gui)
-            UIAPI.update_url_box_gui()
-            page_parser.element_interaction(UIAPI.update_run_status_gui)
+            loader.start_to_run(func_cookie=API.update_cookies_box_gui)
+            API.update_url_box_gui()
+            page_parser.element_interaction(API.update_run_status_gui)
             loader.stop()
 
         new = threading.Thread(target=start_loader)
@@ -575,38 +575,38 @@ class API:
     @staticmethod
     def add_filter_func_https():
         url.add_filter_func(lambda url: re.match(re.compile("^https://"), url), "HTTPS过滤")
-        UIAPI.update_filter_func_box_gui()
+        API.update_filter_func_box_gui()
 
     @staticmethod
     def add_filter_func_www():
         url.add_filter_func(lambda url: re.match(re.compile(r".*www\."), url), "www过滤")
-        UIAPI.update_filter_func_box_gui()
+        API.update_filter_func_box_gui()
 
     @staticmethod
     def del_filter_func():
-        index = UIAPI.get_filter_func_box_index_gui()
+        index = API.get_filter_func_box_index_gui()
         url.del_filter_func(index)
-        UIAPI.update_filter_func_box_gui()
+        API.update_filter_func_box_gui()
 
     @staticmethod
     def del_url():
-        index = UIAPI.get_url_box_index_gui()
+        index = API.get_url_box_index_gui()
         url.del_url(index)
-        UIAPI.update_url_box_gui()
+        API.update_url_box_gui()
 
     @staticmethod
     def add_url():
-        args = UIAPI.get_url_parameter_gui()
-        new_url = UIAPI.get_new_url_name_gui()
+        args = API.get_url_parameter_gui()
+        new_url = API.get_new_url_name_gui()
         if new_url == "":
             return
         url.add_url(new_url, **args)
-        UIAPI.update_url_box_gui()
+        API.update_url_box_gui()
 
     @staticmethod
     def add_url_from_tag():
-        page_parser.add_url(**UIAPI.add_url_from_tag_gui())
-        UIAPI.update_parser_func_box_gui()
+        page_parser.add_url(**API.add_url_from_tag_gui())
+        API.update_parser_func_box_gui()
 
 
 def crawler_main():

+ 163 - 163
datascience/gui.py

@@ -265,7 +265,7 @@ class UIAPI:
 
     @staticmethod
     def view_cleaning_script_gui():
-        name = clean_list[UIAPI.get_clean_func_box_index_gui()]
+        name = clean_list[API.get_clean_func_box_index_gui()]
         API.update_clean_code(machine_controller.get_clean_code(name))
 
     @staticmethod
@@ -330,7 +330,7 @@ class UIAPI:
     @staticmethod
     def set_dtype_gui():
         type_ = bool(dtype_func.get())
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         column_list = dtype_column.get().split(",")
         if column_list == [""]:
             column_list = []
@@ -403,7 +403,7 @@ class UIAPI:
     @staticmethod
     def set_learner_gui():
         global chose_learner
-        chose_learner.set(UIAPI.get_learner_name_gui(True))
+        chose_learner.set(API.get_learner_name_gui(True))
 
     @staticmethod
     def get_learner_name_gui(learner_type=False):
@@ -436,36 +436,36 @@ class UIAPI:
         tkinter.messagebox.showinfo("非常抱歉", "高级别的机器学习请到机器学习板块深入研究...")
 
 
-class API:
+class API(UIAPI):
     @staticmethod
     def clear_rendering():
         machine_controller.clean_render()
-        UIAPI.update_render_box_gui()
+        API.update_render_box_gui()
 
     @staticmethod
     def del_form():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         machine_controller.del_sheet(name)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def del_learner():
-        learner = UIAPI.get_learner_name_gui(True)
-        set_learne = UIAPI.get_learner_name_gui(False)  # 获取学习器Learner
+        learner = API.get_learner_name_gui(True)
+        set_learne = API.get_learner_name_gui(False)  # 获取学习器Learner
         if set_learne != learner:
             machine_controller.del_leaner(learner)
-        UIAPI.update_leaner_box_gui()
+        API.update_leaner_box_gui()
 
     @staticmethod
     def visual_learner():
-        learner = UIAPI.get_learner_name_gui(True)
+        learner = API.get_learner_name_gui(True)
         data = machine_controller.visual_learner(
-            learner, UIAPI.askokcancel_gui(f"是否将数据生成表格。\n(可绘制成散点图对比数据)")
+            learner, API.askokcancel_gui(f"是否将数据生成表格。\n(可绘制成散点图对比数据)")
         )
-        UIAPI.vitables_gui(
+        API.vitables_gui(
             f"对象:{learner}\n\n{data[0]}\n\n\n{data[1]}", f"CoTan数据处理 查看数据:{learner}"
         )
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def get_learner_config():
@@ -473,8 +473,8 @@ class API:
 
     @staticmethod
     def test_learner():
-        name = UIAPI.get_sheet_name_gui()  # 表格数据
-        learner = UIAPI.get_learner_name_gui()
+        name = API.get_sheet_name_gui()  # 表格数据
+        learner = API.get_learner_name_gui()
         try:
             split = float(data_split.get())
             if split < 0 or 1 < split:
@@ -488,18 +488,18 @@ class API:
 
     @staticmethod
     def predict_learner():
-        name = UIAPI.get_sheet_name_gui()  # 表格数据
-        learner = UIAPI.get_learner_name_gui()
+        name = API.get_sheet_name_gui()  # 表格数据
+        learner = API.get_learner_name_gui()
         data = machine_controller.predict(name, learner)
         title = f"CoTan数据处理 表格:{name} 学习器:{learner}"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def fit_learner():
-        name = UIAPI.get_sheet_name_gui()  # 表格数据
-        learner = UIAPI.get_learner_name_gui()
-        split = UIAPI.get_data_split_gui()
+        name = API.get_sheet_name_gui()  # 表格数据
+        learner = API.get_learner_name_gui()
+        split = API.get_data_split_gui()
         socore = machine_controller.training_machine(
             name, learner, parameters=API.get_learner_config(), split=split
         )
@@ -536,54 +536,54 @@ class API:
     @staticmethod
     def add_learner_core(learner_type):  # 添加Lenear的核心
         machine_controller.add_learner(learner_type, parameters=API.get_learner_config())
-        UIAPI.update_leaner_box_gui()
+        API.update_leaner_box_gui()
 
     @staticmethod
     def feature_extraction():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         machine_controller.decision_tree_classifier(name)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def replace_index_func():
-        name = UIAPI.get_sheet_name_gui()
-        is_column, save, the_replace_dict = UIAPI.replace_index_func_gui()
+        name = API.get_sheet_name_gui()
+        is_column, save, the_replace_dict = API.replace_index_func_gui()
         machine_controller.replace_index(name, is_column, the_replace_dict, save)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def change_index():
-        name = UIAPI.get_sheet_name_gui()  # 名字
-        drop, iloc, is_column, save = UIAPI.change_index_gui()
+        name = API.get_sheet_name_gui()  # 名字
+        drop, iloc, is_column, save = API.change_index_gui()
 
         machine_controller.change_index(name, is_column, iloc, save, drop)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def num_to_name():
-        name = UIAPI.get_sheet_name_gui()  # 名字
-        is_column, save = UIAPI.num_to_name_gui()
+        name = API.get_sheet_name_gui()  # 名字
+        is_column, save = API.num_to_name_gui()
 
         machine_controller.number_naming(name, is_column, save)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def num_with_name():
-        name = UIAPI.get_sheet_name_gui()  # 名字
-        is_column, save = UIAPI.num_with_name_gui()
+        name = API.get_sheet_name_gui()  # 名字
+        is_column, save = API.num_with_name_gui()
 
         machine_controller.name_with_number(name, is_column, save)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def datetime_index(is_date=True):
-        name = UIAPI.get_sheet_name_gui()  # 名字
-        init, is_column, save = UIAPI.datetime_index_gui()
+        name = API.get_sheet_name_gui()  # 名字
+        init, is_column, save = API.datetime_index_gui()
         if is_date:
             machine_controller.date_index(name, is_column, save, **init)
         else:
             machine_controller.time_naming(name, is_column, save, **init)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def date_index():
@@ -595,14 +595,14 @@ class API:
 
     @staticmethod
     def set_dtype():
-        column_list, dtype, name, type_, wrong = UIAPI.set_dtype_gui()
+        column_list, dtype, name, type_, wrong = API.set_dtype_gui()
         if type_:  # 软转换
             if wrong != "ignore":
                 wrong = "coerce"
             machine_controller.set_dtype(name, column_list, dtype, wrong)
         else:
             machine_controller.as_dtype(name, column_list, dtype, "ignore")
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def python_render():  # 导入绘制方法
@@ -619,18 +619,18 @@ class API:
 
     @staticmethod
     def rendering():
-        render_dir = UIAPI.rendering_gui()
+        render_dir = API.rendering_gui()
         webbrowser.open(
             machine_controller.render_all(API.get_rendering_parameters(), render_dir)
         )
-        UIAPI.update_render_box_gui()
+        API.update_render_box_gui()
 
     @staticmethod
     def rendering_one():
-        render_dir = UIAPI.rendering_one_gui()
-        list(render_dict.values())[UIAPI.render_box_index_gui()].render(render_dir)
+        render_dir = API.rendering_one_gui()
+        list(render_dict.values())[API.render_box_index_gui()].render(render_dir)
         webbrowser.open(render_dir)
-        UIAPI.update_render_box_gui()
+        API.update_render_box_gui()
 
     @staticmethod
     def make_overlap():
@@ -642,182 +642,182 @@ class API:
                 raise
             base_image = None
             top_image = None
-        UIAPI.update_combo_box_gui()
+        API.update_combo_box_gui()
 
     @staticmethod
     def add_basemap():
         global base_image
-        base_image = list(render_dict.keys())[UIAPI.render_box_index_gui()]
-        UIAPI.update_combo_box_gui()
+        base_image = list(render_dict.keys())[API.render_box_index_gui()]
+        API.update_combo_box_gui()
 
     @staticmethod
     def add_top_image():
         global top_image
-        top_image = list(render_dict.keys())[UIAPI.render_box_index_gui()]
-        UIAPI.update_combo_box_gui()
+        top_image = list(render_dict.keys())[API.render_box_index_gui()]
+        API.update_combo_box_gui()
 
     @staticmethod
     def del_rendering():
-        key = list(render_dict.keys())[UIAPI.render_box_index_gui()]
+        key = list(render_dict.keys())[API.render_box_index_gui()]
         machine_controller.del_render(key)
-        UIAPI.update_render_box_gui()
+        API.update_render_box_gui()
 
     @staticmethod
     def new_render(c, name):
-        if UIAPI.get_draw_as_well_gui():
+        if API.get_draw_as_well_gui():
             c.render(f"{PATH}\\{name}.html")
-        UIAPI.update_render_box_gui()
+        API.update_render_box_gui()
 
     @staticmethod
     def to_geo():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_geo(name, API.get_rendering_parameters()), "Geo地图")
 
     @staticmethod
     def to_map():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_map(name, API.get_rendering_parameters()), "Map地图")
 
     @staticmethod
     def to_scattergeo():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(
             machine_controller.to_scattergeo(name, API.get_rendering_parameters()), "Geo点地图"
         )
 
     @staticmethod
     def to_treemap():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_tree_map(name, API.get_rendering_parameters()), "矩形树图")
 
     @staticmethod
     def to_tree():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_tree(name, API.get_rendering_parameters()), "树状图")
 
     @staticmethod
     def to_sankey():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_sankey(name, API.get_rendering_parameters()), "桑基图")
 
     @staticmethod
     def to_sunburst():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_sunburst(name, API.get_rendering_parameters()), "旭日图")
 
     @staticmethod
     def to_theme_river():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(
             machine_controller.to_theme_river(name, API.get_rendering_parameters()), "河流图"
         )
 
     @staticmethod
     def to_calendar():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_calendar(name, API.get_rendering_parameters()), "日历图")
 
     @staticmethod
     def to_gauge():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_gauge(name, API.get_rendering_parameters()), "仪表图")
 
     @staticmethod
     def to_liquid():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_liquid(name, API.get_rendering_parameters()), "水球图")
 
     @staticmethod
     def to_line3d():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_line3d(name, API.get_rendering_parameters()), "3D折线图")
 
     @staticmethod
     def to_scatter3d():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(
             machine_controller.to_scatter3d(name, API.get_rendering_parameters()), "3D散点图"
         )
 
     @staticmethod
     def to_bar3d():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_bar3d(name, API.get_rendering_parameters()), "3D柱状图")
 
     @staticmethod
     def to_word_cloud():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(
             machine_controller.to_word_cloud(name, API.get_rendering_parameters()), "词云图"
         )
 
     @staticmethod
     def to_radar():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_radar(name, API.get_rendering_parameters()), "雷达图")
 
     @staticmethod
     def to_polar():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_polar(name, API.get_rendering_parameters()), "极坐标图")
 
     @staticmethod
     def to_pie():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_pie(name, API.get_rendering_parameters()), "饼图")
 
     @staticmethod
     def to_parallel():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_parallel(name, API.get_rendering_parameters()), "多轴图")
 
     @staticmethod
     def to_graph():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_graph(name, API.get_rendering_parameters()), "关系图")
 
     @staticmethod
     def to_format_graph():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(
             machine_controller.to_format_graph(name, API.get_rendering_parameters()), "关系图"
         )
 
     @staticmethod
     def to_funnel():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_funnel(name, API.get_rendering_parameters()), "漏斗图")
 
     @staticmethod
     def to_heat_map():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_heatmap(name, API.get_rendering_parameters()), "热力图")
 
     @staticmethod
     def to_boxpolt():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_boxpolt(name, API.get_rendering_parameters()), "箱形图")
 
     @staticmethod
     def to_pictorialbar():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(
             machine_controller.to_pictorialbar(name, API.get_rendering_parameters()), "象形柱状图"
         )
 
     @staticmethod
     def to_scatter():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_scatter(name, API.get_rendering_parameters()), "散点图")
 
     @staticmethod
     def to_line():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_line(name, API.get_rendering_parameters()), "折线图")
 
     @staticmethod
     def to_bar():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_bar(name, API.get_rendering_parameters()), "柱状图")
 
     @staticmethod
@@ -828,19 +828,19 @@ class API:
     @staticmethod
     def empty_cleaning_script():
         machine_controller.del_all_clean_func()
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def execute_cleaning_script():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         data = machine_controller.data_clean(name)
         title = f"CoTan数据处理 表格:{name}.数据清洗"
-        UIAPI.vitables_gui(data,title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data,title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def del_cleaning_script():
-        name = clean_list[UIAPI.get_clean_func_box_index_gui()]
+        name = clean_list[API.get_clean_func_box_index_gui()]
         machine_controller.del_clean_func(name)
         API.update_cleaning_script_box()
 
@@ -852,126 +852,126 @@ class API:
 
     @staticmethod
     def add_cleaning_script():
-        exp = UIAPI.get_clean_code_gui()
+        exp = API.get_clean_code_gui()
         machine_controller.add_clean_func(exp)
         API.update_cleaning_script_box()
 
     @staticmethod
     def clean_nan_row():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         data = machine_controller.del_nan(name, True)
         title = f"CoTan数据处理 表格:{name}.NaN"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def is_nan():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         data = machine_controller.is_nan(name)
         title = f"CoTan数据处理 表格:{name}.NaN"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def to_bool():
         the_bool_exp = bool_exp.get()
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         data = machine_controller.to_bool(name, the_bool_exp, True)
         title = f"CoTan数据处理 表格:{name} 布尔化"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def del_data():
-        name = UIAPI.get_sheet_name_gui()
-        column, new, row = UIAPI.del_data_gui()
+        name = API.get_sheet_name_gui()
+        column, new, row = API.del_data_gui()
         try:
             data = machine_controller.del_slice(name, column, row, new)
         except BaseException:
             data = "None 你的操作不被允许"
         title = f"CoTan数据处理 表格:{name}"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def slice_data():
-        column, is_iloc, new, row = UIAPI.slice_data_gui()
-        name = UIAPI.get_sheet_name_gui()
+        column, is_iloc, new, row = API.slice_data_gui()
+        name = API.get_sheet_name_gui()
         try:
             data = machine_controller.get_slice(name, column, row, is_iloc, new)
         except BaseException:
             data = "None 你的操作不被允许"
         title = f"CoTan数据处理 表格:{name}"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def sample_data():
-        name = UIAPI.get_sheet_name_gui()
-        new = UIAPI.get_ascending_new_gui()
+        name = API.get_sheet_name_gui()
+        new = API.get_ascending_new_gui()
         data = machine_controller.sample(name, new)
         title = f"CoTan数据处理 打乱表格:{name}"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def stored_value():
-        name = UIAPI.get_sheet_name_gui()
-        new = UIAPI.get_ascending_new_gui()
+        name = API.get_sheet_name_gui()
+        new = API.get_ascending_new_gui()
         data = machine_controller.stored_value(name, stored_list, new)
         title = f"CoTan数据处理 表格:{name}.Stored"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def del_baseline():
         global stored_list, stored_box
-        del stored_list[UIAPI.get_stored_box_index_gui()]
-        UIAPI.update_sort_box_gui()
+        del stored_list[API.get_stored_box_index_gui()]
+        API.update_sort_box_gui()
 
     @staticmethod
     def add_baseline():  # 按基准列排行
         try:
-            ascending, value = UIAPI.add_baseline_gui(ascending_type, sort_by)
+            ascending, value = API.add_baseline_gui(ascending_type, sort_by)
             stored_list.append((value, ascending))
         except BaseException:
             pass
-        UIAPI.update_sort_box_gui()
+        API.update_sort_box_gui()
 
     @staticmethod
     def sort_by_column():  # 行
-        name = UIAPI.get_sheet_name_gui()
-        new, ascending = UIAPI.sort_by_column_gui()
+        name = API.get_sheet_name_gui()
+        new, ascending = API.sort_by_column_gui()
         data = machine_controller.sorted_index(name, False, new, ascending)
         title = f"CoTan数据处理 表格:{name}.Stored by Column"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def sort_by_tow():  # 行
-        name = UIAPI.get_sheet_name_gui()
-        new, ascending = UIAPI.sort_by_column_gui()
+        name = API.get_sheet_name_gui()
+        new, ascending = API.sort_by_column_gui()
         data = machine_controller.sorted_index(name, True, new, ascending)
         title = f"CoTan数据处理 表格:{name}.Stored by Row"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def transpose():
-        name = UIAPI.get_sheet_name_gui()
-        new = UIAPI.get_ascending_new_gui()
+        name = API.get_sheet_name_gui()
+        new = API.get_ascending_new_gui()
         data = machine_controller.transpose(name, new)
         title = f"CoTan数据处理 表格:{name}.T"
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def show_report():
-        if not UIAPI.askokcancel_gui(f"是否统计数据,大量的数据需要耗费一定的时间(确定后,系统会在后台统计)"):
+        if not API.askokcancel_gui(f"是否统计数据,大量的数据需要耗费一定的时间(确定后,系统会在后台统计)"):
             raise Exception
         report_dir = f"{PATH}/$Show_Des_Sheet.html"
         try:
-            name = UIAPI.get_sheet_name_gui()
+            name = API.get_sheet_name_gui()
             if name is None:
                 raise Exception
             machine_controller.to_report(name, report_dir)
@@ -981,36 +981,36 @@ class API:
 
     @staticmethod
     def show_describe():
-        describe = UIAPI.get_des_bool_gui()
-        name = UIAPI.get_sheet_name_gui()
+        describe = API.get_des_bool_gui()
+        name = API.get_sheet_name_gui()
         title = f"CoTan数据处理 表格:{name}_describe"
         data = str(machine_controller.describe(name, describe))
-        UIAPI.vitables_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.vitables_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def show_sheet():
-        name = UIAPI.get_sheet_name_gui()
+        name = API.get_sheet_name_gui()
         title = f"CoTan数据处理 表格:{name}"
         data = str(machine_controller.get_sheet(name))
-        UIAPI.vitables_gui(data, title)
+        API.vitables_gui(data, title)
 
     @staticmethod
     def get_column():  # 列名(横行竖列,列名是上面的)
-        name = UIAPI.get_sheet_name_gui()
-        UIAPI.update_index_box_gui(machine_controller.get_column(name))
+        name = API.get_sheet_name_gui()
+        API.update_index_box_gui(machine_controller.get_column(name))
 
     @staticmethod
     def get_row():  # 行名(横行竖列,行名左)
-        name = UIAPI.get_sheet_name_gui()
-        UIAPI.update_index_box_gui(machine_controller.get_index(name))
+        name = API.get_sheet_name_gui()
+        API.update_index_box_gui(machine_controller.get_index(name))
 
     @staticmethod
     def show_one_sheet_html():
         global PATH, to_html_type
         html_dir = f"{PATH}/$Show_Sheet.html"
         try:
-            name = UIAPI.get_sheet_name_gui()
+            name = API.get_sheet_name_gui()
             if name is None:
                 raise Exception
             machine_controller.render_html_one(name, html_dir)
@@ -1023,7 +1023,7 @@ class API:
         global PATH, to_html_type
         html_dir = f"{PATH}/$Show_Sheet.html"
         try:
-            name = UIAPI.get_sheet_name_gui()
+            name = API.get_sheet_name_gui()
             if name is None:
                 raise Exception
             machine_controller.render_html_all(name, html_dir, to_html_type.get())
@@ -1034,24 +1034,24 @@ class API:
     @staticmethod
     def to_csv():
         global SCREEN, sep, encoding, str_must, index_must
-        csv_sep, save_dir = UIAPI.to_csv_gui()
-        name = UIAPI.get_sheet_name_gui()
+        csv_sep, save_dir = API.to_csv_gui()
+        name = API.get_sheet_name_gui()
         machine_controller.to_csv(name, save_dir, csv_sep)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def add_csv():
         global SCREEN, sep, encoding, str_must, index_must, sheet_name
-        csv_encoding, csv_sep, file_dir, index, name, str_ = UIAPI.add_csv_gui()
+        csv_encoding, csv_sep, file_dir, index, name, str_ = API.add_csv_gui()
         machine_controller.add_csv(file_dir, name, csv_sep, csv_encoding, str_, index)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def add_from_python():
         global SCREEN, sep, encoding, str_must, index_must
-        code, name = UIAPI.add_from_python_gui()
+        code, name = API.add_from_python_gui()
         machine_controller.add_python(code, name)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
 
 def machine_learning():
@@ -1643,7 +1643,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="查看词典",
-    command=UIAPI.show_dictionary_gui,
+    command=API.show_dictionary_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1657,7 +1657,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="恢复显示",
-    command=UIAPI.reset_clean_code_gui,
+    command=API.reset_clean_code_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1708,7 +1708,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="查看执行方法",
-    command=UIAPI.view_cleaning_script_gui,
+    command=API.view_cleaning_script_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1722,7 +1722,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="导入执行方法",
-    command=UIAPI.open_python_for_clean_gui,
+    command=API.open_python_for_clean_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -2312,7 +2312,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="查看词典",
-    command=UIAPI.show_dictionary_gui,
+    command=API.show_dictionary_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -2326,7 +2326,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="恢复显示",
-    command=UIAPI.show_tips_gui,
+    command=API.show_tips_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -2812,7 +2812,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="选用学习器",
-    command=UIAPI.set_learner_gui,
+    command=API.set_learner_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -3009,7 +3009,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="决策树",
-    command=UIAPI.show_sorry_gui,
+    command=API.show_sorry_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -3023,7 +3023,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="SVM",
-    command=UIAPI.show_sorry_gui,
+    command=API.show_sorry_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -3039,7 +3039,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="朴素贝叶斯",
-    command=UIAPI.show_sorry_gui,
+    command=API.show_sorry_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,

+ 0 - 1
funcsystem/controller.py

@@ -35,7 +35,6 @@ class SheetFunc(SheetMemory, SheetComputing, SheetDataPacket, SheetProperty, She
 
 
 class ExpFunc(ExpMemory, ExpComputing, ExpCheck, ExpDataPacket, ExpProperty, ExpBestValue):
-
     def return_son(self):
         return self.son_list
 

+ 210 - 209
funcsystem/factory.py

@@ -46,152 +46,153 @@ gui_height = 2
 row = 0
 column = 1
 
+class UIAPI:
+    @staticmethod
+    def dichotomy_gui():
+        parameters = [100, 0.0001, 0.1, 0.5, False, True, 1000, 0.1, 0.1, False, None]
+        for i in range(11):
+            try:
+                if i in (4, 5, 9):
+                    a = dicon_parameters[i].get()
+                else:
+                    a = float(dicon_parameters[i].get())
+                parameters[i] = a
+            except BaseException:
+                pass
+        return parameters
+
+    @staticmethod
+    def output_prompt_gui(news):
+        global prompt_box, prompt_num, SCREEN
+        prompt_num += 1
+        news = str(news)
+        prompt_box.insert(0, news + f"({prompt_num})")
+        SCREEN.update()
 
-def dichotomy_gui():
-    parameters = [100, 0.0001, 0.1, 0.5, False, True, 1000, 0.1, 0.1, False, None]
-    for i in range(11):
+    @staticmethod
+    def set_func_gui():
+        new_func = func_exp.get().replace(" ", "")
+        if new_func == "":
+            API.output_prompt_gui("应用失败")
+            raise Exception
+        default_value = [-10, 10, 0.1, 2, 1, -10, 10, 1]
+        get = [
+            start_definition,
+            end_definition,
+            span_definition,
+            accuracy,
+            default_a,
+            start_a,
+            end_a,
+            span_a,
+        ]
+        # 参数的处理
         try:
-            if i in (4, 5, 9):
-                a = dicon_parameters[i].get()
+            span_str = span_definition.get().replace(" ", "")
+            if span_str[0] == "H":
+                domain = {
+                    "Pi": sympy.pi,
+                    "e": sympy.E,
+                    "log": sympy.log,
+                    "sin": sympy.sin,
+                    "cos": sympy.cos,
+                    "tan": sympy.tan,
+                    "cot": lambda x: 1 / sympy.tan(x),
+                    "csc": lambda x: 1 / sympy.sin(x),
+                    "sec": lambda x: 1 / sympy.cos(x),
+                    "sinh": sympy.sinh,
+                    "cosh": sympy.cosh,
+                    "tanh": sympy.tanh,
+                    "asin": sympy.asin,
+                    "acos": sympy.acos,
+                    "atan": sympy.atan,
+                }
+                span = eval(span_str[1:], domain)
             else:
-                a = float(dicon_parameters[i].get())
-            parameters[i] = a
+                raise Exception
         except BaseException:
-            pass
-    return parameters
-
-
-def output_prompt_gui(news):
-    global prompt_box, prompt_num, SCREEN
-    prompt_num += 1
-    news = str(news)
-    prompt_box.insert(0, news + f"({prompt_num})")
-    SCREEN.update()
-
-
-def set_func_gui():
-    new_func = func_exp.get().replace(" ", "")
-    if new_func == "":
-        output_prompt_gui("应用失败")
-        raise Exception
-    default_value = [-10, 10, 0.1, 2, 1, -10, 10, 1]
-    get = [
-        start_definition,
-        end_definition,
-        span_definition,
-        accuracy,
-        default_a,
-        start_a,
-        end_a,
-        span_a,
-    ]
-    # 参数的处理
-    try:
-        span_str = span_definition.get().replace(" ", "")
-        if span_str[0] == "H":
-            domain = {
-                "Pi": sympy.pi,
-                "e": sympy.E,
-                "log": sympy.log,
-                "sin": sympy.sin,
-                "cos": sympy.cos,
-                "tan": sympy.tan,
-                "cot": lambda x: 1 / sympy.tan(x),
-                "csc": lambda x: 1 / sympy.sin(x),
-                "sec": lambda x: 1 / sympy.cos(x),
-                "sinh": sympy.sinh,
-                "cosh": sympy.cosh,
-                "tanh": sympy.tanh,
-                "asin": sympy.asin,
-                "acos": sympy.acos,
-                "atan": sympy.atan,
-            }
-            span = eval(span_str[1:], domain)
-        else:
-            raise Exception
-    except BaseException:
-        span = None
-    for i in range(8):
+            span = None
+        for i in range(8):
+            try:
+                default_value[i] = float(get[i].get())
+            except BaseException:
+                pass
+        if span is not None:
+            default_value[2] = span
+        # View的处理
+        style_str = func_style.get().split("#")
         try:
-            default_value[i] = float(get[i].get())
+            if style_str[0] not in point_style:
+                style_str[0] = "b"
+            line_style_str = line_style.get(style_str[1], "-")
         except BaseException:
-            pass
-    if span is not None:
-        default_value[2] = span
-    # View的处理
-    style_str = func_style.get().split("#")
-    try:
-        if style_str[0] not in point_style:
-            style_str[0] = "b"
-        line_style_str = line_style.get(style_str[1], "-")
-    except BaseException:
-        style_str = ["", ""]
-        style_str[0] = random.choice(point_style)
-        line_style_str = "-"
-    style = style_str[0] + line_style_str
-    # Name的处理
-    name = func_name.get().replace(" ", "")
-    if name == "":
-        name = new_func
-    return [new_func, name, style]+default_value
-
-
-def get_y_value_gui():
-    return y_value.get().split(",")
-
-
-def update_prediction_box_gui(answer):
-    prediction_box.delete(0, tkinter.END)
-    prediction_box.insert(tkinter.END, *answer)
-
-
-def get_projection_value_gui():
-    return projection_value.get
-
-
-def get_proximity_accuracy_gui():
-    return proximity_accuracy.get()
-
-
-def get_x_value_derivation_gui():
-    return x_value_derivation.get().split(",")
-
-
-def get_y_value_symbol_gui():
-    return y_value_symbol.get().split(",")
+            style_str = ["", ""]
+            style_str[0] = random.choice(point_style)
+            line_style_str = "-"
+        style = style_str[0] + line_style_str
+        # Name的处理
+        name = func_name.get().replace(" ", "")
+        if name == "":
+            name = new_func
+        return [new_func, name, style]+default_value
 
+    @staticmethod
+    def get_y_value_gui():
+        return y_value.get().split(",")
 
-def get_x_value_gui():
-    return x_value.get().split(",")
-
+    @staticmethod
+    def update_prediction_box_gui(answer):
+        prediction_box.delete(0, tkinter.END)
+        prediction_box.insert(tkinter.END, *answer)
 
-def update_result_box_gui(answer):
-    result_box.delete(0, tkinter.END)  # 清空
-    result_box.insert(tkinter.END, *answer)
+    @staticmethod
+    def get_projection_value_gui():
+        return projection_value.get
 
+    @staticmethod
+    def get_proximity_accuracy_gui():
+        return proximity_accuracy.get()
 
-def get_y_value_gradient_gui():
-    return y_value_gradient.get()
+    @staticmethod
+    def get_x_value_derivation_gui():
+        return x_value_derivation.get().split(",")
 
+    @staticmethod
+    def get_y_value_symbol_gui():
+        return y_value_symbol.get().split(",")
 
-def askokcancel_gui(message):
-    return tkinter.messagebox.askokcancel("提示", message)
+    @staticmethod
+    def get_x_value_gui():
+        return x_value.get().split(",")
 
+    @staticmethod
+    def update_result_box_gui(answer):
+        result_box.delete(0, tkinter.END)  # 清空
+        result_box.insert(tkinter.END, *answer)
 
-def add_projection_box_gui(result):
-    projection_box.insert(tkinter.END, result)
+    @staticmethod
+    def get_y_value_gradient_gui():
+        return y_value_gradient.get()
 
+    @staticmethod
+    def askokcancel_gui(message):
+        return tkinter.messagebox.askokcancel("提示", message)
 
-def update_sheet_box_gui(sheet):
-    sheet_box.delete(0, tkinter.END)
-    sheet_box.insert(tkinter.END, *sheet)
+    @staticmethod
+    def add_projection_box_gui(result):
+        projection_box.insert(tkinter.END, result)
 
+    @staticmethod
+    def update_sheet_box_gui(sheet):
+        sheet_box.delete(0, tkinter.END)
+        sheet_box.insert(tkinter.END, *sheet)
 
-def get_save_dir_gui():
-    return asksaveasfilename(title="选择导出位置", filetypes=[("CSV", ".csv")])
+    @staticmethod
+    def get_save_dir_gui():
+        return asksaveasfilename(title="选择导出位置", filetypes=[("CSV", ".csv")])
 
 
-class API:
+class API(UIAPI):
     @staticmethod
     def type_selection(sequence, type_=float, convert=True):  # Float筛选系统
         x = []
@@ -207,19 +208,19 @@ class API:
     @staticmethod
     def save_to_csv():  # 导出CSV
         try:
-            if not func.save_csv(get_save_dir_gui()):
+            if not func.save_csv(API.get_save_dir_gui()):
                 raise Exception
-            output_prompt_gui("CSV导出成功")
+            API.output_prompt_gui("CSV导出成功")
         except BaseException:
-            output_prompt_gui("CSV导出失败")
+            API.output_prompt_gui("CSV导出失败")
 
     @staticmethod
     def save_to_sheet():  # 生成表格
         try:
-            update_sheet_box_gui(func.return_list())
-            output_prompt_gui("表格创建成功")
+            API.update_sheet_box_gui(func.return_list())
+            API.output_prompt_gui("表格创建成功")
         except BaseException:
-            output_prompt_gui("无法创建表格")
+            API.output_prompt_gui("无法创建表格")
 
     @staticmethod
     def sympy_computing(exp_str) -> tuple:
@@ -263,196 +264,196 @@ class API:
         accuracy = API.computing_gui()
         try:
             result = func.check_symmetry_center(
-                API.confirmation_expression(get_projection_value_gui()), output_prompt_gui, accuracy
+                API.confirmation_expression(API.get_projection_value_gui()), API.output_prompt_gui, accuracy
             )
             if result[0]:
-                add_projection_box_gui(result[1])
-                output_prompt_gui("预测完成")
+                API.add_projection_box_gui(result[1])
+                API.output_prompt_gui("预测完成")
             else:
                 raise Exception
         except BaseException:
-            output_prompt_gui("预测失败")
+            API.output_prompt_gui("预测失败")
 
     @staticmethod
     def check_symmetry_axis():
         accuracy = API.computing_gui()
         try:
             result = func.check_symmetry_axis(
-                API.confirmation_expression(get_projection_value_gui()), output_prompt_gui, accuracy
+                API.confirmation_expression(API.get_projection_value_gui()), API.output_prompt_gui, accuracy
             )
             if result[0]:
-                add_projection_box_gui(result[1])
-                output_prompt_gui("预测完成")
+                API.add_projection_box_gui(result[1])
+                API.output_prompt_gui("预测完成")
             else:
                 raise Exception
         except BaseException:
-            output_prompt_gui("预测失败")
+            API.output_prompt_gui("预测失败")
 
     @staticmethod
     def check_periodic():
         accuracy = API.computing_gui()
         try:
             result = func.check_periodic(
-                API.confirmation_expression(get_projection_value_gui()), output_prompt_gui, accuracy
+                API.confirmation_expression(API.get_projection_value_gui()), API.output_prompt_gui, accuracy
             )
             if result[0]:
-                add_projection_box_gui(result[1])
-                output_prompt_gui("预测完成")
+                API.add_projection_box_gui(result[1])
+                API.output_prompt_gui("预测完成")
             else:
                 raise Exception
         except BaseException:
-            output_prompt_gui("预测失败")
+            API.output_prompt_gui("预测失败")
 
     @staticmethod
     def check_monotonic():
         accuracy = API.computing_gui()
         try:
             result = func.check_monotonic(
-                get_projection_value_gui(), output_prompt_gui, accuracy
+                API.get_projection_value_gui(), API.output_prompt_gui, accuracy
             )
             if result[1]:
-                add_projection_box_gui(result[1])
-                output_prompt_gui("预测完成")
+                API.add_projection_box_gui(result[1])
+                API.output_prompt_gui("预测完成")
             else:
                 raise Exception
         except BaseException:
-            output_prompt_gui("预测失败")
+            API.output_prompt_gui("预测失败")
 
     @staticmethod
     def clear_memory():
         try:
-            if askokcancel_gui(f"确定删除{func}的记忆吗?"):
-                update_result_box_gui([])
+            if API.askokcancel_gui(f"确定删除{func}的记忆吗?"):
+                API.update_result_box_gui([])
                 func.clean_memory()
-                output_prompt_gui("删除完毕")
+                API.output_prompt_gui("删除完毕")
             else:
-                output_prompt_gui("删除取消")
+                API.output_prompt_gui("删除取消")
         except BaseException:
-            output_prompt_gui("删除失败")
+            API.output_prompt_gui("删除失败")
 
     @staticmethod
     def show_hidden_memory():  # 显示xy
         try:
-            update_result_box_gui([])
+            API.update_result_box_gui([])
             func.hide_or_show()
-            output_prompt_gui("已清空卡槽")
+            API.output_prompt_gui("已清空卡槽")
         except BaseException:
-            output_prompt_gui("隐藏(显示)失败")
+            API.output_prompt_gui("隐藏(显示)失败")
 
     @staticmethod
     def gradient_method_calculation():
         try:
-            output_prompt_gui("计算过程程序可能无响应")
+            API.output_prompt_gui("计算过程程序可能无响应")
             parameters = []
             for i in gradient_parameters:
                 parameters.append(i.get())
-            output_prompt_gui("系统运算中")
-            answer = func.gradient_calculation(get_y_value_gradient_gui(), *parameters)
+            API.output_prompt_gui("系统运算中")
+            answer = func.gradient_calculation(API.get_y_value_gradient_gui(), *parameters)
             if answer[1] is not None:
-                update_result_box_gui(answer[0])
-                output_prompt_gui("系统运算完成")
+                API.update_result_box_gui(answer[0])
+                API.output_prompt_gui("系统运算完成")
             else:
-                output_prompt_gui("系统运算无结果")
+                API.output_prompt_gui("系统运算无结果")
         except BaseException:
-            output_prompt_gui("系统运算失败,请注意参数设置")
+            API.output_prompt_gui("系统运算失败,请注意参数设置")
 
     @staticmethod
     def calculate():
         try:
-            output_prompt_gui("计算过程程序可能无响应")
-            answer = func.calculation(get_x_value_gui())
+            API.output_prompt_gui("计算过程程序可能无响应")
+            answer = func.calculation(API.get_x_value_gui())
             if answer != []:
-                output_prompt_gui("系统运算完毕")
+                API.output_prompt_gui("系统运算完毕")
             else:
-                output_prompt_gui("系统运算无结果")
-            update_result_box_gui(answer)
+                API.output_prompt_gui("系统运算无结果")
+            API.update_result_box_gui(answer)
         except BaseException:
-            output_prompt_gui("计算失败")
+            API.output_prompt_gui("计算失败")
             # raise
 
     @staticmethod
     def sympy_calculation_x():
         try:
-            output_prompt_gui("计算过程程序可能无响应")
+            API.output_prompt_gui("计算过程程序可能无响应")
             answer = []
-            for i in get_y_value_symbol_gui():
+            for i in API.get_y_value_symbol_gui():
                 answer += func.sympy_calculation(i)[0]
             if answer:
-                output_prompt_gui("系统运算完毕")
+                API.output_prompt_gui("系统运算完毕")
             else:
-                output_prompt_gui("系统运算无结果")
-            update_result_box_gui(answer)
+                API.output_prompt_gui("系统运算无结果")
+            API.update_result_box_gui(answer)
         except BaseException:
-            output_prompt_gui("计算失败")
+            API.output_prompt_gui("计算失败")
 
     @staticmethod
     def function_differentiation():
         try:
-            output_prompt_gui("计算过程程序可能无响应")
-            accuracy = get_proximity_accuracy_gui()
+            API.output_prompt_gui("计算过程程序可能无响应")
+            accuracy = API.get_proximity_accuracy_gui()
             answer = []
-            for i in get_x_value_derivation_gui():
+            for i in API.get_x_value_derivation_gui():
                 get = func.derivative(i, accuracy)[0]
                 if get is not None:
                     answer.append(get)
             if answer != []:
-                output_prompt_gui("系统运算完毕")
+                API.output_prompt_gui("系统运算完毕")
             else:
-                output_prompt_gui("系统运算无结果")
-            update_result_box_gui(answer)
+                API.output_prompt_gui("系统运算无结果")
+            API.update_result_box_gui(answer)
         except IndexError:
-            output_prompt_gui("计算失败")
+            API.output_prompt_gui("计算失败")
 
     @staticmethod
     def approximation():  # 逼近法
         try:
-            output_prompt_gui("计算过程程序可能无响应")
-            accuracy = get_proximity_accuracy_gui()
+            API.output_prompt_gui("计算过程程序可能无响应")
+            accuracy = API.get_proximity_accuracy_gui()
             answer = []
-            for i in get_x_value_derivation_gui():
+            for i in API.get_x_value_derivation_gui():
                 get = func.derivative(i, accuracy, True)[0]
                 if get is not None:
                     answer.append(get)
             if answer:
-                output_prompt_gui("系统运算完毕")
+                API.output_prompt_gui("系统运算完毕")
             else:
-                output_prompt_gui("系统运算无结果")
-            update_result_box_gui(answer)
+                API.output_prompt_gui("系统运算无结果")
+            API.update_result_box_gui(answer)
         except IndexError:
-            output_prompt_gui("计算失败")
+            API.output_prompt_gui("计算失败")
 
     @staticmethod
     def dichotomy():  # 二分法
         global dicon_parameters, func, result_box
         try:
-            output_prompt_gui("计算过程程序可能无响应")
+            API.output_prompt_gui("计算过程程序可能无响应")
             answer = []
-            output_prompt_gui("系统运算中")
-            for i in get_y_value_gui():
+            API.output_prompt_gui("系统运算中")
+            for i in API.get_y_value_gui():
                 print(i)
                 try:
-                    answer += func.dichotomy(float(i), *dichotomy_gui())[0]
+                    answer += func.dichotomy(float(i), *API.dichotomy_gui())[0]
                 except BaseException:
                     pass
             if answer:
-                output_prompt_gui("系统运算完成")
+                API.output_prompt_gui("系统运算完成")
             else:
-                output_prompt_gui("系统运算无结果")
-            update_result_box_gui(answer)
+                API.output_prompt_gui("系统运算无结果")
+            API.update_result_box_gui(answer)
         except BaseException:
             # raise
-            output_prompt_gui("系统运算失败")
+            API.output_prompt_gui("系统运算失败")
 
     @staticmethod
     def property_prediction():
         try:
             accuracy = API.computing_gui()
-            output_prompt_gui("预测过程程序可能无响应")
-            answer = func.property_prediction(output_prompt_gui, True, accuracy)
-            update_prediction_box_gui(*answer)
-            output_prompt_gui("性质预测完成")
+            API.output_prompt_gui("预测过程程序可能无响应")
+            answer = func.property_prediction(API.output_prompt_gui, True, accuracy)
+            API.update_prediction_box_gui(*answer)
+            API.output_prompt_gui("性质预测完成")
         except IndexError:
-            output_prompt_gui("性质预测失败")
+            API.output_prompt_gui("性质预测失败")
 
     @staticmethod
     def function_drawing():
@@ -464,7 +465,7 @@ class API:
         except BaseException:
             draw_type = 0
         # 画板创造
-        output_prompt_gui("生成绘制取...")
+        API.output_prompt_gui("生成绘制取...")
         fig = plt.figure(num="CoTan函数")  # 定义一个图像窗口
         if draw_type in (0, 1, 2, 3, 8, 9):
             plt.grid(True, ls="--")  # 显示网格(不能放到后面,因为后面调整成为了笛卡尔坐标系)
@@ -594,7 +595,7 @@ class API:
 
         init()
         # 函数绘图系统
-        output_prompt_gui("图像绘制中...")
+        API.output_prompt_gui("图像绘制中...")
         if func is None:
             return False
         if draw_type in (0, 1, 4, 5):
@@ -723,7 +724,7 @@ class API:
             plot_x_len = len(all_func)
             m = []  # 每个群组中fx分类的个数
             for i in all_func:  # 预先生成函数
-                output_prompt_gui(f"迭代计算中...(共{plot_x_len}次)")
+                API.output_prompt_gui(f"迭代计算中...(共{plot_x_len}次)")
                 get = i.get_plot_data()
                 m.append(len(get[0]))
                 func_cul_list.append(get)
@@ -759,20 +760,20 @@ class API:
             FuncAnimation(
                 fig, update, frames=plot_x_len, init_func=_init, interval=frame, blit=False
             )  # 动态绘图
-        output_prompt_gui("绘制完毕")
+        API.output_prompt_gui("绘制完毕")
         plt.show()  # 显示图像
         return True
 
     @staticmethod
     def set_function():
         global func
-        default_value = set_func_gui()
+        default_value = API.set_func_gui()
         try:
             func = ExpFunc(*default_value, have_son=True)
-            output_prompt_gui("应用成功")
+            API.output_prompt_gui("应用成功")
             SCREEN.title(f"CoTan函数工厂  {func}")
         except BaseException:
-            output_prompt_gui("应用失败2")
+            API.output_prompt_gui("应用失败2")
             raise
 
 
@@ -1668,4 +1669,4 @@ sheet_box.grid(
     sticky=tkinter.S + tkinter.N + tkinter.E + tkinter.W,
 )
 
-output_prompt_gui("加载完毕")
+API.output_prompt_gui("加载完毕")

+ 179 - 179
funcsystem/map.py

@@ -4,7 +4,6 @@ import random
 import tkinter
 import tkinter.messagebox
 
-import numpy
 import pandas
 from matplotlib import pyplot as plt
 from matplotlib import rcParams
@@ -50,119 +49,120 @@ csv_list = []
 gui_width = 13  # 标准宽度
 gui_height = 2
 
+class UIAPI:
+    @staticmethod
+    def get_save_dir_gui():
+        return asksaveasfilename(title="选择导出位置", filetypes=[("CSV", ".csv")])
+
+    @staticmethod
+    def output_prompt_gui(news):
+        global prompt_box, prompt_num
+        prompt_num += 1
+        news = str(news)
+        prompt_box.insert(0, news + f"({prompt_num})")
+        SCREEN.update()
+
+    @staticmethod
+    def get_y_value_gradient_gui():
+        parameters = y_value_gradient.get().split("#")  # 拆解输入
+        return parameters
+
+    @staticmethod
+    def dichotomy_gui():
+        y = y_value.get().split(",")  # 拆解输入
+        parameters = dicon_parameters.get().split("#")  # 拆解输入
+        return parameters, y
+
+    @staticmethod
+    def get_func_exp_box_index_gui():
+        return func_exp_box.curselection()[0]
+
+    @staticmethod
+    def get_x_value_gui():
+        return x_value.get().split(",")
+
+    @staticmethod
+    def update_property_box_gui(answer):
+        property_box.delete(0, tkinter.END)
+        property_box.insert(tkinter.END, *answer)
+
+    @staticmethod
+    def update_result_box_gui(answer):
+        result_box.delete(0, tkinter.END)
+        result_box.insert(tkinter.END, *answer)
 
-def get_save_dir_gui():
-    return asksaveasfilename(title="选择导出位置", filetypes=[("CSV", ".csv")])
-
-
-def output_prompt_gui(news):
-    global prompt_box, prompt_num
-    prompt_num += 1
-    news = str(news)
-    prompt_box.insert(0, news + f"({prompt_num})")
-    SCREEN.update()
-
-
-def get_y_value_gradient_gui():
-    parameters = y_value_gradient.get().split("#")  # 拆解输入
-    return parameters
-
-
-def dichotomy_gui():
-    y = y_value.get().split(",")  # 拆解输入
-    parameters = dicon_parameters.get().split("#")  # 拆解输入
-    return parameters, y
-
-
-def get_func_exp_box_index_gui():
-    return func_exp_box.curselection()[0]
-
-
-def get_x_value_gui():
-    return x_value.get().split(",")
-
-
-def update_property_box_gui(answer):
-    property_box.delete(0, tkinter.END)
-    property_box.insert(tkinter.END, *answer)
-
-
-def update_result_box_gui(answer):
-    result_box.delete(0, tkinter.END)
-    result_box.insert(tkinter.END, *answer)
-
-
-def get_func_logger_gui():
-    return func_logger[func_exp_box.curselection()[0]]
-
-
-def add_func_gui():
-    get = func_exp.get().replace(" ", "")
-    definition = definition_domain.get().split(",")
-    name = func_name.get().replace(" ", "")
-    style_str = func_style.get().split("#")
-    if not name:
-        name = get
-    try:
-        if style_str[0] not in point_style:
-            style_str[0] = "b"
-        line_style_str = line_style.get(style_str[1], "-")
-    except BaseException:
-        style_str = ["", ""]
-        style_str[0] = random.choice(point_style)
-        line_style_str = "-"
-    style = style_str[0] + line_style_str
-    try:
-        span_str = definition[2]
-        if span_str.startswith("H"):
-            named_domain = {
-                "Pi": math.pi,
-                "e": math.e,
-                "log": math.log,
-                "sin": math.sin,
-                "cos": math.cos,
-                "tan": math.tan,
-                "cot": lambda x: 1 / math.tan(x),
-                "csc": lambda x: 1 / math.sin(x),
-                "sec": lambda x: 1 / math.cos(x),
-                "sinh": math.sinh,
-                "cosh": math.cosh,
-                "tanh": math.tanh,
-                "asin": math.asin,
-                "acos": math.acos,
-                "atan": math.atan,
-            }
-            definition[2] = eval(span_str[1:], named_domain)
-    except BaseException:
-        pass
-    return get, [name, style] + definition
-
-
-def update_func_exp_box_gui():
-    func_exp_box.delete(0, tkinter.END)
-    func_exp_box.insert(tkinter.END, *func_logger)
-
-
-def read_csv_gui():
-    file = askopenfilename(title="载入表格", filetypes=[("CSV", ".csv")])
-    style_str = func_style.get().split("#")
-    try:
-        if style_str[0] not in point_style:
-            style_str[0] = "b"
-        line_style_str = line_style.get(style_str[1], "-")
-    except BaseException:
-        style_str = ["", ""]
-        style_str[0] = random.choice(point_style)
-        line_style_str = "-"
-    style = style_str[0] + line_style_str
-    name = path.basename(file)[0:-4].replace(" ", "")
-    if not name:
-        name = random.randint(1, 1000)
-    name += "(In CSV)"
-    return pandas.read_csv(file).tolist(), name, style
-
-
-class API:
+    @staticmethod
+    def get_func_logger_gui():
+        return func_logger[func_exp_box.curselection()[0]]
+
+    @staticmethod
+    def add_func_gui():
+        get = func_exp.get().replace(" ", "")
+        definition = definition_domain.get().split(",")
+        name = func_name.get().replace(" ", "")
+        style_str = func_style.get().split("#")
+        if not name:
+            name = get
+        try:
+            if style_str[0] not in point_style:
+                style_str[0] = "b"
+            line_style_str = line_style.get(style_str[1], "-")
+        except BaseException:
+            style_str = ["", ""]
+            style_str[0] = random.choice(point_style)
+            line_style_str = "-"
+        style = style_str[0] + line_style_str
+        try:
+            span_str = definition[2]
+            if span_str.startswith("H"):
+                named_domain = {
+                    "Pi": math.pi,
+                    "e": math.e,
+                    "log": math.log,
+                    "sin": math.sin,
+                    "cos": math.cos,
+                    "tan": math.tan,
+                    "cot": lambda x: 1 / math.tan(x),
+                    "csc": lambda x: 1 / math.sin(x),
+                    "sec": lambda x: 1 / math.cos(x),
+                    "sinh": math.sinh,
+                    "cosh": math.cosh,
+                    "tanh": math.tanh,
+                    "asin": math.asin,
+                    "acos": math.acos,
+                    "atan": math.atan,
+                }
+                definition[2] = eval(span_str[1:], named_domain)
+        except BaseException:
+            pass
+        return get, [name, style] + definition
+
+    @staticmethod
+    def update_func_exp_box_gui():
+        func_exp_box.delete(0, tkinter.END)
+        func_exp_box.insert(tkinter.END, *func_logger)
+
+    @staticmethod
+    def read_csv_gui():
+        file = askopenfilename(title="载入表格", filetypes=[("CSV", ".csv")])
+        style_str = func_style.get().split("#")
+        try:
+            if style_str[0] not in point_style:
+                style_str[0] = "b"
+            line_style_str = line_style.get(style_str[1], "-")
+        except BaseException:
+            style_str = ["", ""]
+            style_str[0] = random.choice(point_style)
+            line_style_str = "-"
+        style = style_str[0] + line_style_str
+        name = path.basename(file)[0:-4].replace(" ", "")
+        if not name:
+            name = random.randint(1, 1000)
+        name += "(In CSV)"
+        return pandas.read_csv(file).tolist(), name, style
+
+
+class API(UIAPI):
     @staticmethod
     def type_selection(iter_object, si=float, no_zero=True):  # Float筛选系统
         x = []
@@ -179,7 +179,7 @@ class API:
     def plot_func():
         global func_logger, definition_domain, fig, x_limit, y_limit, y_axis, x_axis
         # 画板创造
-        output_prompt_gui("生成绘制取...")
+        API.output_prompt_gui("生成绘制取...")
         fig = plt.figure(num="CoTan函数")  # 定义一个图像窗口
         plt.grid(True, ls="--")  # 显示网格(不能放到后面,因为后面调整成为了笛卡尔坐标系)
         axis = plt.gca()
@@ -283,7 +283,7 @@ class API:
         plt.xlim(_x_limit)
         plt.ylim(_y_limit)
         # 函数绘图系统
-        output_prompt_gui("图像绘制中...")
+        API.output_prompt_gui("图像绘制中...")
         if not func_logger:
             return False
         for Fucn in func_logger:
@@ -358,33 +358,33 @@ class API:
                     last_x = now_x
             plt.plot(plot_min, [min_y] * len(plot_min), exp_style[0] + "o")  # 画出一些点
             plt.plot(plot_max, [max_y] * len(plot_max), exp_style[0] + "o")  # 画出一些点
-        output_prompt_gui("绘制完毕")
+        API.output_prompt_gui("绘制完毕")
         plt.legend()  # 显示图示
         plt.show()  # 显示图像
         return True
 
     @staticmethod
     def add_from_csv():  # 添加函数
-        file, name, style = read_csv_gui()
+        file, name, style = API.read_csv_gui()
         try:
-            output_prompt_gui("读取CSV")
+            API.output_prompt_gui("读取CSV")
             func_str_list.append(name)
             func_logger.append(SheetFunc(file, name, style))
-            update_func_exp_box_gui()
-            output_prompt_gui("读取完毕")
+            API.update_func_exp_box_gui()
+            API.output_prompt_gui("读取完毕")
         except BaseException:
-            output_prompt_gui("读取失败")
+            API.output_prompt_gui("读取失败")
 
     @staticmethod
     def add_func():  # 添加函数
-        get, definition = add_func_gui()
+        get, definition = API.add_func_gui()
         if get and get not in func_str_list:
             func_str_list.append(get)
             func_logger.append(ExpFunc(get, *definition))
-            update_func_exp_box_gui()
-            output_prompt_gui("函数生成完毕")
+            API.update_func_exp_box_gui()
+            API.output_prompt_gui("函数生成完毕")
         else:
-            output_prompt_gui("函数生成失败")
+            API.output_prompt_gui("函数生成失败")
 
     @staticmethod
     def clean_func_box():  # 添加函数
@@ -392,18 +392,18 @@ class API:
         if API.show_askokcancel("是否清空所有函数?)"):
             func_str_list = []
             func_logger = []
-            update_func_exp_box_gui()
-            output_prompt_gui("函数清空完毕")
+            API.update_func_exp_box_gui()
+            API.output_prompt_gui("函数清空完毕")
 
     @staticmethod
     def func_to_sheet_gui():  # 显示xy
         try:
-            func = get_func_logger_gui()
+            func = API.get_func_logger_gui()
             sheet_box.delete(0, tkinter.END)
             sheet_box.insert(tkinter.END, *func.return_list())
-            output_prompt_gui("表格创建成功")
+            API.output_prompt_gui("表格创建成功")
         except BaseException:
-            output_prompt_gui("无法创建表格")
+            API.output_prompt_gui("无法创建表格")
             pass
 
     @staticmethod
@@ -415,111 +415,111 @@ class API:
         global x_value, func_exp_box, func_logger
         try:
             if API.show_askokcancel(f"确定删除{func_logger[func_exp_box.curselection()[0]]}的记忆吗?"):
-                get_func_logger_gui().clean_memory()
-                update_result_box_gui([])
-                output_prompt_gui("删除完毕")
+                API.get_func_logger_gui().clean_memory()
+                API.update_result_box_gui([])
+                API.output_prompt_gui("删除完毕")
             else:
-                output_prompt_gui("删除取消")
+                API.output_prompt_gui("删除取消")
         except BaseException:
-            output_prompt_gui("删除失败")
+            API.output_prompt_gui("删除失败")
 
     @staticmethod
     def hide_memory():  # 显示xy
         global func_logger, result_box
         try:
-            get_func_logger_gui().hide_or_show()
-            update_result_box_gui([])
-            output_prompt_gui("已清空卡槽")
+            API.get_func_logger_gui().hide_or_show()
+            API.update_result_box_gui([])
+            API.output_prompt_gui("已清空卡槽")
         except BaseException:
-            output_prompt_gui("隐藏(显示)失败")
+            API.output_prompt_gui("隐藏(显示)失败")
 
     @staticmethod
     def show_memory():  # 显示xy
         global func_logger, result_box
         try:
             answer = []
-            for i in zip(get_func_logger_gui().get_memory()):
+            for i in zip(API.get_func_logger_gui().get_memory()):
                 answer.append(f"x={i[0]} -> y={i[1]}")
-            update_result_box_gui(answer)
-            output_prompt_gui("输出完成")
+            API.update_result_box_gui(answer)
+            API.output_prompt_gui("输出完成")
         except BaseException:
-            output_prompt_gui("操作失败")
+            API.output_prompt_gui("操作失败")
 
     @staticmethod
     def property_prediction():
         try:
-            output_prompt_gui("预测过程程序可能无响应")
-            answer = get_func_logger_gui().property_prediction(output_prompt_gui)
-            update_property_box_gui(answer)
-            output_prompt_gui("性质预测完成")
+            API.output_prompt_gui("预测过程程序可能无响应")
+            answer = API.get_func_logger_gui().property_prediction(API.output_prompt_gui)
+            API.update_property_box_gui(answer)
+            API.output_prompt_gui("性质预测完成")
         except IndexError:
-            output_prompt_gui("性质预测失败")
+            API.output_prompt_gui("性质预测失败")
 
     @staticmethod
     def calculate():
         global func_logger, result_box, x_value
         try:
-            output_prompt_gui("计算过程程序可能无响应")
-            answer = get_func_logger_gui().calculation(get_x_value_gui())
-            update_result_box_gui(answer)
-            output_prompt_gui("系统计算完毕")
+            API.output_prompt_gui("计算过程程序可能无响应")
+            answer = API.get_func_logger_gui().calculation(API.get_x_value_gui())
+            API.update_result_box_gui(answer)
+            API.output_prompt_gui("系统计算完毕")
         except IndexError:
-            output_prompt_gui("计算失败")
+            API.output_prompt_gui("计算失败")
 
     @staticmethod
     def func_to_csv():  # 导出CSV
         global csv_list
         try:
-            get_func_logger_gui().save_csv(get_save_dir_gui())
-            output_prompt_gui("CSV导出成功")
+            API.get_func_logger_gui().save_csv(API.get_save_dir_gui())
+            API.output_prompt_gui("CSV导出成功")
         except BaseException:
-            output_prompt_gui("CSV导出失败")
+            API.output_prompt_gui("CSV导出失败")
 
     @staticmethod
     def del_func():  # 删除函数
         global func_logger, func_str_list, func_exp_box
-        del_index = get_func_exp_box_index_gui()
+        del_index = API.get_func_exp_box_index_gui()
         del func_logger[del_index]
         del func_str_list[del_index]
-        update_func_exp_box_gui()
-        output_prompt_gui("函数删除完毕")
+        API.update_func_exp_box_gui()
+        API.output_prompt_gui("函数删除完毕")
 
     @staticmethod
     def dichotomy():
         try:
-            output_prompt_gui("计算过程程序可能无响应")
-            parameters, y = dichotomy_gui()
+            API.output_prompt_gui("计算过程程序可能无响应")
+            parameters, y = API.dichotomy_gui()
             answer = []
-            output_prompt_gui("系统运算中")
+            API.output_prompt_gui("系统运算中")
             for i in y:
-                answer += get_func_logger_gui().dichotomy(float(i), *parameters)[0]
+                answer += API.get_func_logger_gui().dichotomy(float(i), *parameters)[0]
             if answer:
-                output_prompt_gui("系统运算完成")
+                API.output_prompt_gui("系统运算完成")
             else:
-                output_prompt_gui("系统运算无结果")
-            update_result_box_gui(answer)
+                API.output_prompt_gui("系统运算无结果")
+            API.update_result_box_gui(answer)
         except BaseException:
-            output_prompt_gui("系统运算失败")
+            API.output_prompt_gui("系统运算失败")
 
     @staticmethod
     def gradient_method_calculation():
         try:
-            output_prompt_gui("计算过程程序可能无响应")
-            output_prompt_gui("系统运算中")
-            answer = get_func_logger_gui().gradient_calculation(*get_y_value_gradient_gui())
+            API.output_prompt_gui("计算过程程序可能无响应")
+            API.output_prompt_gui("系统运算中")
+            answer = API.get_func_logger_gui().gradient_calculation(*API.get_y_value_gradient_gui())
             if answer[1]:
-                output_prompt_gui("系统运算完成")
+                API.output_prompt_gui("系统运算完成")
             else:
-                output_prompt_gui("系统运算无结果")
-            update_result_box_gui(answer)
+                API.output_prompt_gui("系统运算无结果")
+            API.update_result_box_gui(answer)
         except BaseException:
-            output_prompt_gui("系统运算失败,请注意参数设置")
+            API.output_prompt_gui("系统运算失败,请注意参数设置")
 
     @staticmethod
     def func_differentiation():
         global func_logger, func_exp_box, property_box, func_str_list, func_name, line_style, point_style, func_style
         try:
-            fucn = get_func_logger_gui()
+            fucn = API.get_func_logger_gui()
             diff = fucn.derivatives
             if diff is not None and str(diff):
                 get = str(diff)
@@ -535,12 +535,12 @@ class API:
                         fucn.accuracy,
                     )
                 )
-                update_func_exp_box_gui()
-                output_prompt_gui("函数生成完毕")
+                API.update_func_exp_box_gui()
+                API.output_prompt_gui("函数生成完毕")
             else:
                 raise Exception
         except BaseException:
-            output_prompt_gui("导函数创建失败")
+            API.output_prompt_gui("导函数创建失败")
 
 
 def function_mapping():
@@ -965,4 +965,4 @@ sheet_box.grid(
     sticky=tkinter.S + tkinter.N + tkinter.E + tkinter.W,
 )
 
-output_prompt_gui("加载完成,欢迎使用!")
+API.output_prompt_gui("加载完成,欢迎使用!")

+ 124 - 124
gitrepo/gui.py

@@ -81,7 +81,7 @@ class UIAPI:
         data = ""
         out_data = ""  # 包含out的data
         if show_screen:
-            text, cli_screen, button_list = UIAPI.show_cli_gui(
+            text, cli_screen, button_list = API.show_cli_gui(
                 save_to_txt, stop, keep, format, pipe, name=name
             )  # [close,keep]
             update_button()
@@ -91,7 +91,7 @@ class UIAPI:
                 data += f"{tip_text}\n"
             cli_screen.update()
         else:
-            u = threading.Thread(target=UIAPI.progress_bar_gui)
+            u = threading.Thread(target=API.progress_bar_gui)
             u.start()
         SCREEN.update()
 
@@ -140,7 +140,7 @@ class UIAPI:
                     try:  # 如果界面被关掉了,会报错
                         cli_screen.title(f"{name} : 运行中")
                     except BaseException:
-                        text, cli_screen, button_list = UIAPI.show_cli_gui(
+                        text, cli_screen, button_list = API.show_cli_gui(
                             save_to_txt, stop, keep, format, pipe, name=f"{name} : 运行中"
                         )
                         update_button()
@@ -163,7 +163,7 @@ class UIAPI:
                     if show_screen:
                         cli_screen.title(f"{name} : 运行中")
                 except BaseException:
-                    text, cli_screen, button_list = UIAPI.show_cli_gui(
+                    text, cli_screen, button_list = API.show_cli_gui(
                         save_to_txt, stop, keep, format, pipe, name=f"{name} : 运行中"
                     )
                     update_button()
@@ -368,12 +368,12 @@ class UIAPI:
         global last_name
         if last_name is None:
             return False
-        UIAPI.update_git_file_gui(last_name)
+        API.update_git_file_gui(last_name)
 
     @staticmethod
     def update_git_file_select_gui():
-        name = UIAPI.get_repo_name_gui()
-        UIAPI.update_git_file_gui(name)
+        name = API.get_repo_name_gui()
+        API.update_git_file_gui(name)
 
     @staticmethod
     def update_git_file_gui(name):
@@ -392,7 +392,7 @@ class UIAPI:
         new_file = set(askopenfilenames(title=f"选择文件"))
         have_file = set(file_list)
         file_list += list(new_file - (new_file & have_file))  # 筛选出重复
-        UIAPI.update_file_box_gui()
+        API.update_file_box_gui()
 
     @staticmethod
     def add_file_input_dir_gui():
@@ -400,18 +400,18 @@ class UIAPI:
         new_dir = file_dir.get()
         if new_dir.replace(" ", "") != "" and new_dir not in file_list:
             file_list.append(new_dir)
-        UIAPI.update_file_box_gui()
+        API.update_file_box_gui()
 
     @staticmethod
     def add_file_by_git_gui():
         global file_dir
         new_dir = file_dir.get()
         if new_dir.replace(" ", "") != "":
-            name = UIAPI.get_repo_name_gui()
+            name = API.get_repo_name_gui()
             new_dir = git.make_dir(name, new_dir)
             if new_dir not in file_list:
                 file_list.append(new_dir)
-        UIAPI.update_file_box_gui()
+        API.update_file_box_gui()
 
     @staticmethod
     def diff_gui():
@@ -452,7 +452,7 @@ class UIAPI:
 
     @staticmethod
     def add_new_branch_gui():
-        name = UIAPI.get_branch_name_gui()
+        name = API.get_branch_name_gui()
         origin = origin_branch.get()
         return name, origin
 
@@ -465,7 +465,7 @@ class UIAPI:
                 "警告!", "非常遗憾,我不同意你commit而不添加任何描述!\n描述是很重要的!" "(如果你不想添加描述,请使用快速合并,但我并不建议!)"
             )
             raise Exception
-        name = UIAPI.get_branch_name_gui()
+        name = API.get_branch_name_gui()
         return message, name, parameters_no_ff
 
     @staticmethod
@@ -568,26 +568,26 @@ class UIAPI:
     @staticmethod
     def branch_new_gui():
         new_name = branch_new_name.get()
-        old_name = UIAPI.get_branch_name_gui()
+        old_name = API.get_branch_name_gui()
         return new_name, old_name
 
 
-class API:
+class API(UIAPI):
     @staticmethod
     def branch_new():  # 克隆仓库
-        new_name, old_name = UIAPI.branch_new_gui()
-        UIAPI.cli_gui(git.rename_branch, (UIAPI.get_repo_name_gui(), old_name, new_name), show_screen=False)
-        UIAPI.update_repo_box_gui()
+        new_name, old_name = API.branch_new_gui()
+        API.cli_gui(git.rename_branch, (API.get_repo_name_gui(), old_name, new_name), show_screen=False)
+        API.update_repo_box_gui()
 
     @staticmethod
     def clone_git():  # 克隆仓库
-        name = UIAPI.clone_git_gui()
+        name = API.clone_git_gui()
         API.clone_core(name, clone_repo.get())
-        UIAPI.update_repo_box_gui()
+        API.update_repo_box_gui()
 
     @staticmethod
     def clone_core(name, url):
-        UIAPI.cli_gui(
+        API.cli_gui(
             git.clone,
             (name, url),
             break_time=0,
@@ -596,235 +596,235 @@ class API:
             is_asynchronous_display=True,
         )
         git.after_clone(name)
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def customize():
-        command, is_asynchronous_display, is_threaded_refresh = UIAPI.get_customize_gui()
-        UIAPI.cli_gui(
+        command, is_asynchronous_display, is_threaded_refresh = API.get_customize_gui()
+        API.cli_gui(
             git.customize_command,
-            (UIAPI.get_repo_name_gui(), command),
+            (API.get_repo_name_gui(), command),
             break_time=0,
             tip_text=f"{command}:操作进行中",
             is_threaded_refresh=is_threaded_refresh,
             is_asynchronous_display=is_asynchronous_display,
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def fetch_remote():
-        branch, local, remote = UIAPI.featch_remote_gui()
-        UIAPI.cli_gui(
+        branch, local, remote = API.featch_remote_gui()
+        API.cli_gui(
             git.fetch,
-            (UIAPI.get_repo_name_gui(), local, remote, branch),
+            (API.get_repo_name_gui(), local, remote, branch),
             break_time=0,
             tip_text=f"此操作需要连接远程仓库,请稍等...",
             is_threaded_refresh=True,
             is_asynchronous_display=True,
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def del_tag():
-        tag = UIAPI.del_tag_gui()
-        UIAPI.cli_gui(git.del_tag, (UIAPI.get_repo_name_gui(), tag))
-        UIAPI.update_git_file_last_gui()
+        tag = API.del_tag_gui()
+        API.cli_gui(git.del_tag, (API.get_repo_name_gui(), tag))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def del_remote_branch():
-        branch, remote = UIAPI.del_remote_branch_gui()
-        UIAPI.cli_gui(
+        branch, remote = API.del_remote_branch_gui()
+        API.cli_gui(
             git.del_branch_remote,
-            (UIAPI.get_repo_name_gui(), remote, branch),
+            (API.get_repo_name_gui(), remote, branch),
             break_time=0,
             tip_text=f"此操作需要连接远程仓库,请稍等...",
             is_threaded_refresh=True,
             is_asynchronous_display=True,
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def del_remote_tag():
-        remoto, tag = UIAPI.del_remote_tag_gui()
-        UIAPI.cli_gui(
+        remoto, tag = API.del_remote_tag_gui()
+        API.cli_gui(
             git.del_tag_remote,
-            (UIAPI.get_repo_name_gui(), remoto, tag),
+            (API.get_repo_name_gui(), remoto, tag),
             break_time=0,
             tip_text=f"此操作需要连接远程仓库,请稍等...",
             is_threaded_refresh=True,
             is_asynchronous_display=True,
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def push_all_tag():
-        remoto = UIAPI.get_remote_name_gui()
-        UIAPI.cli_gui(
+        remoto = API.get_remote_name_gui()
+        API.cli_gui(
             git.push_all_tag,
-            (UIAPI.get_repo_name_gui(), remoto),
+            (API.get_repo_name_gui(), remoto),
             break_time=0,
             tip_text=f"此操作需要连接远程仓库,请稍等...",
             is_threaded_refresh=True,
             is_asynchronous_display=True,
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def push_tag():
-        remoto, the_tag_name = UIAPI.push_tag_gui()
-        UIAPI.cli_gui(
+        remoto, the_tag_name = API.push_tag_gui()
+        API.cli_gui(
             git.push_tag,
-            (UIAPI.get_repo_name_gui(), the_tag_name, remoto),
+            (API.get_repo_name_gui(), the_tag_name, remoto),
             break_time=0,
             tip_text=f"此操作需要连接远程仓库,请稍等...",
             is_threaded_refresh=True,
             is_asynchronous_display=True,
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def add_tag():
-        the_tag_name, the_commit, the_tag_message = UIAPI.add_tag_gui()
-        UIAPI.cli_gui(
-            git.add_tag, (UIAPI.get_repo_name_gui(), the_tag_name, the_commit, the_tag_message), show_screen=False
+        the_tag_name, the_commit, the_tag_message = API.add_tag_gui()
+        API.cli_gui(
+            git.add_tag, (API.get_repo_name_gui(), the_tag_name, the_commit, the_tag_message), show_screen=False
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def show_tag(type_):
         global git
-        key = UIAPI.get_search_key_gui()
-        UIAPI.cli_gui(
+        key = API.get_search_key_gui()
+        API.cli_gui(
             {1: git.get_tag_list, 0: git.search_commit}.get(type_, git.search_commit),
-            (UIAPI.get_repo_name_gui(), key),
+            (API.get_repo_name_gui(), key),
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def pull_push_remote(type_):
-        allow, branch, local, parameters_f, parameters_u, remote = UIAPI.pull_push_gui()
-        UIAPI.cli_gui(
+        allow, branch, local, parameters_f, parameters_u, remote = API.pull_push_gui()
+        API.cli_gui(
             {0: git.pull_from_remote, 1: git.push_to_remote}.get(
                 type_, git.pull_from_remote
             ),
-            (UIAPI.get_repo_name_gui(), local, remote, branch, allow, parameters_u, parameters_f),
+            (API.get_repo_name_gui(), local, remote, branch, allow, parameters_u, parameters_f),
             break_time=0,
             tip_text=f"此操作需要连接远程仓库,请稍等...",
             is_threaded_refresh=True,
             is_asynchronous_display=True,
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def bind_remote_branch():
-        local, remote = UIAPI.bind_remote_branch_gui()
-        UIAPI.cli_gui(git.bind_branch, (UIAPI.get_repo_name_gui(), local, remote))
-        UIAPI.update_git_file_last_gui()
+        local, remote = API.bind_remote_branch_gui()
+        API.cli_gui(git.bind_branch, (API.get_repo_name_gui(), local, remote))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def del_remote():
-        name = UIAPI.del_remote_gui()
-        UIAPI.cli_gui(git.del_remote, (UIAPI.get_repo_name_gui(), name))
-        UIAPI.update_git_file_last_gui()
+        name = API.del_remote_gui()
+        API.cli_gui(git.del_remote, (API.get_repo_name_gui(), name))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def add_remote():
-        name, ssh = UIAPI.add_remote_gui()
-        UIAPI.cli_gui(git.remote_add, (UIAPI.get_repo_name_gui(), ssh, name))
-        UIAPI.update_git_file_last_gui()
+        name, ssh = API.add_remote_gui()
+        API.cli_gui(git.remote_add, (API.get_repo_name_gui(), ssh, name))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def cherry_pick():
-        the_commit = UIAPI.get_commit_id_gui()
-        UIAPI.cli_gui(git.cherry_pick, (UIAPI.get_repo_name_gui(), the_commit))
-        UIAPI.update_git_file_last_gui()
+        the_commit = API.get_commit_id_gui()
+        API.cli_gui(git.cherry_pick, (API.get_repo_name_gui(), the_commit))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def open_stash(type_):
-        stash_num = UIAPI.get_stash_gui()
+        stash_num = API.get_stash_gui()
         if stash_num == "":
             stash_num = "0"
-        UIAPI.cli_gui([git.drop_stash, git.apply_stash][type_], (UIAPI.get_repo_name_gui(), stash_num))
-        UIAPI.update_git_file_last_gui()
+        API.cli_gui([git.drop_stash, git.apply_stash][type_], (API.get_repo_name_gui(), stash_num))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def branch_merge():
-        message, name, parameters_no_ff = UIAPI.branch_merge_gui()
-        UIAPI.cli_gui(git.merge_branch, (UIAPI.get_repo_name_gui(), name, parameters_no_ff, message))
-        UIAPI.update_git_file_last_gui()
+        message, name, parameters_no_ff = API.branch_merge_gui()
+        API.cli_gui(git.merge_branch, (API.get_repo_name_gui(), name, parameters_no_ff, message))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def del_branch(type_):
-        name = UIAPI.get_branch_name_gui()
-        UIAPI.cli_gui(git.del_branch, (UIAPI.get_repo_name_gui(), name, type_))
-        UIAPI.update_git_file_last_gui()
+        name = API.get_branch_name_gui()
+        API.cli_gui(git.del_branch, (API.get_repo_name_gui(), name, type_))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def switch_branch():
-        name = UIAPI.get_branch_name_gui()
-        UIAPI.cli_gui(git.switch_branch, (UIAPI.get_repo_name_gui(), name), break_time=1, show_screen=False)
-        UIAPI.update_git_file_last_gui()
+        name = API.get_branch_name_gui()
+        API.cli_gui(git.switch_branch, (API.get_repo_name_gui(), name), break_time=1, show_screen=False)
+        API.update_git_file_last_gui()
 
     @staticmethod
     def add_new_branch():
-        name, origin = UIAPI.add_new_branch_gui()
-        UIAPI.cli_gui(
-            git.new_branch, (UIAPI.get_repo_name_gui(), name, origin), break_time=1, show_screen=False
+        name, origin = API.add_new_branch_gui()
+        API.cli_gui(
+            git.new_branch, (API.get_repo_name_gui(), name, origin), break_time=1, show_screen=False
         )
-        UIAPI.update_git_file_last_gui()
+        API.update_git_file_last_gui()
 
     @staticmethod
     def remove_file():
         if file_list == []:
             return False
-        UIAPI.cli_gui(git.rm, (UIAPI.get_repo_name_gui(), file_list))
-        UIAPI.update_git_file_last_gui()
+        API.cli_gui(git.rm, (API.get_repo_name_gui(), file_list))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def checkout_file():  # 从暂存区、仓库返回文件
         if file_list == []:
             return False
-        UIAPI.cli_gui(git.checkout_version, (UIAPI.get_repo_name_gui(), file_list))
-        UIAPI.update_git_file_last_gui()
+        API.cli_gui(git.checkout_version, (API.get_repo_name_gui(), file_list))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def reset_file():  # 使用reset回退文件
-        repo_head = UIAPI.reset_file_gui()
-        UIAPI.cli_gui(git.back_version_file, (UIAPI.get_repo_name_gui(), repo_head, file_list))
-        UIAPI.update_git_file_last_gui()
+        repo_head = API.reset_file_gui()
+        API.cli_gui(git.back_version_file, (API.get_repo_name_gui(), repo_head, file_list))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def reset_head():
-        repo_head, the_reset_type = UIAPI.reset_head_gui()
-        UIAPI.cli_gui(git.back_version, (UIAPI.get_repo_name_gui(), repo_head, the_reset_type))
-        UIAPI.update_git_file_last_gui()
+        repo_head, the_reset_type = API.reset_head_gui()
+        API.cli_gui(git.back_version, (API.get_repo_name_gui(), repo_head, the_reset_type))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def log():
         global git, log_type
-        name = UIAPI.get_repo_name_gui()
-        abbrev, graph, pretty = UIAPI.log_gui(log_type)
-        UIAPI.cli_gui(git.log, (name, graph, pretty, abbrev))
-        UIAPI.update_git_file_last_gui()
+        name = API.get_repo_name_gui()
+        abbrev, graph, pretty = API.log_gui(log_type)
+        API.cli_gui(git.log, (name, graph, pretty, abbrev))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def not_parameters_call(func):
         global git
-        name = UIAPI.get_repo_name_gui()
-        UIAPI.cli_gui(func, (name,))
-        UIAPI.update_git_file_last_gui()
+        name = API.get_repo_name_gui()
+        API.cli_gui(func, (name,))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def commit_file():
-        name = UIAPI.get_repo_name_gui()
-        UIAPI.cli_gui(git.commit_file, (name, UIAPI.commit_file_gui()))
-        UIAPI.update_git_file_last_gui()
+        name = API.get_repo_name_gui()
+        API.cli_gui(git.commit_file, (name, API.commit_file_gui()))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def diff():
-        branch = UIAPI.diff_gui()
-        UIAPI.cli_gui(git.diff_file, (UIAPI.get_repo_name_gui(), branch))
-        UIAPI.update_git_file_last_gui()
+        branch = API.diff_gui()
+        API.cli_gui(git.diff_file, (API.get_repo_name_gui(), branch))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def remove_the_staging():
@@ -832,16 +832,16 @@ class API:
         dic = file_list
         if dic == []:
             dic = "."
-        UIAPI.cli_gui(git.reset_file, (UIAPI.get_repo_name_gui(), dic))
-        UIAPI.update_git_file_last_gui()
+        API.cli_gui(git.reset_file, (API.get_repo_name_gui(), dic))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def add():
         dic = file_list
         if dic == []:
             dic = "."  # 查一下取消的dic
-        UIAPI.cli_gui(git.add_file, (UIAPI.get_repo_name_gui(), dic))
-        UIAPI.update_git_file_last_gui()
+        API.cli_gui(git.add_file, (API.get_repo_name_gui(), dic))
+        API.update_git_file_last_gui()
 
     @staticmethod
     def get_file_box_index():
@@ -851,7 +851,7 @@ class API:
     def del_file():
         try:
             del file_list[API.get_file_box_index()]
-            UIAPI.update_file_box_gui()
+            API.update_file_box_gui()
         except BaseException:
             pass
 
@@ -859,14 +859,14 @@ class API:
     def clean_file():
         global file_list
         file_list = []
-        UIAPI.update_file_box_gui()
+        API.update_file_box_gui()
 
     @staticmethod
     def repo_init():  # 创建仓库
         global git
-        new_dir = UIAPI.repo_init_gui()
+        new_dir = API.repo_init_gui()
         git.open_repo(new_dir)
-        UIAPI.update_repo_box_gui()
+        API.update_repo_box_gui()
 
 
 def git_main():
@@ -919,7 +919,7 @@ tkinter.Button(
     bg=buttom_color,
     fg=word_color,
     text="查看文件",
-    command=UIAPI.update_git_file_select_gui,
+    command=API.update_git_file_select_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1005,7 +1005,7 @@ tkinter.Button(
     bg=buttom_color,
     fg=word_color,
     text="填充路径并添加",
-    command=UIAPI.add_file_by_git_gui,
+    command=API.add_file_by_git_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1015,7 +1015,7 @@ tkinter.Button(
     bg=buttom_color,
     fg=word_color,
     text="直接添加",
-    command=UIAPI.add_file_input_dir_gui,
+    command=API.add_file_input_dir_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1025,7 +1025,7 @@ tkinter.Button(
     bg=buttom_color,
     fg=word_color,
     text="选择文件",
-    command=UIAPI.add_file_list_gui,
+    command=API.add_file_list_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,

+ 80 - 80
machinelearning/gui.py

@@ -112,7 +112,7 @@ class UIAPI:
     def to_csv_gui():
         save_dir = asksaveasfilename(title="选择保存的CSV", filetypes=[("CSV", ".csv")])
         csv_sep = sep.get()
-        name = UIAPI.get_data_name_gui()
+        name = API.get_data_name_gui()
         return save_dir, name, csv_sep
 
     @staticmethod
@@ -125,17 +125,17 @@ class UIAPI:
     @staticmethod
     def set_x_data_gui():
         global x_data
-        x_data.set(UIAPI.get_data_name_gui())
+        x_data.set(API.get_data_name_gui())
 
     @staticmethod
     def set_y_data_gui():
         global y_data
-        y_data.set(UIAPI.get_data_name_gui())
+        y_data.set(API.get_data_name_gui())
 
     @staticmethod
     def set_learner_gui():
         global learner_output
-        learner_output.set(UIAPI.get_learner_gui(True))
+        learner_output.set(API.get_learner_gui(True))
 
     @staticmethod
     def get_learner_gui(return_box=False):
@@ -147,7 +147,7 @@ class UIAPI:
                 try:
                     return list(learn_dict.keys)[0]
                 except BaseException:
-                    return UIAPI.get_learner_gui(False)
+                    return API.get_learner_gui(False)
         else:
             try:
                 return learner_output.get()
@@ -208,7 +208,7 @@ class UIAPI:
         return calculation_type.get()
 
 
-class API:
+class API(UIAPI):
     @staticmethod
     def add_reverse_fast_fourier2():  # 添加Lenear的核心
         API.add_leaner("[2]Reverse_Fast_Fourier")
@@ -226,7 +226,7 @@ class API:
         file_dir = askopenfilename(title="导入参数")
         with open(file_dir, "r") as f:
             learner_controller.add_curve_fitting(f.read())
-            UIAPI.update_leaner_gui()
+            API.update_leaner_gui()
 
     @staticmethod
     def show_clustering_score():
@@ -242,28 +242,28 @@ class API:
 
     @staticmethod
     def show_score(func):
-        learner = UIAPI.get_learner_gui(True)
+        learner = API.get_learner_gui(True)
         save_dir = askdirectory(title="选择保存位置")
         data = learner_controller.model_evaluation(
             learner,
             save_dir,
-            UIAPI.get_data_name_gui(False, True),
-            UIAPI.get_data_name_gui(False, False),
+            API.get_data_name_gui(False, True),
+            API.get_data_name_gui(False, False),
             func,
         )
         webbrowser.open(data[0])
         webbrowser.open(data[1])  # 还可以打开文件管理器
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def calculation():
         global calculation_list, calculation_method
-        func = UIAPI.get_calculation_type_gui()
+        func = API.get_calculation_type_gui()
         if len(calculation_list) == 2 and 1 in calculation_method:
             learner_controller.calculation_matrix(
                 calculation_list, calculation_method, func
             )
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def add_calculation_core(num, type_):
@@ -275,115 +275,115 @@ class API:
 
     @staticmethod
     def add_calculation_number():
-        API.add_calculation_core(UIAPI.get_calculation_num_gui(), 0)
-        UIAPI.update_calculation_box_gui()
+        API.add_calculation_core(API.get_calculation_num_gui(), 0)
+        API.update_calculation_box_gui()
 
     @staticmethod
     def add_calculation_object():
-        name = UIAPI.get_data_name_gui()
+        name = API.get_data_name_gui()
         API.add_calculation_core(name, 1)
-        UIAPI.update_calculation_box_gui()
+        API.update_calculation_box_gui()
 
     @staticmethod
     def del_leaner():
-        learn = UIAPI.get_learner_gui(True)
-        set_learne = UIAPI.get_learner_gui(False)  # 获取学习器Learner
+        learn = API.get_learner_gui(True)
+        set_learne = API.get_learner_gui(False)  # 获取学习器Learner
         if set_learne != learn:
             learner_controller.del_leaner(learn)
-        UIAPI.update_leaner_gui()
+        API.update_leaner_gui()
 
     @staticmethod
     def global_seeting():
-        args = UIAPI.global_settings_gui()
+        args = API.global_settings_gui()
         machinelearning.template.set_global(*args)
 
     @staticmethod
     def reshape():
-        numpy_shape = UIAPI.get_shape_gui()
-        learner_controller.reshape(UIAPI.get_data_name_gui(), numpy_shape)
-        UIAPI.update_sheet_box_gui()
+        numpy_shape = API.get_shape_gui()
+        learner_controller.reshape(API.get_data_name_gui(), numpy_shape)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def transpose():
         try:
-            func = UIAPI.get_shape_gui()
+            func = API.get_shape_gui()
         except BaseException:
             func = None
-        learner_controller.transpose(UIAPI.get_data_name_gui(), func)
-        UIAPI.update_sheet_box_gui()
+        learner_controller.transpose(API.get_data_name_gui(), func)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def del_ndim():
-        learner_controller.del_ndim(UIAPI.get_data_name_gui())
-        UIAPI.update_sheet_box_gui()
+        learner_controller.del_ndim(API.get_data_name_gui())
+        API.update_sheet_box_gui()
 
     @staticmethod
     def reval():
         global learner_controller
-        reval_type = UIAPI.get_reval_type_gui()
-        learner_controller.reval(UIAPI.get_data_name_gui(), reval_type)
-        UIAPI.update_sheet_box_gui()
+        reval_type = API.get_reval_type_gui()
+        learner_controller.reval(API.get_data_name_gui(), reval_type)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def two_split():
-        split_type = UIAPI.get_merge_split_type_gui()
-        learner_controller.two_split(UIAPI.get_data_name_gui(), shape.get(), split_type)
-        UIAPI.update_sheet_box_gui()
+        split_type = API.get_merge_split_type_gui()
+        learner_controller.two_split(API.get_data_name_gui(), shape.get(), split_type)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def split():
         global learner_controller, shape
-        split_type = UIAPI.get_merge_split_type_gui()
-        split_shape_list = UIAPI.get_split_shape_list_gui()
-        learner_controller.split(UIAPI.get_data_name_gui(), split_shape_list, split_type)
-        UIAPI.update_sheet_box_gui()
+        split_type = API.get_merge_split_type_gui()
+        split_shape_list = API.get_split_shape_list_gui()
+        learner_controller.split(API.get_data_name_gui(), split_shape_list, split_type)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def merge():
         if len(merge_list) < 1:
             return False
-        merge_type = UIAPI.get_merge_split_type_gui()
+        merge_type = API.get_merge_split_type_gui()
         learner_controller.merge(merge_list, merge_type)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def merge_del():
-        del merge_list[UIAPI.get_merge_box_index_gui()]
-        UIAPI.update_merge_box_gui()
+        del merge_list[API.get_merge_box_index_gui()]
+        API.update_merge_box_gui()
 
     @staticmethod
     def merge_add():
-        merge_list.append(UIAPI.get_data_name_gui())
-        UIAPI.update_merge_box_gui()
+        merge_list.append(API.get_data_name_gui())
+        API.update_merge_box_gui()
 
     @staticmethod
     def visualization_results():
-        learner = UIAPI.get_learner_gui(True)
+        learner = API.get_learner_gui(True)
         save_dir = askdirectory(title="选择保存位置")
         data = learner_controller.model_visualization(learner, save_dir)
         webbrowser.open(data[0])
         webbrowser.open(data[1])  # 还可以打开文件管理器
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
     @staticmethod
     def score_learner():
-        learner = UIAPI.get_learner_gui()
+        learner = API.get_learner_gui()
         score = learner_controller.score(
-            UIAPI.get_data_name_gui(False, True), UIAPI.get_data_name_gui(False, False), learner
+            API.get_data_name_gui(False, True), API.get_data_name_gui(False, False), learner
         )
-        UIAPI.show_score_gui(f"针对测试数据评分结果为:{score}")
+        API.show_score_gui(f"针对测试数据评分结果为:{score}")
 
     @staticmethod
     def predict_learner():
-        learner = UIAPI.get_learner_gui()
-        data = learner_controller.predict(UIAPI.get_data_name_gui(False, True), learner)
+        learner = API.get_learner_gui()
+        data = learner_controller.predict(API.get_data_name_gui(False, True), learner)
         title = f"CoTan数据处理 学习器:{learner}"
-        UIAPI.creat_text_sheet_gui(data, title)
-        UIAPI.update_sheet_box_gui()
+        API.creat_text_sheet_gui(data, title)
+        API.update_sheet_box_gui()
 
     @staticmethod
     def fit_learner():
-        learner = UIAPI.get_learner_gui()
+        learner = API.get_learner_gui()
         try:
             split = float(data_split.get())
             if split < 0 or 1 < split:
@@ -391,13 +391,13 @@ class API:
         except BaseException:
             split = 0.3
         socore = learner_controller.fit_model(
-            UIAPI.get_data_name_gui(False, True),
-            UIAPI.get_data_name_gui(False, False),
+            API.get_data_name_gui(False, True),
+            API.get_data_name_gui(False, False),
             learner,
-            Text=UIAPI.get_learner_parameters_gui(),
+            Text=API.get_learner_parameters_gui(),
             split=split,
         )
-        UIAPI.show_score_gui(
+        API.show_score_gui(
             f"针对训练数据({(1 - split) * 100}%)评分结果为:{socore[0]}\n"
             f"针对测试数据评分({split * 100}%)结果为:{socore[1]}",
         )
@@ -417,9 +417,9 @@ class API:
     @staticmethod
     def add_view_data():
         learner_controller.add_view_data(
-            UIAPI.get_learner_gui(), parameters=UIAPI.get_learner_parameters_gui()
+            API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
         )
-        UIAPI.update_leaner_gui()
+        API.update_leaner_gui()
 
     @staticmethod
     def add_cluster_tree():
@@ -436,16 +436,16 @@ class API:
     @staticmethod
     def add_predictive_heatmap_more():  # 添加Lenear的核心
         learner_controller.add_predictive_heat_map_more(
-            UIAPI.get_learner_gui(), parameters=UIAPI.get_learner_parameters_gui()
+            API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
         )
-        UIAPI.update_leaner_gui()
+        API.update_leaner_gui()
 
     @staticmethod
     def add_predictive_heatmap():  # 添加Lenear的核心
         learner_controller.add_predictive_heat_map(
-            UIAPI.get_learner_gui(), parameters=UIAPI.get_learner_parameters_gui()
+            API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
         )
-        UIAPI.update_leaner_gui()
+        API.update_leaner_gui()
 
     @staticmethod
     def add_feature_scatter_class_all():
@@ -634,22 +634,22 @@ class API:
     @staticmethod
     def add_select_from_model():  # 添加Lenear的核心
         learner_controller.add_select_from_model(
-            UIAPI.get_learner_gui(), parameters=UIAPI.get_learner_parameters_gui()
+            API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
         )
-        UIAPI.update_leaner_gui()
+        API.update_leaner_gui()
 
     @staticmethod
     def add_leaner(learner_type):  # 添加Lenear的核心
         learner_controller.add_learner(
-            learner_type, parameters=UIAPI.get_learner_parameters_gui()
+            learner_type, parameters=API.get_learner_parameters_gui()
         )
-        UIAPI.update_leaner_gui()
+        API.update_leaner_gui()
 
     @staticmethod
     def to_html_one():
         html_dir = f"{PATH}/$Show_Sheet.html"
         try:
-            name = UIAPI.get_data_name_gui()
+            name = API.get_data_name_gui()
             if name is None:
                 raise Exception
             learner_controller.to_html_one(name, html_dir)
@@ -661,7 +661,7 @@ class API:
     def to_html():
         html_dir = f"{PATH}/$Show_Sheet.html"
         try:
-            name = UIAPI.get_data_name_gui()
+            name = API.get_data_name_gui()
             if name is None:
                 raise Exception
             learner_controller.to_html(name, html_dir, to_html_type.get())
@@ -671,19 +671,19 @@ class API:
 
     @staticmethod
     def to_csv():
-        learner_controller.to_csv(*UIAPI.to_csv_gui())
-        UIAPI.update_sheet_box_gui()
+        learner_controller.to_csv(*API.to_csv_gui())
+        API.update_sheet_box_gui()
 
     @staticmethod
     def add_csv():
-        learner_controller.read_csv(*UIAPI.add_csv_gui())
-        UIAPI.update_sheet_box_gui()
+        learner_controller.read_csv(*API.add_csv_gui())
+        API.update_sheet_box_gui()
 
     @staticmethod
     def add_python():
-        code, name = UIAPI.add_python_gui()
+        code, name = API.add_python_gui()
         learner_controller.add_python(code, name)
-        UIAPI.update_sheet_box_gui()
+        API.update_sheet_box_gui()
 
 
 def machine_learning():
@@ -1067,7 +1067,7 @@ tkinter.Button(
     bg=botton_color,
     fg=word_color,
     text="选用X集",
-    command=UIAPI.set_x_data_gui,
+    command=API.set_x_data_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1083,7 +1083,7 @@ tkinter.Button(
     bg=botton_color,
     fg=word_color,
     text="选用Y集",
-    command=UIAPI.set_y_data_gui,
+    command=API.set_y_data_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -1099,7 +1099,7 @@ tkinter.Button(
     bg=botton_color,
     fg=word_color,
     text="选用学习器",
-    command=UIAPI.set_learner_gui,
+    command=API.set_learner_gui,
     font=FONT,
     width=gui_width,
     height=gui_height,

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff