1
0
Huan 5 жил өмнө
parent
commit
f44dd2af6a

+ 36 - 24
Hello.py

@@ -12,7 +12,9 @@ import webbrowser
 
 from newtkinter import DragWindow
 
+img = None
 SCREEN = None
+queue_screen = None
 draftboard_start = None
 datascience_start = None
 functionmapping_start = None
@@ -305,11 +307,18 @@ def system_run():  # 不需要进度条
 
 
 def queuer():
-    global title_color, button_color, button_cursor
+    global title_color, button_color, button_cursor, queue_screen
+    try:
+        queue_screen.destroy()
+    except (AttributeError, TclError):
+        pass
     queue_screen = tkinter.Toplevel()
+
     queue_screen.title('通信管理器')
     queue_screen.resizable(width=False, height=False)
     queue_screen.geometry(f'+30+30')
+    # queue_screen.wm_iconbitmap(bitmap=f'Pic{os.sep}favicon.ico')
+    img = ImageTk.PhotoImage(Image.open(f'Pic{os.sep}favicon.ico'))
     font = ("黑体", 11)  # 设置字体
 
     def sent():
@@ -371,7 +380,7 @@ def close():
 
 
 def cotan_main():
-    global SCREEN, title_color, button_color, button_cursor
+    global SCREEN, title_color, button_color, button_cursor, img
     SCREEN = DragWindow(alpha=0.97, width=1200, height=800)
     font1 = tkfont.Font(family='Comic Sans MS', size=20, weight=tkfont.BOLD)
     font2 = tkfont.Font(family='Comic Sans MS', size=16, weight=tkfont.BOLD)
@@ -391,13 +400,16 @@ def cotan_main():
         width=1000,
         height=800,
         highlightthickness=0)
-    bg_image = ImageTk.PhotoImage(Image.open('Pic/Night2.jpg'))
+    bg_image = ImageTk.PhotoImage(Image.open(f'Pic{os.sep}night.jpg'))
     canvas.create_image(500, 400, image=bg_image)
     canvas.grid(column=1, row=0, sticky=tkinter.S + tkinter.N, rowspan=20)
+    # img = ImageTk.PhotoImage(Image.open(f'Pic{os.sep}favicon.ico'))
+    # SCREEN.tk.call('wm', 'iconphoto', SCREEN._w, img)
+    SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
     # 标题
     tkinter.Label(
         frame,
-        text='CoTan~科学计算',
+        text='CoTan~科学计算系统',
         width=20,
         bg='#FFFFFF',
         font=font1).grid(
@@ -406,7 +418,7 @@ def cotan_main():
         sticky=tkinter.N)  # 设置说明
     tkinter.Label(
         frame,
-        text='CoTan学术',
+        text='CoTan工具',
         bg=title_color,
         font=font2).grid(
         column=0,
@@ -415,12 +427,12 @@ def cotan_main():
         tkinter.E)
     tkinter.Button(
         frame,
-        text='CoTan社区',
+        text='CoTan草稿板',
         cursor=button_cursor,
         height=2,
         font=font3,
         bg=button_color,
-        command=to_website,
+        command=draftboard_run,
         activebackground=title_color,
         bd=0,
         justify=tkinter.LEFT).grid(
@@ -431,9 +443,9 @@ def cotan_main():
         tkinter.W)
     tkinter.Button(
         frame,
-        text='寄忆草稿板',
+        text='自动化网页',
         cursor=button_cursor,
-        command=draftboard_run,
+        command=crawlef_run,
         height=2,
         font=font3,
         bg=button_color,
@@ -447,9 +459,9 @@ def cotan_main():
         tkinter.W)
     tkinter.Button(
         frame,
-        text='自动化网页',
+        text='Git仓库控制器',
         cursor=button_cursor,
-        command=crawlef_run,
+        command=git_run,
         height=1,
         font=font3,
         bg=button_color,
@@ -463,9 +475,9 @@ def cotan_main():
         tkinter.W)
     tkinter.Button(
         frame,
-        text='Git仓库控制器',
+        text='CoTan社区',
         cursor=button_cursor,
-        command=git_run,
+        command=to_website,
         height=1,
         font=font3,
         bg=button_color,
@@ -490,9 +502,9 @@ def cotan_main():
         tkinter.E)
     tkinter.Button(
         frame,
-        text='函数测绘',
+        text='代数工厂',
         cursor=button_cursor,
-        command=functionmapping_run,
+        command=algebraicfactory_run,
         height=2,
         font=font3,
         bg=button_color,
@@ -506,9 +518,9 @@ def cotan_main():
         tkinter.W)
     tkinter.Button(
         frame,
-        text='函数工厂',
+        text='机器学习',
         cursor=button_cursor,
-        command=functionfactory_run,
+        command=machinelearner_run,
         height=2,
         font=font3,
         bg=button_color,
@@ -522,9 +534,9 @@ def cotan_main():
         tkinter.W)
     tkinter.Button(
         frame,
-        text='代数工厂',
+        text='数据科学',
         cursor=button_cursor,
-        command=algebraicfactory_run,
+        command=datascience_run,
         height=2,
         font=font3,
         bg=button_color,
@@ -538,9 +550,9 @@ def cotan_main():
         tkinter.W)
     tkinter.Button(
         frame,
-        text='数据科学',
+        text='函数工厂',
         cursor=button_cursor,
-        command=datascience_run,
+        command=functionfactory_run,
         height=1,
         font=font3,
         bg=button_color,
@@ -554,9 +566,9 @@ def cotan_main():
         tkinter.W)
     tkinter.Button(
         frame,
-        text='机器学习',
+        text='函数实验室',
         cursor=button_cursor,
-        command=machinelearner_run,
+        command=functionmapping_run,
         height=1,
         font=font3,
         bg=button_color,
@@ -691,7 +703,7 @@ def cotan_main():
         row=20,
         sticky=tkinter.W +
         tkinter.E)
-    canvas.create_text(500, 750, text='CoTan~别来无恙', font=font4, fill='#FFFFE0')
+    canvas.create_text(450, 740, text='Welcome to CoTan', font=font4, fill='#FFFFE0')
     SCREEN.protocol("WM_DELETE_WINDOW", close)
     SCREEN.mainloop()
 

BIN
Pic/Night.jpg


BIN
Pic/Sun.jpg


+ 0 - 0
Pic/Night2.jpg → Pic/night.jpg


+ 2 - 0
algebraicfactory/gui.py

@@ -1,6 +1,7 @@
 import tkinter
 import tkinter.messagebox
 import tkinter.font as tkfont
+import os
 
 from algebraicfactory.controller import AlgebraPolynomial
 from system import exception_catch, QueueController
@@ -20,6 +21,7 @@ FONT3 = tkfont.Font(family="Fixdsys", size=11)
 SCREEN.title("CoTan代数工厂")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry("+10+10")  # 设置所在位置
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 option_list = []
 value_algebra_dict = {}  # Sub替换字典
 left_value = None  # 选定的Sub符号

+ 35 - 6
crawler/gui.py

@@ -6,7 +6,7 @@ import logging
 
 import crawler.controller
 import crawler.template
-from newtkinter import askdirectory
+from newtkinter import askdirectory, askopenfilename
 from system import exception_catch, basicConfig, QueueController
 
 
@@ -332,6 +332,15 @@ class UIAPI:
                     data=data_format.get(),
                     dataBase_name=API.get_datadase_name_gui(),)
 
+    @staticmethod
+    @exception_catch()
+    def add_filter_from_python_gui():
+        file_dir = askopenfilename(title='python文件')
+        file_name = os.path.split(file_dir)[-1]
+        with open(file_dir, 'r') as f:
+            code = f.read()
+        return code, file_name
+
 
 class API(UIAPI):
     @staticmethod
@@ -639,6 +648,17 @@ class API(UIAPI):
         url.add_filter_func(lambda the_url: re.match(re.compile("^https://"), the_url), "HTTPS过滤")
         API.update_filter_func_box_gui()
 
+    @staticmethod
+    @exception_catch()
+    def add_filter_from_python():
+        name_space = {}
+        code_str, file_name = API.add_filter_from_python_gui()
+        exec(code_str, name_space)
+        code = name_space.get('filter')
+        assert hasattr(code, '__call__'), 'filter not callable'
+        url.add_filter_func(code, file_name)
+        API.update_filter_func_box_gui()
+
     @staticmethod
     @exception_catch()
     def add_filter_func_www():
@@ -652,6 +672,12 @@ class API(UIAPI):
         url.del_filter_func(index)
         API.update_filter_func_box_gui()
 
+    @staticmethod
+    @exception_catch()
+    def clean_filter_func():
+        url.clean_filter_func()
+        API.update_filter_func_box_gui()
+
     @staticmethod
     @exception_catch()
     def del_url():
@@ -661,12 +687,12 @@ class API(UIAPI):
 
     @staticmethod
     @exception_catch()
-    def add_url():
+    def add_url(must=False):
         args = API.get_url_parameter_gui()
         new_url = API.get_new_url_name_gui()
         if new_url == "":
             return
-        url.add_url(new_url, **args)
+        url.add_url(new_url, must=must, **args)
         API.update_url_box_gui()
 
     @staticmethod
@@ -695,6 +721,7 @@ def crawler_main(in_queue, out_queue):
 SCREEN.title("CoTan自动化网页")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry("+10+10")  # 设置所在位置
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 gui_width = 13  # 标准宽度
 gui_height = 2
 row = 0
@@ -704,7 +731,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="添加url对象",
-    command=API.add_url,
+    command=lambda: API.add_url(False),
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -723,7 +750,8 @@ tkinter.Button(
     SCREEN,
     bg=buttom_bg_color,
     fg=word_color,
-    text="应用过滤机制",
+    command=lambda: API.add_url(True),
+    text="强制添加",
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -890,7 +918,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="自定义过滤器",
-    command=API.add_filter_func_https,
+    command=API.add_filter_from_python,
     font=FONT,
     width=gui_width,
     height=gui_height,
@@ -901,6 +929,7 @@ tkinter.Button(
     fg=word_color,
     text="清空过滤器",
     font=FONT,
+    command=API.clean_filter_func,
     width=gui_width,
     height=gui_height,
 ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)

+ 6 - 3
crawler/template.py

@@ -399,6 +399,9 @@ class UrlAdd(Urlbase, metaclass=ABCMeta):
     def del_filter_func(self, index):  # 删除过滤函数
         del self.filter[list(self.filter.keys())[index]]
 
+    def clean_filter_func(self):
+        self.filter = {}
+
     def return_filter_func(self):
         return list(self.filter.keys())
 
@@ -418,14 +421,14 @@ class UrlReturn(Urlbase, metaclass=ABCMeta):
     def is_finish(self):
         return len(self.url_list) == 0
 
-    def add_url(self, url, func, data=None, **kwargs):  # 添加url
+    def add_url(self, url, func, data=None, must=False, **kwargs):  # 添加url
         if func == "":
             func = "get"
         if func == "get":
             url_ = url
         else:
             url_ = url + str(data)
-        if url_ not in self.url_history and self.filter_func(url, func=func):  # 1.url不存在历史,2.url满足筛选条件
+        if must or (url_ not in self.url_history and self.filter_func(url, func=func)):  # 1.url不存在历史,2.url满足筛选条件
             if func == "get":
                 self.url_list.append(
                     UrlPage(url=url, **kwargs, down_load_dir=self.dir)
@@ -1413,7 +1416,7 @@ class PageParserTool(PageParserFunc):
         self.add_func(f"Webpage_snapshot", action)  # 添加func
 
 
-class PageParserData(PageParserDatabase, PageParserDataSource, PageParserDataFindall,PageParserTool):
+class PageParserData(PageParserDatabase, PageParserDataSource, PageParserDataFindall, PageParserTool):
     pass
 
 

+ 26 - 17
datascience/gui.py

@@ -27,6 +27,7 @@ FONT1 = ("黑体", 13)
 SCREEN.title("CoTan数据处理")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry("+10+10")  # 设置所在位置
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 gui_width = 13  # 标准宽度
 gui_height = 2
 row = 0
@@ -284,12 +285,6 @@ class UIAPI:
         exp = clean_code.get("0.0", tkinter.END)
         return exp
 
-    @staticmethod
-    @exception_catch()
-    def view_cleaning_script_gui():
-        name = clean_list[API.get_clean_func_box_index_gui()]
-        API.update_clean_code(machine_controller.get_clean_code(name))
-
     @staticmethod
     @exception_catch()
     def get_clean_func_box_index_gui():
@@ -316,7 +311,7 @@ class UIAPI:
     @exception_catch()
     def reset_clean_code_gui():
         global clean_code, clean_default_script
-        API.update_clean_code(clean_default_script)
+        API.update_clean_code_gui(clean_default_script)
 
     @staticmethod
     @exception_catch()
@@ -368,6 +363,12 @@ class UIAPI:
         wrong = dtype_wrong.get()
         return column_list, dtype, name, type_, wrong
 
+    @staticmethod
+    @exception_catch()
+    def update_clean_code_gui(clean_default_script_):
+        clean_code.delete("0.0", tkinter.END)
+        clean_code.insert("0.0", clean_default_script_)
+
     @staticmethod
     @exception_catch()
     def datetime_index_gui():
@@ -474,6 +475,12 @@ class UIAPI:
 
 
 class API(UIAPI):
+    @staticmethod
+    @exception_catch()
+    def view_cleaning_script():
+        name = clean_list[API.get_clean_func_box_index_gui()]
+        API.update_clean_code_gui(machine_controller.get_clean_code(name))
+
     @staticmethod
     @exception_catch()
     def clear_rendering():
@@ -917,17 +924,11 @@ class API(UIAPI):
         name = API.get_sheet_name_gui()
         API.new_render(machine_controller.to_bar(name, API.get_rendering_parameters()), "柱状图")
 
-    @staticmethod
-    @exception_catch()
-    def update_clean_code(clean_default_script_):
-        clean_code.delete("0.0", tkinter.END)
-        clean_code.insert("0.0", clean_default_script_)
-
     @staticmethod
     @exception_catch()
     def empty_cleaning_script():
         machine_controller.del_all_clean_func()
-        API.update_sheet_box_gui()
+        API.update_cleaning_script_box()
 
     @staticmethod
     @exception_catch()
@@ -948,9 +949,10 @@ class API(UIAPI):
     @staticmethod
     @exception_catch()
     def update_cleaning_script_box():
-        clean_list_ = machine_controller.get_clean_func()
+        global clean_list
+        clean_list = machine_controller.get_clean_func()
         clean_func_box.delete(0, tkinter.END)
-        clean_func_box.insert(tkinter.END, *clean_list_)
+        clean_func_box.insert(tkinter.END, *clean_list)
 
     @staticmethod
     @exception_catch()
@@ -959,6 +961,13 @@ class API(UIAPI):
         machine_controller.add_clean_func(exp)
         API.update_cleaning_script_box()
 
+    @staticmethod
+    @exception_catch()
+    def clean_cleaning_script():
+        exp = API.get_clean_code_gui()
+        machine_controller.add_clean_func(exp)
+        API.update_cleaning_script_box()
+
     @staticmethod
     @exception_catch()
     def clean_nan_row():
@@ -1824,7 +1833,7 @@ tkinter.Button(
     bg=buttom_bg_color,
     fg=word_color,
     text="查看执行方法",
-    command=API.view_cleaning_script_gui,
+    command=API.view_cleaning_script,
     font=FONT,
     width=gui_width,
     height=gui_height,

+ 2 - 5
datascience/template.py

@@ -479,11 +479,8 @@ class DatacleaningFunc(FormBase, metaclass=ABCMeta):
         return list(self.clean_func.keys())
 
     def del_clean_func(self, key):
-        try:
-            del self.clean_func[key]
-            del self.clean_func_code[key]
-        except BaseException as e:
-            logging.warning(str(e))
+        del self.clean_func[key]
+        del self.clean_func_code[key]
 
     def del_all_clean_func(self):
         self.clean_func = {}

+ 1 - 0
draftboard/board.py

@@ -49,6 +49,7 @@ FONT = pygame.font.Font(fr'Font{os.sep}ZKST.ttf', 16)  # 设置字体(Linux下
 SCREEN = pygame.display.set_mode((SCREEN_X, SCREEN_Y), 0)  # 创建屏幕
 SCREEN_CAPTION = pygame.display.set_caption('CoTan草稿板')  # 定义标题(后期加上定义Logo)
 SCREEN.fill([255, 255, 255])  # 默认用白色填充窗口
+pygame.display.set_icon(pygame.image.load(f'Pic{os.sep}favicon.ico'))
 
 
 def func_draw(func_list, pixel_accuracy=1000):

+ 2 - 0
draftboard/toolbox.py

@@ -1,3 +1,4 @@
+import os
 from tkinter.colorchooser import askcolor
 from newtkinter import asksaveasfilename, askopenfilename
 import tkinter.messagebox
@@ -225,6 +226,7 @@ def tool_box():
     SCREEN.title("Tool")
     SCREEN.resizable(width=False, height=False)
     SCREEN.geometry(f"+10+10")
+    SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
     tkinter.Button(
         SCREEN,
         text="选择颜色",

+ 6 - 11
funcsystem/factory.py

@@ -844,6 +844,7 @@ SCREEN["bg"] = bg_color
 SCREEN.title("CoTan函数工厂")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry("+10+10")
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 FONT = (rf"Font{os.sep}ZKST.ttf", 11)  # 设置字体
 rcParams["font.family"] = "simhei"
 rcParams["axes.unicode_minus"] = False
@@ -1072,12 +1073,12 @@ prediction_accuracy.grid(
 
 row += 1
 # 显示函数的xy
-prediction_box = tkinter.Listbox(SCREEN, width=gui_width * 3)  # 暂时不启用多选
+prediction_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height*5)  # 暂时不启用多选
 prediction_box.grid(
     column=column,
     row=row,
     columnspan=3,
-    rowspan=9,
+    rowspan=5,
     sticky=tkinter.S + tkinter.N + tkinter.E + tkinter.W,
 )
 
@@ -1359,13 +1360,12 @@ plot_type.insert(
 row += 3
 # 显示函数的xy
 prompt_box = tkinter.Listbox(
-    SCREEN, width=gui_width * 3, height=gui_height * 2
-)  # 暂时不启用多选
+    SCREEN, width=gui_width * 3, height=gui_height*1)  # 暂时不启用多选
 prompt_box.grid(
     column=column,
     row=row,
     columnspan=3,
-    rowspan=2,
+    rowspan=1,
     sticky=tkinter.S + tkinter.N + tkinter.E + tkinter.W,
 )
 
@@ -1474,11 +1474,6 @@ for i in range(4):
         SCREEN, width=gui_width * 2, textvariable=gradient_parameters[-1]
     ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
 
-row += 1
-tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, height=1).grid(
-    column=1, row=row
-)  # 底部
-
 column += 3
 tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
     column=column, row=0
@@ -1678,7 +1673,7 @@ tkinter.Button(
 row += 1
 # 显示函数的xy
 projection_box = tkinter.Listbox(
-    SCREEN, width=gui_width * 3, height=gui_height * 5
+    SCREEN, width=gui_width * 3, height=gui_height*6
 )  # 暂时不启用多选
 projection_box.grid(
     column=column,

+ 6 - 5
funcsystem/map.py

@@ -597,9 +597,10 @@ def function_mapping(in_queue, out_queue):
     queue_controller.stop_process()
 
 
-SCREEN.title("CoTan函数测绘")
+SCREEN.title("CoTan函数实验室")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry(f"+10+10")
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 rcParams["font.family"] = "simhei"
 rcParams["axes.unicode_minus"] = False
 tkinter.Label(
@@ -709,10 +710,10 @@ func_exp_box.grid(
     rowspan=rowspan,
     sticky=tkinter.S + tkinter.N + tkinter.E + tkinter.W,
 )
-a_y += rowspan
-tkinter.Label(
-    SCREEN, font=FONT, text="", width=gui_width, height=1, bg=bg_color, fg=word_color
-).grid(column=0, row=a_y)
+# a_y += rowspan
+# tkinter.Label(
+#     SCREEN, font=FONT, text="", width=gui_width, height=1, bg=bg_color, fg=word_color
+# ).grid(column=0, row=a_y)
 
 tkinter.Label(SCREEN, font=FONT, text="", width=1, bg=bg_color, fg=word_color).grid(
     column=4, row=0

+ 8 - 11
gitrepo/gui.py

@@ -614,6 +614,11 @@ class UIAPI:
         old_name = API.get_branch_name_gui()
         return new_name, old_name
 
+    @staticmethod
+    @exception_catch()
+    def get_file_box_index_gui():
+        return file_box.curselection()[0]
+
 
 class API(UIAPI):
     @staticmethod
@@ -922,19 +927,11 @@ class API(UIAPI):
         API.cli_gui(git.add_file, (API.get_repo_name_gui(), dic))
         API.update_git_file_last_gui()
 
-    @staticmethod
-    @exception_catch()
-    def get_file_box_index():
-        return file_box.curselection()
-
     @staticmethod
     @exception_catch()
     def del_file():
-        try:
-            del file_list[API.get_file_box_index()]
-            API.update_file_box_gui()
-        except BaseException as e:
-            logging.warning(str(e))
+        del file_list[API.get_file_box_index_gui()]
+        API.update_file_box_gui()
 
     @staticmethod
     @exception_catch()
@@ -981,7 +978,7 @@ FONT = ("黑体", 11)  # 设置字体
 SCREEN.title("CoTan仓库管理器")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry("+10+10")  # 设置所在位置
-
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 gui_width = 13  # 标准宽度
 gui_height = 2
 row = 0

+ 34 - 3
machinelearning/gui.py

@@ -6,7 +6,6 @@ from newtkinter import askopenfilename, asksaveasfilename, askdirectory
 import chardet
 import webbrowser
 from multiprocessing import Queue
-import threading
 
 import machinelearning.controller
 import machinelearning.template
@@ -35,6 +34,15 @@ learn_dict = {}
 
 
 class UIAPI:
+    @staticmethod
+    @exception_catch()
+    def add_learner_from_python_gui():
+        file_dir = askopenfilename(title='python文件')
+        file_name = os.path.split(file_dir)[-1]
+        with open(file_dir, 'r') as f:
+            code = f.read()
+        return code, file_name
+
     @staticmethod
     @exception_catch()
     def get_split_shape_list_gui():
@@ -232,6 +240,18 @@ class UIAPI:
 
 
 class API(UIAPI):
+    @staticmethod
+    @exception_catch()
+    def add_learner_from_python():  # 添加Lenear的核心
+        code_str, name = API.add_learner_from_python_gui()
+        code_str = code_str.replace('base = None', '')
+        code_str = code_str.replace('study_base = None', '')
+        name_space = {'base': machinelearning.template.LearnBase,
+                      'study_base': machinelearning.template.StudyMachinebase}
+        exec(code_str, name_space)
+        learner_controller.add_learner_from_python(name_space.get('learner'), name)
+        API.update_leaner_gui()
+
     @staticmethod
     @exception_catch()
     def add_reverse_fast_fourier2():  # 添加Lenear的核心
@@ -756,16 +776,24 @@ class API(UIAPI):
     def to_html_one():
         html_dir = f"{PATH}{os.sep}$Show_Sheet.html"
         name = API.get_data_name_gui()
-        assert not name is None
+        assert name is not None
         learner_controller.to_html_one(name, html_dir)
         webbrowser.open(html_dir)
 
+    @staticmethod
+    @exception_catch()
+    def del_sheet():
+        name = API.get_data_name_gui()
+        assert name is not None
+        learner_controller.del_sheet(name)
+        API.update_sheet_box_gui()
+
     @staticmethod
     @exception_catch()
     def to_html():
         html_dir = f"{PATH}{os.sep}$Show_Sheet.html"
         name = API.get_data_name_gui()
-        assert not name is None
+        assert name is not None
         learner_controller.to_html(name, html_dir, to_html_type.get())
         webbrowser.open(html_dir)
 
@@ -800,6 +828,7 @@ def machine_learning(in_queue, out_queue):
 SCREEN.title("CoTan机器学习")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry("+10+10")  # 设置所在位置
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 tkinter.Button(
     SCREEN,
     bg=botton_color,
@@ -865,6 +894,7 @@ tkinter.Button(
     fg=word_color,
     text="删除表格",
     font=FONT,
+    command=API.del_sheet,
     width=gui_width,
     height=gui_height,
 ).grid(
@@ -1241,6 +1271,7 @@ tkinter.Button(
     fg=word_color,
     text="导入学习器",
     font=FONT,
+    command=API.add_learner_from_python,
     width=gui_width,
     height=gui_height,
 ).grid(

+ 9 - 0
machinelearning/template.py

@@ -121,6 +121,9 @@ class LearnerIO(LearnBase):
         name = f"{name}[{len(self.numpy_dict)}]"
         self.numpy_dict[name] = data
 
+    def del_sheet(self, name):
+        del self.numpy_dict[name]
+
     def read_csv(
             self,
             file_dir,
@@ -5023,6 +5026,12 @@ class MachineLearnerAdd(MachineLearnerInit, metaclass=ABCMeta):
         self.learner[name] = get(model=learner_str, args_use=args_use)
         self.data_type[name] = learner_str
 
+    def add_learner_from_python(self, learner, name):
+        name = f"Le[{len(self.learner)}]{name}"
+        # 生成学习器
+        self.learner[name] = learner
+        self.data_type[name] = 'from_python'
+
     def add_curve_fitting(self, learner):
         named_domain = {}
         exec(learner, named_domain)

+ 3 - 3
system/__init__.py

@@ -3,7 +3,6 @@ import logging
 from multiprocessing import Queue
 import time
 import threading
-from sys import exit
 
 
 PATH = os.getcwd()
@@ -52,10 +51,11 @@ def exception_catch(*args_catch, **kwargs_catch):
         def adorner(*args, **kwargs):
             try:
                 return_ = func(*args, **kwargs)
-                logging.debug(f'run  {func.__name__} args:{args}  kwargs:{kwargs} return:{return_}')
+                logging.debug(f'run  {func.__name__} args:{args}  kwargs:{kwargs} return:{return_}'
+                              .replace('\n', '\\n'))
                 return return_
             except BaseException as e:
-                logging.error(f'{e}  {func.__name__} args:{args}  kwargs:{kwargs}')
+                logging.error(f'{e}  {func.__name__} args:{args}  kwargs:{kwargs}'.replace('\n', '\\n'))
                 assert not func.__name__.endswith('_gui'), str(e)
         return adorner
     return catch

+ 26 - 4
system/gui.py

@@ -1,8 +1,9 @@
 import tkinter
 from newtkinter import askopenfilename
-from tkinter.messagebox import showwarning, askokcancel
+from tkinter.messagebox import showwarning, askokcancel, showinfo
 from tkinter.scrolledtext import ScrolledText
 import webbrowser
+import os
 
 from system.controller import Systemctl, NamingError, ConflictError
 from system import QueueController
@@ -10,9 +11,10 @@ from system import QueueController
 queue_controller = QueueController()
 SCREEN = tkinter.Tk()
 systemctl = Systemctl()
-SCREEN.title("插件管理")
+SCREEN.title("系统管理")
 SCREEN.resizable(width=False, height=False)
 SCREEN.geometry(f"+10+10")
+SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
 bg_color = "#FFFAFA"  # 主颜色
 SCREEN["bg"] = bg_color
 botton_color = "#FFFAFA"  # 按钮颜色
@@ -123,6 +125,14 @@ def system_main(in_queue, out_queue):
     queue_controller.stop_process()
 
 
+def show_about():
+    showinfo("关于", '''
+关于CoTan:
+CoTan是由SuperHuan于2020年开始开发的开源科学计算系统。
+关于CoTan的更多信息请访问CoTan社区
+''')
+
+
 (
     tkinter.Label(
         SCREEN,
@@ -256,9 +266,21 @@ row += 1
         bg=botton_color,
         fg=word_color,
         command=lambda: webbrowser.open(r'E:\SongZihuan\PyProject\CoTan\Log\log_system.log'),
-        text="查看日记",
+        text="查看日志",
+        font=FONT,
+        width=gui_width,
+        height=gui_height,
+    ).grid(column=column, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
+)
+(
+    tkinter.Button(
+        SCREEN,
+        bg=botton_color,
+        fg=word_color,
+        command=show_about,
+        text="关于CoTan",
         font=FONT,
         width=gui_width,
         height=gui_height,
-    ).grid(column=column, columnspan=3, row=row, sticky=tkinter.E + tkinter.W)
+    ).grid(column=column+2, row=row, sticky=tkinter.E + tkinter.W)
 )