浏览代码

代码静态检查

Huan 5 年之前
父节点
当前提交
8e979b0a89

+ 1 - 1
Hello.py

@@ -5,7 +5,7 @@ import tkinter.font as tkfont
 from PIL import ImageTk, Image
 import time
 
-from drag import DragWindow
+from newtkinter import DragWindow
 
 SCREEN = None
 draftboard_start = None

+ 0 - 0
crawler/db.py


+ 2 - 5
crawler/gui.py

@@ -1,9 +1,8 @@
 import crawler.controller
 import crawler.template
-from crawler import controller
 import os
 import tkinter
-from tkinter.filedialog import askdirectory
+from newtkinter import askdirectory
 import re
 import threading
 
@@ -18,8 +17,6 @@ word_color = "#000000"  # 文字颜色
 SCREEN["bg"] = bg_color
 FONT = ("黑体", 11)  # 设置字体
 start_loader_stop = False
-url_input = None
-url_parameter = None
 user_agent_input = None
 requests_data = None
 mode_input = None
@@ -2238,7 +2235,7 @@ tkinter.Button(
     height=gui_height,
 ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
 SCREEN.update()  # 要预先update一下,否则会卡住
-save_dir = askdirectory(title="选择项目位置")  # 项目位置
+save_dir = askdirectory(title="选择项目位置", must=True)  # 项目位置
 url = crawler.controller.Url(save_dir, save_dir)  # url管理器
 loader = crawler.controller.PageDownloader(url, save_dir)  # 页面下载器
 page_parser = crawler.controller.PageParser(loader)  # 页面解析器

+ 1 - 1
crawler/template.py

@@ -1503,7 +1503,7 @@ class PageParserChains(PageParserChainsWindow, PageParserClick, PageParserChains
 
 
 for i in range(1, 13):  # F1 - F12按键
-    keys_name_dict[f"f{i}"] = eval(f"Keys.F{i}")
+    keys_name_dict[f"f{i}"] = eval(f"Keys.F{i}", {'Keys': Keys})
 
 
 class CoTanDB(Database):

+ 1 - 1
datascience/gui.py

@@ -1,7 +1,7 @@
 import os
 import webbrowser
 import tkinter
-from tkinter.filedialog import askopenfilename, asksaveasfilename
+from newtkinter import askopenfilename, asksaveasfilename
 import tkinter.messagebox
 from tkinter.scrolledtext import ScrolledText
 

+ 2 - 2
datascience/template.py

@@ -45,7 +45,7 @@ class FormBase(RowColumnBase):
         self.clean_func = {}
         self.clean_func_code = {}
         self.DEL = Del()
-        self.Name = {"pd": pd, "DEL": self.DEL, "re": re, "Sheet": self.sheet_dict}
+        self.named_domain = {"pd": pd, "DEL": self.DEL, "re": re, "Sheet": self.sheet_dict}
         self.all_render = {}  # 存放所有的图
 
 
@@ -446,7 +446,7 @@ class SheetSlice(SheetIO):
 @plugin_class_loading(get_path(r'template/datascience'))
 class DatacleaningFunc(SheetIO):
     def add_clean_func(self, code):
-        name = self.Name.copy()
+        name = self.named_domain.copy()
         try:
             exec(code, name)
         except BaseException:

+ 22 - 3
draftboard/customfunctions.py

@@ -8,6 +8,9 @@ func_input = None
 help = None
 button = None
 logger = None
+bg_color = "#FFFAFA"  # 主颜色
+botton_color = "#FFFAFA"  # 按钮颜色
+word_color = "#000000"  # 文字颜色
 help_doc = """
 请在第一个输入框输入你的函数方程,不需要输入f(x)=和y=,唯一变量是x(x为自变量)
 圆周率-Pi,自然无理数-e
@@ -80,12 +83,28 @@ def get_help():
 
 def make_func():
     global SCREEN, func_input, help, button, logger
-    SCREEN = tkinter.Toplevel()
+    SCREEN = tkinter.Toplevel(bg=bg_color)
     SCREEN.title("")
     SCREEN.resizable(width=False, height=False)
     SCREEN.geometry(f"+350+10")
-    button = tkinter.Button(SCREEN, text="制造函数", command=custom, width=28, height=1)  # 收到消息执行这个函数
-    help = tkinter.Button(SCREEN, text="帮助", command=get_help, width=28, height=1)  # 帮助菜单
+    button = tkinter.Button(
+        SCREEN,
+        text="制造函数",
+        command=custom,
+        width=28,
+        height=1,
+        bg=bg_color,
+        fg=word_color,
+    )
+    help = tkinter.Button(
+        SCREEN,
+        text="帮助",
+        command=get_help,
+        width=28,
+        height=1,
+        bg=bg_color,
+        fg=word_color,
+    )
     func_input = tkinter.Entry(SCREEN)
     func_input.pack(fill=tkinter.BOTH)
     button.pack()

+ 193 - 22
draftboard/drawingfunction.py

@@ -9,6 +9,9 @@ func_dict = {}
 custom_func_dict = {}
 width = 20
 SCREEN = None  # 设置屏幕
+bg_color = "#FFFAFA"  # 主颜色
+botton_color = "#FFFAFA"  # 按钮颜色
+word_color = "#000000"  # 文字颜色
 
 
 class Logger:
@@ -187,29 +190,197 @@ def custom_func():
 def func_box():
     global SCREEN
     loger = Logger()
-    SCREEN = tkinter.Toplevel()  # 设置屏幕
+    SCREEN = tkinter.Toplevel(bg=bg_color)  # 设置屏幕
     SCREEN.title("")
     SCREEN.resizable(width=False, height=False)
     SCREEN.geometry(f"+180+10")
-    tkinter.Button(SCREEN, text="1次函数", command=linear_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="2次函数", command=quadratic_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="-1次函数", command=inverse_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="3次函数", command=cubic_function, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="根号函数", command=radical_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="对数函数", command=log_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="指数函数", command=exp_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="对数底函数", command=log2_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="sin函数", command=sin_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="cos函数", command=cos_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="tan函数", command=tan_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="cot函数", command=tan_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="csc函数", command=csc_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="sec函数", command=sec_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="arcsin函数", command=arcsin_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="arccos函数", command=arccos_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="arctan函数", command=arctan_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="arccot函数", command=arccot_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="arccsc函数", command=arccsc_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="arcsec函数", command=arcsec_func, width=width, height=1).pack()
-    tkinter.Button(SCREEN, text="自定义函数", command=custom_func, width=width, height=3).pack()
+    tkinter.Button(
+        SCREEN,
+        text="1次函数",
+        bg=bg_color,
+        fg=word_color,
+        command=linear_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="2次函数",
+        bg=bg_color,
+        fg=word_color,
+        command=quadratic_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="-1次函数",
+        bg=bg_color,
+        fg=word_color,
+        command=inverse_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="3次函数",
+        bg=bg_color,
+        fg=word_color,
+        command=cubic_function,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="根号函数",
+        bg=bg_color,
+        fg=word_color,
+        command=radical_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="对数函数",
+        bg=bg_color,
+        fg=word_color,
+        command=log_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="指数函数",
+        bg=bg_color,
+        fg=word_color,
+        command=exp_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="对数底函数",
+        bg=bg_color,
+        fg=word_color,
+        command=log2_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="sin函数",
+        bg=bg_color,
+        fg=word_color,
+        command=sin_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="cos函数",
+        bg=bg_color,
+        fg=word_color,
+        command=cos_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="tan函数",
+        bg=bg_color,
+        fg=word_color,
+        command=tan_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="cot函数",
+        bg=bg_color,
+        fg=word_color,
+        command=tan_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="csc函数",
+        bg=bg_color,
+        fg=word_color,
+        command=csc_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="sec函数",
+        bg=bg_color,
+        fg=word_color,
+        command=sec_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="arcsin函数",
+        bg=bg_color,
+        fg=word_color,
+        command=arcsin_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="arccos函数",
+        bg=bg_color,
+        fg=word_color,
+        command=arccos_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="arctan函数",
+        bg=bg_color,
+        fg=word_color,
+        command=arctan_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="arccot函数",
+        bg=bg_color,
+        fg=word_color,
+        command=arccot_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="arccsc函数",
+        bg=bg_color,
+        fg=word_color,
+        command=arccsc_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="arcsec函数",
+        bg=bg_color,
+        fg=word_color,
+        command=arcsec_func,
+        width=width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="自定义函数",
+        bg=bg_color,
+        fg=word_color,
+        command=custom_func,
+        width=width,
+        height=3,
+    ).pack()
     return loger

+ 154 - 20
draftboard/toolbox.py

@@ -1,5 +1,5 @@
 from tkinter.colorchooser import askcolor
-from tkinter.filedialog import asksaveasfile
+from newtkinter import asksaveasfilename, askopenfilename
 import tkinter.messagebox
 
 from draftboard import drawingfunction
@@ -19,6 +19,9 @@ save_dir = None
 gui_width = 20
 gui_height = 3
 span = None
+bg_color = "#FFFAFA"  # 主颜色
+botton_color = "#FFFAFA"  # 按钮颜色
+word_color = "#000000"  # 文字颜色
 help_doc = """
 *快捷键:
     d-不用点击左键画线(再次点击关闭)
@@ -80,7 +83,7 @@ def select_color():
 
 def choose_save():
     global save_dir
-    save_dir = tkinter.filedialog.asksaveasfilename(
+    save_dir = asksaveasfilename(
         title="选择保存位置", filetypes=[("PNG", ".png")]
     )
     if not save_dir:
@@ -91,7 +94,7 @@ def choose_save():
 
 def choose_open():
     global background_image
-    background_image = tkinter.filedialog.askopenfilename(
+    background_image = askopenfilename(
         title="选择载入图片", filetypes=[("PNG", ".png"), ("JPG", ".jpg")]
     )
     if not background_image:
@@ -208,36 +211,167 @@ def _help():
 def tool_box():
     global SCREEN, span_input  # 初始化屏幕
     SCREEN = tkinter.Tk()  # 设置屏幕
-    SCREEN.title("")
+    SCREEN["bg"] = bg_color
+    SCREEN.title("Tool")
     SCREEN.resizable(width=False, height=False)
     SCREEN.geometry(f"+10+10")
-    tkinter.Button(SCREEN, text="选择颜色", command=select_color, width=gui_width, height=gui_height).pack()
-    tkinter.Button(SCREEN, text="选择增函数颜色", command=increasing_func_color, width=gui_width, height=1).pack()
-    tkinter.Button(SCREEN, text="选择减函数颜色", command=subtraction_func_color, width=gui_width, height=1).pack()
-    tkinter.Button(SCREEN, text="使用中笔(默认笔)", command=switch_stroke, width=gui_width, height=gui_height).pack()
-    tkinter.Button(SCREEN, text="使用大笔", command=switch_big, width=gui_width, height=1).pack()  # 切换到大笔
-    tkinter.Button(SCREEN, text="使用小笔", command=switch_small, width=gui_width, height=1).pack()  # 切换笔
-    tkinter.Button(SCREEN, text="使用刷子", command=switch_brush, width=gui_width, height=1).pack()  # 切换笔
+    tkinter.Button(
+        SCREEN,
+        text="选择颜色",
+        bg=bg_color,
+        fg=word_color,
+        command=select_color,
+        width=gui_width,
+        height=gui_height,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="选择增函数颜色",
+        bg=bg_color,
+        fg=word_color,
+        command=increasing_func_color,
+        width=gui_width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="选择减函数颜色",
+        bg=bg_color,
+        fg=word_color,
+        command=subtraction_func_color,
+        width=gui_width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="使用中笔(默认笔)",
+        bg=bg_color,
+        fg=word_color,
+        command=switch_stroke,
+        width=gui_width,
+        height=gui_height,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="使用大笔",
+        bg=bg_color,
+        fg=word_color,
+        command=switch_big,
+        width=gui_width,
+        height=1,
+    ).pack()  # 切换到大笔
+    tkinter.Button(
+        SCREEN,
+        text="使用小笔",
+        bg=bg_color,
+        fg=word_color,
+        command=switch_small,
+        width=gui_width,
+        height=1,
+    ).pack()  # 切换笔
+    tkinter.Button(
+        SCREEN,
+        text="使用刷子",
+        bg=bg_color,
+        fg=word_color,
+        command=switch_brush,
+        width=gui_width,
+        height=1,
+    ).pack()  # 切换笔
     pen_weight_input = tkinter.Entry(SCREEN, width=gui_width - 2)
     pen_weight_input.pack(fill=tkinter.BOTH)
-    tkinter.Button(SCREEN, text="使用自定义大小", command=set_pen, width=gui_width, height=1).pack()  # 切换笔
-    tkinter.Button(SCREEN, text="清空草稿", command=empty, width=gui_width, height=gui_height).pack()  # 填充背景
-    tkinter.Button(SCREEN, text="绘制坐标系", command=plot_coordinate, width=gui_width, height=gui_height).pack()
-    tkinter.Button(SCREEN, text="绘制坐标系(小跨度)", command=plot_coordinate_small, width=gui_width, height=1).pack()
+    tkinter.Button(
+        SCREEN,
+        text="使用自定义大小",
+        bg=bg_color,
+        fg=word_color,
+        command=set_pen,
+        width=gui_width,
+        height=1,
+    ).pack()  # 切换笔
+    tkinter.Button(
+        SCREEN,
+        text="清空草稿",
+        bg=bg_color,
+        fg=word_color,
+        command=empty,
+        width=gui_width,
+        height=gui_height,
+    ).pack()  # 填充背景
+    tkinter.Button(
+        SCREEN,
+        text="绘制坐标系",
+        bg=bg_color,
+        fg=word_color,
+        command=plot_coordinate,
+        width=gui_width,
+        height=gui_height,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="绘制坐标系(小跨度)",
+        bg=bg_color,
+        fg=word_color,
+        command=plot_coordinate_small,
+        width=gui_width,
+        height=1,
+    ).pack()
     tkinter.Button(
         SCREEN,
         text="绘制坐标系(大跨度)",
         command=plot_coordinate_big_span,
         width=gui_width,
         height=1,
+        bg=bg_color,
+        fg=word_color,
     ).pack()  # 绘制坐标系
     span_input = tkinter.Entry(SCREEN, width=gui_width - 2)
     span_input.pack(fill=tkinter.BOTH)
-    tkinter.Button(SCREEN, text="使用自定义跨度", command=set_span, width=gui_width, height=1).pack()  # 切换笔
-    tkinter.Button(SCREEN, text="绘制函数", command=open_func_box, width=gui_width, height=gui_height).pack()
-    tkinter.Button(SCREEN, text="保存", command=choose_save, width=gui_width, height=1).pack()
-    tkinter.Button(SCREEN, text="载入", command=choose_open, width=gui_width, height=1).pack()
-    tkinter.Button(SCREEN, text="帮助", command=_help, width=gui_width, height=1).pack()  # help是系统保留关键词,用_help代替
+    tkinter.Button(
+        SCREEN,
+        text="使用自定义跨度",
+        bg=bg_color,
+        fg=word_color,
+        command=set_span,
+        width=gui_width,
+        height=1,
+    ).pack()  # 切换笔
+    tkinter.Button(
+        SCREEN,
+        text="绘制函数",
+        bg=bg_color,
+        fg=word_color,
+        command=open_func_box,
+        width=gui_width,
+        height=gui_height,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="保存",
+        bg=bg_color,
+        fg=word_color,
+        command=choose_save,
+        width=gui_width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="载入",
+        bg=bg_color,
+        fg=word_color,
+        command=choose_open,
+        width=gui_width,
+        height=1,
+    ).pack()
+    tkinter.Button(
+        SCREEN,
+        text="帮助",
+        bg=bg_color,
+        fg=word_color,
+        command=_help,
+        width=gui_width,
+        height=1,
+    ).pack()  # help是系统保留关键词,用_help代替
     SCREEN.mainloop()
     try:
         func = func_logger()

+ 39 - 38
funcsystem/map.py

@@ -3,8 +3,6 @@ import math
 import random
 import tkinter
 import tkinter.messagebox
-from tkinter.filedialog import asksaveasfile
-import tkinter.messagebox
 
 import numpy
 import pandas
@@ -19,7 +17,10 @@ func_str_list = []
 prompt_num = 0
 FONT = (r"Font\ZKST.ttf", 11)  # 设置字体
 SCREEN = tkinter.Tk()  # 设置屏幕
-
+bg_color = "#FFFAFA"  # 主颜色
+SCREEN["bg"] = bg_color
+botton_color = "#FFFAFA"  # 按钮颜色
+word_color = "#000000"  # 文字颜色
 line_style = {
     "实线": "-",
     "短横线": "--",
@@ -45,8 +46,8 @@ line_style = {
 point_style = ["g", "r", "c", "m", "y", "k"]
 csv_list = []
 
-gui_width = 12  # 标准宽度
-gui_height = 1
+gui_width = 13  # 标准宽度
+gui_height = 2
 
 
 def type_selection(iter_object, si=float, n=True):  # Float筛选系统
@@ -533,7 +534,7 @@ SCREEN.geometry(f"+10+10")
 rcParams["font.family"] = "simhei"
 rcParams["axes.unicode_minus"] = False
 tkinter.Label(
-    SCREEN, text="输入解析式:", font=FONT, width=gui_width, height=gui_height
+    SCREEN, text="输入解析式:", font=FONT, width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=0, row=0
 )  # 设置说明
@@ -542,7 +543,7 @@ func_exp.grid(column=1, row=0, columnspan=2, sticky=tkinter.E + tkinter.W)
 
 # 设置定义域
 tkinter.Label(
-    SCREEN, font=FONT, text="定义域:", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="定义域:", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=0, row=1
 )  # 设置说明
@@ -551,7 +552,7 @@ definition_domain.grid(column=1, row=1, columnspan=2, sticky=tkinter.E + tkinter
 
 # 设置函数名字
 tkinter.Label(
-    SCREEN, font=FONT, text="函数名字:", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="函数名字:", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=0, row=2
 )  # 设置说明
@@ -560,7 +561,7 @@ func_name.grid(column=1, row=2, columnspan=2, sticky=tkinter.E + tkinter.W)
 
 # 设置函数图示
 tkinter.Label(
-    SCREEN, font=FONT, text="函数样式:", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="函数样式:", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=0, row=3
 )  # 设置说明
@@ -574,7 +575,7 @@ tkinter.Button(
     command=add_func,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(
     column=0, row=a_y
 )  # 添加函数
@@ -584,7 +585,7 @@ tkinter.Button(
     command=del_func,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(
     column=1, row=a_y
 )  # 删除函数
@@ -594,14 +595,14 @@ tkinter.Button(
     command=clean_func_box,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(
     column=2, row=a_y
 )  # 绘制函数
 a_y += 1
 # 显示函数
 func_exp_box = tkinter.Listbox(SCREEN, width=gui_width * 3 + 2)  # 暂时不启用多选
-rowspan = 10
+rowspan = 12
 func_exp_box.grid(
     column=0,
     row=a_y,
@@ -610,15 +611,15 @@ func_exp_box.grid(
     sticky=tkinter.S + tkinter.N + tkinter.E + tkinter.W,
 )
 a_y += rowspan
-tkinter.Label(SCREEN, font=FONT, text="", width=gui_width, height=1).grid(
+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).grid(column=4, row=0)  # 占用第四
+tkinter.Label(SCREEN, font=FONT, text="", width=1, bg=bg_color, fg=word_color).grid(column=4, row=0)  # 占用第四
 a_y = 0
 # 输入x函数求y值
 tkinter.Label(
-    SCREEN, font=FONT, text="计算(y):", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="计算(y):", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -628,7 +629,7 @@ x_value.grid(column=6, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
 a_y += 1
 # 输入x函数求y值
 tkinter.Label(
-    SCREEN, font=FONT, text="二分法计算(y):", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="二分法计算(y):", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -637,7 +638,7 @@ y_value.grid(column=6, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
 
 a_y += 1
 tkinter.Label(
-    SCREEN, font=FONT, text="二分法参数:", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="二分法参数:", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -647,7 +648,7 @@ dicon_parameters.grid(column=6, row=a_y, columnspan=2, sticky=tkinter.E + tkinte
 a_y += 1
 # 输入x函数求y值
 tkinter.Label(
-    SCREEN, font=FONT, text="梯度法计算(y):", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="梯度法计算(y):", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -661,7 +662,7 @@ tkinter.Button(
     command=calculate,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -671,7 +672,7 @@ tkinter.Button(
     command=dichotomy,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=6, row=a_y)
 tkinter.Button(
     SCREEN,
@@ -679,7 +680,7 @@ tkinter.Button(
     command=gradient_method_calculation,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=7, row=a_y)
 
 a_y += 1
@@ -690,7 +691,7 @@ tkinter.Button(
     command=show_memory,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=5, row=a_y)
 tkinter.Button(
     SCREEN,
@@ -698,7 +699,7 @@ tkinter.Button(
     command=hide_memory,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=6, row=a_y)
 tkinter.Button(
     SCREEN,
@@ -706,12 +707,12 @@ tkinter.Button(
     command=clean_func_memory,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=7, row=a_y)
 
 a_y += 1
 # 显示函数
-result_box = tkinter.Listbox(SCREEN, width=gui_width * 3 + 2, height=17)  # 暂时不启用多选
+result_box = tkinter.Listbox(SCREEN, width=gui_width * 3 + 2, height=8)  # 暂时不启用多选
 result_box.grid(
     column=5, row=a_y, columnspan=3, sticky=tkinter.N + tkinter.E + tkinter.W
 )
@@ -719,7 +720,7 @@ result_box.grid(
 a_y += 1
 # 设置坐标系刻度
 tkinter.Label(
-    SCREEN, font=FONT, text="X轴(函数):", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="X轴(函数):", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y, sticky=tkinter.N
 )  # 设置说明
@@ -731,7 +732,7 @@ x_axis.grid(
 a_y += 1
 # 设置坐标系刻度
 tkinter.Label(
-    SCREEN, font=FONT, text="Y轴(函数):", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="Y轴(函数):", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -741,7 +742,7 @@ y_axis.grid(column=6, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
 a_y += 1
 # 设置坐标系刻度
 tkinter.Label(
-    SCREEN, font=FONT, text="X轴极限:", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="X轴极限:", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -751,7 +752,7 @@ x_limit.grid(column=6, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
 a_y += 1
 # 设置坐标系刻度
 tkinter.Label(
-    SCREEN, font=FONT, text="Y轴极限:", width=gui_width, height=gui_height
+    SCREEN, font=FONT, text="Y轴极限:", width=gui_width, height=gui_height, bg=bg_color, fg=word_color
 ).grid(
     column=5, row=a_y
 )  # 设置说明
@@ -765,7 +766,7 @@ tkinter.Button(
     command=plot_func,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(
     column=5, row=a_y
 )  # 绘制函数
@@ -775,7 +776,7 @@ tkinter.Button(
     command=property_prediction,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(
     column=6, row=a_y
 )  # 绘制函数
@@ -785,7 +786,7 @@ tkinter.Button(
     command=func_differentiation,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(
     column=7, row=a_y
 )  # 绘制函数
@@ -797,12 +798,12 @@ property_box.grid(
     column=5, row=a_y, columnspan=3, sticky=tkinter.N + tkinter.E + tkinter.W
 )
 a_y += 1
-prompt_box = tkinter.Listbox(SCREEN, width=gui_width * 3 + 2, height=5)  # 暂时不启用多选
+prompt_box = tkinter.Listbox(SCREEN, width=gui_width * 3 + 2, height=3)  # 暂时不启用多选
 prompt_box.grid(
     column=5, row=a_y, columnspan=3, sticky=tkinter.N + tkinter.E + tkinter.W
 )
 
-tkinter.Label(SCREEN, font=FONT, text="", width=1).grid(column=8, row=a_y)  # 占用第四
+tkinter.Label(SCREEN, font=FONT, text="", width=1, bg=bg_color, fg=word_color).grid(column=8, row=a_y)  # 占用第四
 a_y = 0
 
 # 绘制函数坐标表格
@@ -812,7 +813,7 @@ tkinter.Button(
     command=add_from_csv,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=9, row=a_y)
 tkinter.Button(
     SCREEN,
@@ -820,7 +821,7 @@ tkinter.Button(
     command=func_to_sheet,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=10, row=a_y)
 tkinter.Button(
     SCREEN,
@@ -828,7 +829,7 @@ tkinter.Button(
     command=func_to_csv,
     font=FONT,
     width=gui_width,
-    height=gui_height,
+    height=gui_height, bg=bg_color, fg=word_color,
 ).grid(column=11, row=a_y)
 
 a_y += 1

+ 1 - 1
gitrepo/gui.py

@@ -5,7 +5,7 @@ import os
 
 import tkinter.messagebox
 from tkinter import ttk
-from tkinter.filedialog import asksaveasfilename, askdirectory, askopenfilenames
+from newtkinter import asksaveasfilename, askdirectory, askopenfilenames
 from tkinter.scrolledtext import ScrolledText
 
 import gitrepo.template

+ 1 - 1
machinelearning/gui.py

@@ -2,7 +2,7 @@ import os
 import tkinter
 from tkinter.scrolledtext import ScrolledText
 import tkinter.messagebox
-from tkinter.filedialog import askopenfilename, asksaveasfilename, askdirectory
+from newtkinter import askopenfilename, asksaveasfilename, askdirectory
 import chardet
 import webbrowser
 

+ 38 - 0
drag/__init__.py → newtkinter/__init__.py

@@ -1,4 +1,5 @@
 import tkinter as tk
+from tkinter import filedialog
 
 
 class DragWindow(tk.Tk):
@@ -37,3 +38,40 @@ class DragWindow(tk.Tk):
     def _on_tap(self, event):
         self.root_x, self.root_y = event.x_root, event.y_root
         self.abs_x, self.abs_y = self.winfo_x(), self.winfo_y()
+
+# 重建文件读取类 askdirectory,askopenfilename,askopenfilenames,asksaveasfilename
+
+
+askopenfilenames = filedialog.askopenfilenames
+
+
+def askopenfilename(title, must=False, **parameters):
+    while True:
+        name = filedialog.askopenfilename(title=title, **parameters)
+        if name == '':
+            if not must:
+                raise NameError
+            continue
+        break
+    return name
+
+
+def asksaveasfilename(title, **parameters):
+    name: str = filedialog.asksaveasfilename(title=title, **parameters)
+    if name == '':
+        raise NameError
+    end = parameters.get('filetypes', [('', '')])[0][0]
+    if name.endswith(end):
+        return name
+    return name + end
+
+
+def askdirectory(title, must=False, **parameters):
+    while True:
+        name: str = filedialog.askdirectory(title=title, **parameters)
+        if name == '':
+            if not must:
+                raise NameError
+            continue
+        break
+    return name

+ 1 - 1
system/gui.py

@@ -1,5 +1,5 @@
 import tkinter
-from tkinter.filedialog import askopenfilename
+from newtkinter import askopenfilename
 from tkinter.messagebox import showwarning, askokcancel
 from tkinter.scrolledtext import ScrolledText