浏览代码

CGB函数PEP8整理

Huan 5 年之前
父节点
当前提交
a46b95d10a
共有 6 个文件被更改,包括 408 次插入408 次删除
  1. 35 35
      CGB/TK.py
  2. 15 15
      CGB/TK_DoneHS.py
  3. 44 44
      CGB/TK_HS.py
  4. 304 304
      CGB/Write.py
  5. 2 2
      CGB/__init__.py
  6. 8 8
      Hello.py

+ 35 - 35
CGB/TK.py

@@ -3,7 +3,7 @@ from tkinter.filedialog import asksaveasfile
 import tkinter.messagebox
 from CGB import TK_HS
 
-help_Wo='''
+help_doc= '''
 *快捷键:
     d-不用点击左键画线(再次点击关闭)
     g-画直线(2)
@@ -46,35 +46,35 @@ help_Wo='''
     绘制函数-绘制基本初等函数和字定义解析函数
 '''
 
-def GetZColor():
+def increasing_func_color():
     global ZColo
     ZColo = askcolor(title='选择颜色')[0]
 
-def GetJColor():
+def subtraction_func_color():
     global JColo
     JColo = askcolor(title='选择颜色')[0]
 
-def GetColor():
+def select_color():
     global colo
     colo = askcolor(title='选择颜色')[0]
 
-def getBC():
+def choose_save():
     global BC
     BC = tkinter.filedialog.asksaveasfilename(title='选择保存位置',filetypes=[("PNG", ".png")])
     if not BC:BC = None
     else:BC += '.png'
 
-def getBG():
+def choose_open():
     global BG_IM
     BG_IM = tkinter.filedialog.askopenfilename(title='选择载入图片',filetypes=[("PNG", ".png"),("JPG", ".jpg")])
     if not BG_IM: BG_IM = None
 
 
-def ChangePenSZ():
+def switch_brush():
     global d
     if tkinter.messagebox.askokcancel('提示', '要切换到刷子吗(可当橡皮使用)'):d = 10
 
-def ChangePenB():
+def switch_big():
     global d
     if tkinter.messagebox.askokcancel('提示', '要切换到大笔吗'):d = 3
 
@@ -87,33 +87,33 @@ def Set_d():
     except:
         if tkinter.messagebox.askokcancel('提示', '设置失败,是否要切换到中笔吗'): d = 2
 
-def ChangePenZ():
+def switch_stroke():
     global d
     if tkinter.messagebox.askokcancel('提示', '要切换到中笔吗'):d = 2
 
-def ChangePenS():
+def switch_small():
     global d
     if tkinter.messagebox.askokcancel('提示', '要切换到小笔吗?'):d = 1
 
-def ZBX_XY():
+def plot_coordinate():
     global XY
     if tkinter.messagebox.askokcancel('提示', '是否绘制坐标系,确定后返回草图界面任一点三点开始绘制(点击取消可撤销未执行的清空)'):
         XY = 1
     else:XY = None
 
-def ZBX_XY_XKD():
+def plot_coordinate_small():
     global XY
     if tkinter.messagebox.askokcancel('提示', '是否绘制小跨度的坐标系,确定后返回草图界面任一点三点开始绘制(点击取消可撤销未执行的清空)'):
         XY = 2
     else:XY = None
 
-def ZBX_XY_DKD():
+def plot_coordinate_big_span():
     global XY
     if tkinter.messagebox.askokcancel('提示', '是否绘制大跨度的坐标系,确定后返回草图界面任一点三点开始绘制(点击取消可撤销未执行的清空)'):
         XY = 3
     else:XY = None
 
-def Set_k():
+def set_span():
     global XY,k,k_Input
     Input = k_Input.get().replace(' ', '')
     try:
@@ -131,19 +131,19 @@ def Set_k():
         else:
             XY = None
 
-def QK():
+def empty():
     global BG
     if tkinter.messagebox.askokcancel('提示', '是否清空草稿(点击取消可撤销未执行的清空)'):
         BG = askcolor(title='选择背景颜色')[0]
     else:BG = None
 
-def HS():
+def open_func_box():
     global HS_List,closeable
-    HS_List = TK_HS.CHS()
+    HS_List = TK_HS.func_box()
 
 def _help():
-    global help_Wo
-    tkinter.messagebox.showinfo(title='帮助', message=help_Wo)
+    global help_doc
+    tkinter.messagebox.showinfo(title='帮助', message=help_doc)
 
 def close():#关闭屏幕事件
     global top
@@ -153,7 +153,7 @@ def close():#关闭屏幕事件
     except:pass
     top.destroy()
 
-def CC():
+def tool_box():
     global colo#三个月还有这个一般v额u
     global ZColo,JColo
     global top#初始化屏幕
@@ -186,26 +186,26 @@ def CC():
     top.resizable(width=False, height=False)
     top.geometry(f'+10+10')
 
-    tkinter.Button(top, text ="选择颜色", command = GetColor,width = w_b, height = h_b).pack()#选择颜色组件
-    tkinter.Button(top, text="选择增函数颜色", command=GetZColor, width=w_b, height=1).pack()  # 选择颜色组件
-    tkinter.Button(top, text="选择减函数颜色", command=GetJColor, width=w_b, height=1).pack()  # 选择颜色组件
-    tkinter.Button(top, text="使用中笔(默认笔)", command=ChangePenZ, width=w_b, height=h_b).pack()  # 切换笔
-    tkinter.Button(top, text="使用大笔", command = ChangePenB,width = w_b, height = 1).pack()  # 切换到大笔
-    tkinter.Button(top, text="使用小笔", command=ChangePenS, width=w_b, height=1).pack()  # 切换笔
-    tkinter.Button(top, text="使用刷子", command=ChangePenSZ, width=w_b, height=1).pack()  # 切换笔
+    tkinter.Button(top, text ="选择颜色", command = select_color, width = w_b, height = h_b).pack()#选择颜色组件
+    tkinter.Button(top, text="选择增函数颜色", command=increasing_func_color, width=w_b, height=1).pack()  # 选择颜色组件
+    tkinter.Button(top, text="选择减函数颜色", command=subtraction_func_color, width=w_b, height=1).pack()  # 选择颜色组件
+    tkinter.Button(top, text="使用中笔(默认笔)", command=switch_stroke, width=w_b, height=h_b).pack()  # 切换笔
+    tkinter.Button(top, text="使用大笔", command = switch_big, width = w_b, height = 1).pack()  # 切换到大笔
+    tkinter.Button(top, text="使用小笔", command=switch_small, width=w_b, height=1).pack()  # 切换笔
+    tkinter.Button(top, text="使用刷子", command=switch_brush, width=w_b, height=1).pack()  # 切换笔
     d_Input = tkinter.Entry(top, width=w_b-2)
     d_Input.pack(fill=tkinter.BOTH)
     tkinter.Button(top, text="使用自定义大小", command=Set_d, width=w_b, height=1).pack()  # 切换笔
-    tkinter.Button(top, text="清空草稿", command=QK, width=w_b, height=h_b).pack()  # 填充背景
-    tkinter.Button(top, text="绘制坐标系", command=ZBX_XY, width=w_b, height=h_b).pack()  # 绘制坐标系
-    tkinter.Button(top, text="绘制坐标系(小跨度)", command=ZBX_XY_XKD, width=w_b, height=1).pack()  # 绘制坐标系
-    tkinter.Button(top, text="绘制坐标系(大跨度)", command=ZBX_XY_DKD, width=w_b, height=1).pack()  # 绘制坐标系
+    tkinter.Button(top, text="清空草稿", command=empty, width=w_b, height=h_b).pack()  # 填充背景
+    tkinter.Button(top, text="绘制坐标系", command=plot_coordinate, width=w_b, height=h_b).pack()  # 绘制坐标系
+    tkinter.Button(top, text="绘制坐标系(小跨度)", command=plot_coordinate_small, width=w_b, height=1).pack()  # 绘制坐标系
+    tkinter.Button(top, text="绘制坐标系(大跨度)", command=plot_coordinate_big_span, width=w_b, height=1).pack()  # 绘制坐标系
     k_Input = tkinter.Entry(top, width=w_b-2)
     k_Input.pack(fill=tkinter.BOTH)
-    tkinter.Button(top, text="使用自定义跨度", command=Set_k, width=w_b, height=1).pack()  # 切换笔
-    tkinter.Button(top, text="绘制函数", command=HS, width=w_b, height=h_b).pack()
-    tkinter.Button(top, text="保存", command=getBC, width=w_b, height=1).pack()
-    tkinter.Button(top, text="载入", command=getBG, width=w_b, height=1).pack()
+    tkinter.Button(top, text="使用自定义跨度", command=set_span, width=w_b, height=1).pack()  # 切换笔
+    tkinter.Button(top, text="绘制函数", command=open_func_box, width=w_b, height=h_b).pack()
+    tkinter.Button(top, text="保存", command=choose_save, width=w_b, height=1).pack()
+    tkinter.Button(top, text="载入", command=choose_open, width=w_b, height=1).pack()
     tkinter.Button(top, text="帮助", command=_help, width=w_b, height=1).pack()#help是系统保留关键词,用_help代替
     top.protocol('WM_DELETE_WINDOW',close)
     top.mainloop()

+ 15 - 15
CGB/TK_DoneHS.py

@@ -1,7 +1,7 @@
 import tkinter
 import tkinter.messagebox
 import math
-help_Wo = '''
+help_doc = '''
 请在第一个输入框输入你的函数方程,不需要输入f(x)=和y=,唯一变量是x(x为自变量)
 圆周率-Pi,自然无理数-e
 指数的表示符号:**,比如x**2表示x的二次方
@@ -13,10 +13,10 @@ help_Wo = '''
 不支持定义域选择,不支持分段函数
 '''
 
-class HS_lambda:
-    def __init__(self,HS):
-        self.HS = HS
-        self.Name = {'x':0,'Pi':math.pi,'e':math.e,'log':math.log,
+class FunctionExpression:
+    def __init__(self, func):
+        self.FUNC = func
+        self.NAME = {'x':0, '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,
@@ -24,33 +24,33 @@ class HS_lambda:
                      'atan':math.atan}
 
     def __call__(self,x):
-        self.Name['x'] = x
-        return eval(self.HS,self.Name)
+        self.NAME['x'] = x
+        return eval(self.FUNC, self.NAME)
 
-def Sure():
-    global HS_Input,HS,help_Wo
+def determine():
+    global HS_Input,HS,help_doc
     Input = HS_Input.get().replace(' ', '')
     if Input:
         if tkinter.messagebox.askokcancel('提示', f'是否确认生成自定义函数:\n{HS_Input.get()}\n(点击取消可撤销未执行的制造函数)'):
-            HS = HS_lambda(HS_Input.get())
+            HS = FunctionExpression(HS_Input.get())
         else:HS = None
     else:
         if tkinter.messagebox.askokcancel('提示', f'点击确定撤销为执行的制造函数'):
             HS = None
 
-def Help():
-    tkinter.messagebox.showinfo(title='帮助', message=help_Wo)
+def get_help():
+    tkinter.messagebox.showinfo(title='帮助', message=help_doc)
 
 
-def Done_HS():
+def make_func():
     global HS_Input,HS,top
     HS = None
     top = tkinter.Tk()  # 设置屏幕
     top.title('')
     top.resizable(width=False, height=False)
     top.geometry(f'+350+10')
-    button = tkinter.Button(top, text="制造函数", command=Sure,width=28,height=1)  # 收到消息执行这个函数
-    help = tkinter.Button(top, text="帮助", command=Help, width=28, height=1)  # 帮助菜单
+    button = tkinter.Button(top, text="制造函数", command=determine, width=28, height=1)  # 收到消息执行这个函数
+    help = tkinter.Button(top, text="帮助", command=get_help, width=28, height=1)  # 帮助菜单
     HS_Input = tkinter.Entry(top)
     HS_Input.pack(fill=tkinter.BOTH)
     button.pack()

+ 44 - 44
CGB/TK_HS.py

@@ -2,149 +2,149 @@ import tkinter.messagebox
 import math
 from CGB import TK_DoneHS
 
-def HS_1():
+def linear_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制1次函数(点击取消可撤销未执行的函数)'):
         HS_List[1] = lambda x:x
     else:
         HS_List[1] = None
 
-def HS_2():
+def quadratic_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制2次函数(点击取消可撤销未执行的函数)'):
         HS_List[2] = lambda x:x**2
     else:
         HS_List[2] = None
 
-def HS_3():
+def cubic_function():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制3次函数(点击取消可撤销未执行的函数)'):
         HS_List[4] = lambda x:x**3
     else:
         HS_List[4] = None
 
-def HS_D1():
+def inverse_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制-1次函数(点击取消可撤销未执行的函数)'):
         HS_List[3] = lambda x:1/x
     else:
         HS_List[3] = None
 
-def HS_GH():
+def radical_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制根号函数(点击取消可撤销未执行的函数)'):
         HS_List[5] = lambda x:x**(1/2)
     else:
         HS_List[5] = None
 
-def HS_ZS():
+def exp_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制指数函数(点击取消可撤销未执行的函数)'):
         HS_List[6] = lambda x:10**x
     else:
         HS_List[6] = None
 
-def HS_DS():
+def log_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制对数函数(点击取消可撤销未执行的函数)'):
         HS_List[7] = lambda x:math.log(x,2)
     else:
         HS_List[7] = None
 
-def HS_DS2():
+def log2_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制对数函数2(点击取消可撤销未执行的函数)'):
         HS_List[8] = lambda x:math.log(2,x)
     else:
         HS_List[8] = None
 
-def HS_sin():
+def sin_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制正弦函数(点击取消可撤销未执行的函数)'):
         HS_List[9] = lambda x:math.sin(x)
     else:
         HS_List[9] = None
 
-def HS_cos():
+def cos_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制余弦函数(点击取消可撤销未执行的函数)'):
         HS_List[10] = lambda x:math.cos(x)
     else:
         HS_List[10] = None
 
-def HS_tan():
+def tan_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制正切函数(点击取消可撤销未执行的函数)'):
         HS_List[11] = lambda x:math.tan(x)
     else:
         HS_List[11] = None
 
-def HS_cot():
+def cot_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制余切函数(点击取消可撤销未执行的函数)'):
         HS_List[12] = lambda x:1/math.tan(x)
     else:
         HS_List[12] = None
 
-def HS_sec():
+def sec_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制正割函数(点击取消可撤销未执行的函数)'):
         HS_List[13] = lambda x:1/math.cos(x)
     else:
         HS_List[13] = None
 
-def HS_csc():
+def csc_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制余割函数(点击取消可撤销未执行的函数)'):
         HS_List[11] = lambda x:1/math.sin(x)
     else:
         HS_List[11] = None
 
-def HS_arcsin():
+def arcsin_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制反正弦函数(点击取消可撤销未执行的函数)'):
         HS_List[12] = lambda x:math.asin(x)
     else:
         HS_List[12] = None
 
-def HS_arccos():
+def arccos_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制反余弦函数(点击取消可撤销未执行的函数)'):
         HS_List[13] = lambda x:math.acos(x)
     else:
         HS_List[13] = None
 
-def HS_arctan():
+def arctan_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制反正切函数(点击取消可撤销未执行的函数)'):
         HS_List[14] = lambda x:math.atan(x)
     else:
         HS_List[14] = None
 
-def HS_arccot():
+def arccot_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制反余切函数(点击取消可撤销未执行的函数)'):
         HS_List[15] = lambda x:1/math.atan(x)
     else:
         HS_List[15] = None
 
-def HS_arcsec():
+def arcsec_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制反正割函数(点击取消可撤销未执行的函数)'):
         HS_List[16] = lambda x:1/math.acos(x)
     else:
         HS_List[16] = None
 
-def HS_arccsc():
+def arccsc_func():
     global HS_List
     if tkinter.messagebox.askokcancel('提示', '是否绘制反余割函数(点击取消可撤销未执行的函数)'):
         HS_List[17] = lambda x:1/math.asin(x)
     else:
         HS_List[17] = None
 
-def HS_ZDY():
+def custom_func():
     global HS_List,Num
-    get = TK_DoneHS.Done_HS()
+    get = TK_DoneHS.make_func()
     if get != None:
         HS_List[Num] = get
         Num += 1
@@ -155,7 +155,7 @@ def close():
     except:pass
     top.destroy()
 
-def CHS():
+def func_box():
     global HS_List#绘制函数列表
     global Num,top
     Num = 18#字定义函数的序号
@@ -166,27 +166,27 @@ def CHS():
     top.title('')
     top.resizable(width=False, height=False)
     top.geometry(f'+180+10')
-    tkinter.Button(top, text="1次函数", command=HS_1, width=w_b, height=1).pack()
-    tkinter.Button(top, text="2次函数", command=HS_2, width=w_b, height=1).pack()
-    tkinter.Button(top, text="-1次函数", command=HS_D1, width=w_b, height=1).pack()
-    tkinter.Button(top, text="3次函数", command=HS_3, width=w_b, height=1).pack()
-    tkinter.Button(top, text="根号函数", command=HS_GH, width=w_b, height=1).pack()
-    tkinter.Button(top, text="对数函数", command=HS_DS, width=w_b, height=1).pack()
-    tkinter.Button(top, text="指数函数", command=HS_ZS, width=w_b, height=1).pack()
-    tkinter.Button(top, text="对数底函数", command=HS_DS2, width=w_b, height=1).pack()
-    tkinter.Button(top, text="sin函数", command=HS_sin, width=w_b, height=1).pack()
-    tkinter.Button(top, text="cos函数", command=HS_cos, width=w_b, height=1).pack()
-    tkinter.Button(top, text="tan函数", command=HS_tan, width=w_b, height=1).pack()
-    tkinter.Button(top, text="cot函数", command=HS_tan, width=w_b, height=1).pack()
-    tkinter.Button(top, text="csc函数", command=HS_csc, width=w_b, height=1).pack()
-    tkinter.Button(top, text="sec函数", command=HS_sec, width=w_b, height=1).pack()
-    tkinter.Button(top, text="arcsin函数", command=HS_arcsin, width=w_b, height=1).pack()
-    tkinter.Button(top, text="arccos函数", command=HS_arccos, width=w_b, height=1).pack()
-    tkinter.Button(top, text="arctan函数", command=HS_arctan, width=w_b, height=1).pack()
-    tkinter.Button(top, text="arccot函数", command=HS_arctan, width=w_b, height=1).pack()
-    tkinter.Button(top, text="arccsc函数", command=HS_arccsc, width=w_b, height=1).pack()
-    tkinter.Button(top, text="arcsec函数", command=HS_arcsec, width=w_b, height=1).pack()
-    tkinter.Button(top, text="自定义函数", command=HS_ZDY, width=w_b, height=3).pack()
+    tkinter.Button(top, text="1次函数", command=linear_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="2次函数", command=quadratic_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="-1次函数", command=inverse_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="3次函数", command=cubic_function, width=w_b, height=1).pack()
+    tkinter.Button(top, text="根号函数", command=radical_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="对数函数", command=log_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="指数函数", command=exp_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="对数底函数", command=log2_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="sin函数", command=sin_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="cos函数", command=cos_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="tan函数", command=tan_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="cot函数", command=tan_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="csc函数", command=csc_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="sec函数", command=sec_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="arcsin函数", command=arcsin_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="arccos函数", command=arccos_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="arctan函数", command=arctan_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="arccot函数", command=arccot_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="arccsc函数", command=arccsc_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="arcsec函数", command=arcsec_func, width=w_b, height=1).pack()
+    tkinter.Button(top, text="自定义函数", command=custom_func, width=w_b, height=3).pack()
     top.protocol('WM_DELETE_WINDOW', close)
     top.mainloop()
     return HS_List

+ 304 - 304
CGB/Write.py

@@ -1,17 +1,17 @@
 import pygame
 from pygame.locals import *
-from CGB.TK import CC
+from CGB.TK import tool_box
 import time
 import os
 
 #定义一些变量
-pen_C = [0, 0, 0]  # 画笔颜色
+PEN_C = [0, 0, 0]  # 画笔颜色
 Z_C = [0,0,255]
 J_C = [255,0,0]
-d = 2  # 圆形的粗细(线条*2)=中笔
+PEN_THICKNESS = 2  # 圆形的粗细(线条*2)=中笔
 m_x = None
 m_y = None  # 为画图所准备的
-Done = False  # 设置免按
+continuous_draw = False  # 设置免按
 XY = 0
 axy = [0, 0, 0]  # 坐标系
 XY_x = 0
@@ -22,27 +22,27 @@ X_L = []  # X个数
 Y_L = []  # Y个数
 X_M = []
 Y_M = []
-_KD = 60  # 坐标系跨度调节
+_span = 60  # 坐标系跨度调节
 
-ZJ = 0  # 中键模式
-Line = []  # 画线列表
-Rect = []  # 画矩阵和圆列表
-Poly = []  # 画多边形列表
+middle_key = 0  # 中键模式
+line = []  # 画线列表
+rect = []  # 画矩阵和圆列表
+poly = []  # 画多边形列表
 
-Talk = ''#设置备注
+tips = ''#设置备注
 
 BC_Dic = ''#保存路径
 Tip = [0,0,0,0,0]#底部显示信息[x,y,左键,中间,右键]
 
-Done_Name = {1:'绘制坐标系',2:'绘制直线(g)',3:'填充矩形(f)',4:'线条矩形(s)',
-             5:'绘制横线(k)',6:'绘制竖线(l)',7:'绘制多段线(j)',
-             8:'绘制横打点多段线(i)',9:'绘制竖打点多段线(u)',10:'坐标测绘(h)',
-             11:'绘制虚线(q)',12:'填充圆形(c)',13:'线条圆形(v)',14:'多边形(n-填充,m-线条)',
-             15:'填充椭圆形(e)',16:'线条椭圆形(r)',0:'None'}#快捷键名字
+mode = {1: '绘制坐标系', 2: '绘制直线(g)', 3: '填充矩形(f)', 4: '线条矩形(s)',
+        5:'绘制横线(k)', 6:'绘制竖线(l)', 7:'绘制多段线(j)',
+        8:'绘制横打点多段线(i)', 9:'绘制竖打点多段线(u)', 10:'坐标测绘(h)',
+        11:'绘制虚线(q)', 12:'填充圆形(c)', 13:'线条圆形(v)', 14:'多边形(n-填充,m-线条)',
+        15:'填充椭圆形(e)', 16:'线条椭圆形(r)', 0:'None'}#快捷键名字
 
 #绘制函数
-def HS(HS_list,JD = 1000):
-    global X_P,X_L,Y_C,Y_L,Y_M,X_M,pen_C,Z_C,J_C
+def func_draw(HS_list, JD = 1000):
+    global X_P,X_L,Y_C,Y_L,Y_M,X_M,PEN_C,Z_C,J_C
     c = [0,0,0]#增函数颜色
     X_Done = lambda x: (x - X_L[0]) / (X_L[1] - X_L[0]) * (X_P[1] - X_P[0]) + X_P[0]#x是数值,换算为像素
     Y_Done = lambda y: (y - Y_L[0]) / (Y_L[1] - Y_L[0]) * (Y_C[1] - Y_C[0]) + Y_C[0]  # x是数值,换算为像素
@@ -72,43 +72,43 @@ def HS(HS_list,JD = 1000):
                 if x1 != None:
                     if y1>y2:c=Z_C#增函数
                     elif y1<y2:c=J_C#减函数#改为检查Y数值而不是坐标
-                    pygame.draw.line(root, c, (int(x1),int(y1)), (int(x2),int(y2)), d)
+                    pygame.draw.line(root, c, (int(x1),int(y1)), (int(x2),int(y2)), PEN_THICKNESS)
                 x1 = x2
                 y1 = y2
         except IndexError:
             break
 
 #画曲线系统
-def draw_Line(xy,c=False):#c-是否带点
+def draw_line(xy, c=False):#c-是否带点
     global m_x,m_y
-    if c:pygame.draw.circle(root, pen_C, xy, d, 0)
+    if c:pygame.draw.circle(root, PEN_C, xy, PEN_THICKNESS, 0)
     if m_x != None:
-        pygame.draw.line(root,pen_C,(m_x,m_y), xy, d)
+        pygame.draw.line(root, PEN_C, (m_x, m_y), xy, PEN_THICKNESS)
     m_x = xy[0]
     m_y = xy[1]
 
 #绘制XY坐标系
-def XYZ_ZBX(s_x,s_y,p = (-100, 100),c = (-200, 100),kd = 10,b = 3,jt = 3,r = 3):
+def coordinate_draw(s_x, s_y, p = (-100, 100), c = (-200, 100), kd = 10, b = 3, jt = 3, r = 3):
     kd = abs(kd)#kd大于0
-    global d,XY_x,XY_y,X_L,X_P,Y_L,Y_C,X_M,Y_M
+    global PEN_THICKNESS,XY_x,XY_y,X_L,X_P,Y_L,Y_C,X_M,Y_M
     XY_x = s_x
     XY_y = s_y#存储原点坐标
     X_M = [s_x + p[0],s_x + p[1]]
     Y_M = [s_y + c[1],s_y + c[0]]
-    pygame.draw.circle(root, pen_C, (s_x, s_y), r, 0)#绘制原点
-    pygame.draw.line(root, pen_C, (s_x + p[0], s_y), (s_x + p[1], s_y), d)  # X轴,Y定
-    pygame.draw.line(root, pen_C, (s_x, s_y + c[0]), (s_x, s_y + c[1]), d)  # y轴,x定
+    pygame.draw.circle(root, PEN_C, (s_x, s_y), r, 0)#绘制原点
+    pygame.draw.line(root, PEN_C, (s_x + p[0], s_y), (s_x + p[1], s_y), PEN_THICKNESS)  # X轴,Y定
+    pygame.draw.line(root, PEN_C, (s_x, s_y + c[0]), (s_x, s_y + c[1]), PEN_THICKNESS)  # y轴,x定
     _a = 0#刻度统计
     _c = 0
     for i in range(s_x ,s_x + p[0], -kd):#右
         _a -= 1
-        pygame.draw.line(root, pen_C, (i, s_y + b), (i, s_y), d)
+        pygame.draw.line(root, PEN_C, (i, s_y + b), (i, s_y), PEN_THICKNESS)
         _c = i
     _b = 0
     _d = 0
     for i in range(s_x, s_x + p[1], kd):#刻度#左
         _b += 1
-        pygame.draw.line(root, pen_C, (i, s_y + b), (i, s_y), d)
+        pygame.draw.line(root, PEN_C, (i, s_y + b), (i, s_y), PEN_THICKNESS)
         _d = i
     X_L = [_a+1,_b-1]
     X_P = [_c,_d]
@@ -116,63 +116,63 @@ def XYZ_ZBX(s_x,s_y,p = (-100, 100),c = (-200, 100),kd = 10,b = 3,jt = 3,r = 3):
     _c = 0
     for i in range(s_y, s_y + c[0], -kd):#上
         _a += 1
-        pygame.draw.line(root, pen_C, (s_x + b, i), (s_x, i), d)
+        pygame.draw.line(root, PEN_C, (s_x + b, i), (s_x, i), PEN_THICKNESS)
         _c = i
     _b = 0
     _d = 0
     for i in range(s_y, s_y + c[1], kd):#下
         _b -= 1
-        pygame.draw.line(root, pen_C, (s_x + b, i), (s_x, i), d)
+        pygame.draw.line(root, PEN_C, (s_x + b, i), (s_x, i), PEN_THICKNESS)
         _d = i
     Y_L = [_b+1,_a-1]
     Y_C = [_d,_c]
 
     #箭头
-    pygame.draw.line(root, pen_C, (s_x + p[1], s_y), (s_x + p[1] - jt, s_y + jt), d)  # X上
-    pygame.draw.line(root, pen_C, (s_x + p[1], s_y), (s_x + p[1] - jt, s_y - jt), d)  # X下
+    pygame.draw.line(root, PEN_C, (s_x + p[1], s_y), (s_x + p[1] - jt, s_y + jt), PEN_THICKNESS)  # X上
+    pygame.draw.line(root, PEN_C, (s_x + p[1], s_y), (s_x + p[1] - jt, s_y - jt), PEN_THICKNESS)  # X下
 
-    pygame.draw.line(root, pen_C, (s_x, s_y + c[0]), (s_x - jt, s_y + c[0] + jt), d)  # y左
-    pygame.draw.line(root, pen_C, (s_x, s_y + c[0]), (s_x + jt, s_y + c[0] + jt), d)  # X下
+    pygame.draw.line(root, PEN_C, (s_x, s_y + c[0]), (s_x - jt, s_y + c[0] + jt), PEN_THICKNESS)  # y左
+    pygame.draw.line(root, PEN_C, (s_x, s_y + c[0]), (s_x + jt, s_y + c[0] + jt), PEN_THICKNESS)  # X下
 
-def New_Tip():
+def top_draw():
     #绘制顶部
-    global d,Font,Tip,Screen_x,Screen_y,ZJ,BC_Dic,Done_Name,Done,XY_x,XY_y,Talk,Line,Rect,Poly,pen_C,Z_C,J_C,axy,_KD
-    if Done:mod_d = '启动无点击画线(点击d关闭)'
+    global PEN_THICKNESS,Font,Tip,Screen_x,Screen_y,middle_key,BC_Dic,mode,continuous_draw,XY_x,XY_y,tips,line,rect,poly,PEN_C,Z_C,J_C,axy,_span
+    if continuous_draw:mod_d = '启动无点击画线(点击d关闭)'
     else:mod_d = '关闭无点击画线'
     pygame.draw.rect(root,[255,255,255], [0,0,Screen_x,16], 0)
     pygame.draw.rect(root, [255, 255, 255], [0, Screen_y-16, Screen_x, Screen_y], 0)
     p = ''
-    if ZJ == 0: Talk = ''
+    if middle_key == 0: tips = ''
     if axy != [0,0,0]:
         a = []
         for i in axy:
             if i != 0:a.append(i)
         p += f'坐标端点:{str(a)}  '
-    if Line:
-        p += f'端点:{str(Line)}  '
-    if Rect:
-        p += f'顶点(圆心):{str(Rect)}  '
-    if Poly:
-        p += f'多顶点:{str(Poly)}  '
-    if Done or ZJ != 0:
-        TIP3 = Font.render(f'模式:{mod_d} , {Done_Name[ZJ]} {Talk}', True, (0, 0, 0))
+    if line:
+        p += f'端点:{str(line)}  '
+    if rect:
+        p += f'顶点(圆心):{str(rect)}  '
+    if poly:
+        p += f'多顶点:{str(poly)}  '
+    if continuous_draw or middle_key != 0:
+        TIP3 = Font.render(f'模式:{mod_d} , {mode[middle_key]} {tips}', True, (0, 0, 0))
     else:
         s = ''
         if BC_Dic:s = f'保存路径(w):{BC_Dic}'
         TIP3 = Font.render(f'{time.strftime("%Y/%m/%d  %I:%M")}  {s}', True, (0, 0, 0))
         p = ''
     if p == '':
-        p = f'主色调:{pen_C} 增函数颜色:{Z_C} 减函数颜色:{J_C}'
+        p = f'主色调:{PEN_C} 增函数颜色:{Z_C} 减函数颜色:{J_C}'
     TIP = Font.render(f'鼠标:{Tip[0]},{Tip[1]}',True, (0, 0, 0))
-    TIP2 = Font.render(f'{Tip[2]},{Tip[3]},{Tip[4]} ; 大小:{d} ; 原点:{XY_x},{XY_y} ; 跨度:{_KD} ; {p}', True, (0, 0, 0))
+    TIP2 = Font.render(f'{Tip[2]},{Tip[3]},{Tip[4]} ; 大小:{PEN_THICKNESS} ; 原点:{XY_x},{XY_y} ; 跨度:{_span} ; {p}', True, (0, 0, 0))
     root.blit(TIP, (0, 0))
     root.blit(TIP2, (100, 0))
     root.blit(TIP3, (0, Screen_y - 16))
 
 #主程序
-def Draw(dis_x=900,dis_y=700):
-    global m_x, m_y,pen_C,d,BG,XY,axy,XY_x,XY_y,_KD,Line,Done,ZJ,Rect,Poly,root,root_caption,done,m_x, m_y,BC_Dic#定义全局变量
-    global Z_C,J_C,Tip,Font,Screen_x,Screen_y,Talk,Font
+def draw_main(dis_x=900, dis_y=700):
+    global m_x, m_y,PEN_C,PEN_THICKNESS,BG,XY,axy,XY_x,XY_y,_span,line,continuous_draw,middle_key,rect,poly,root,root_caption,done,m_x, m_y,BC_Dic#定义全局变量
+    global Z_C,J_C,Tip,Font,Screen_x,Screen_y,tips,Font
     Screen_x = dis_x
     Screen_y = dis_y
     done = pygame.init()  # 初始化所有模块
@@ -183,7 +183,7 @@ def Draw(dis_x=900,dis_y=700):
     root.fill([255, 255, 255])  # 默认用白色填充窗口
     flat = True#循环条件(不是全局)
     while flat:
-        New_Tip()
+        top_draw()
         pygame.display.update()#屏幕刷新
         for event in pygame.event.get():#事件检查
             if event.type == QUIT:#退出事件
@@ -194,10 +194,10 @@ def Draw(dis_x=900,dis_y=700):
                 Tip[0],Tip[1] = event.pos
                 Tip[2],Tip[3],Tip[4] = event.buttons
                 if event.buttons == (1, 0, 0):#左键点击
-                    draw_Line(event.pos)
+                    draw_line(event.pos)
                 elif event.buttons == (0, 0, 0):#无点击绘图(启动快捷键d)
-                    if Done:
-                        draw_Line(event.pos)
+                    if continuous_draw:
+                        draw_line(event.pos)
                     else:#m_x和m_y是指上一点的xy,用于画线系统
                         m_x = None
                         m_y = None
@@ -210,40 +210,40 @@ def Draw(dis_x=900,dis_y=700):
                     bg = pygame.image.load('$CoTanCC.png').convert()#加载位图
                     root.blit(bg, (0, 0))#绘制位图
                     pygame.display.update()#更新屏幕
-                    g = CC()#启动工具箱
+                    g = tool_box()#启动工具箱
                     root = pygame.display.set_mode((dis_x, dis_y), 0)#显示关闭按钮
                     bg = pygame.image.load('$CoTanCC.png').convert()#加载位图
                     root.blit(bg, (0, 0))#绘制位图
                     pygame.display.update()#更新屏幕
                     os.remove('$CoTanCC.png')
-                    if g[0] != None:pen_C = g[0]#设置颜色
-                    if g[1] != None:d = g[1]#设置笔的粗细
+                    if g[0] != None:PEN_C = g[0]#设置颜色
+                    if g[1] != None:PEN_THICKNESS = g[1]#设置笔的粗细
                     if g[2] != None: root.fill(g[2])#设置背景填充
                     if g[3] == 1:#绘制坐标系
-                        Talk = '选择坐标三个端点'
-                        ZJ = 1
+                        tips = '选择坐标三个端点'
+                        middle_key = 1
                         XY = 3
-                        _KD = 60
+                        _span = 60
                     elif g[3] == 2:#绘制坐标系2(小跨度)
-                        Talk = '选择坐标三个端点'
-                        ZJ = 1
+                        tips = '选择坐标三个端点'
+                        middle_key = 1
                         XY = 3
-                        _KD = 20
+                        _span = 20
                     elif g[3] == 3:#绘制坐标系3(大跨度)
-                        Talk = '选择坐标三个端点'
-                        ZJ = 1
+                        tips = '选择坐标三个端点'
+                        middle_key = 1
                         XY = 3
-                        _KD = 120#坐标系跨度(字定义跨度再下面)
+                        _span = 120#坐标系跨度(字定义跨度再下面)
                     else:
-                        ZJ = 0
+                        middle_key = 0
                         XY = 0#恢复选项
                     if g[6] != None: Z_C = g[6]  # 增函数颜色(要在函数绘制之前设置好)
                     if g[7] != None: J_C = g[7]  # 减函数颜色
-                    if g[4] != {}:HS(g[4])#函数绘制
+                    if g[4] != {}:func_draw(g[4])#函数绘制
                     if g[5] != None:
                         pygame.image.save(root, g[5])  # 保存当前环境
                         BC_Dic = g[5]
-                    if g[8] != None: _KD = g[8]  # 自定义跨度
+                    if g[8] != None: _span = g[8]  # 自定义跨度
                     if g[9] != None:
                         try:
                             bg_im = pygame.image.load(g[9]).convert()  # 加载位图
@@ -252,12 +252,12 @@ def Draw(dis_x=900,dis_y=700):
                     #恢复参数
                     m_x = None
                     m_y = None
-                    Done = False
+                    continuous_draw = False
                     pygame.event.clear()
                 elif event.button == 2:#中键点击,ZJ是指中键的模式,来自快捷键和工具箱
                     Tip[3] = 1
-                    if ZJ == 1:#坐标系模式
-                        Talk = '选择下一个端点(共3个)'
+                    if middle_key == 1:#坐标系模式
+                        tips = '选择下一个端点(共3个)'
                         axy[XY-1] = event.pos#存储
                         XY -= 1
                         if XY == 0:
@@ -272,69 +272,69 @@ def Draw(dis_x=900,dis_y=700):
                             s_y = y[1]
                             p = (-abs(x[0] - x[1]), abs(x[1] - x[2]))
                             c = (-abs(y[0] - y[1]), abs(y[1] - y[2]))
-                            b = 2 * d
-                            r = 2 * d
-                            jt = 3 * d
-                            XYZ_ZBX(s_x,s_y,p,c,_KD,b,jt,r)
+                            b = 2 * PEN_THICKNESS
+                            r = 2 * PEN_THICKNESS
+                            jt = 3 * PEN_THICKNESS
+                            coordinate_draw(s_x, s_y, p, c, _span, b, jt, r)
                             axy = [0,0,0]
-                            ZJ = 0
-                    elif ZJ == 2:#画线模式
-                        Line.append(event.pos)
+                            middle_key = 0
+                    elif middle_key == 2:#画线模式
+                        line.append(event.pos)
                         # pygame.draw.circle(root, pen_C, event.pos, d, 0)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0],Line[1], d)
-                            ZJ = 0
-                    elif ZJ == 3 or ZJ == 4:#画矩形模式
-                        Rect.append(event.pos)
-                        if len(Rect) == 2:
-                            x = [Rect[0][0],Rect[1][0]]
-                            y = [Rect[0][1],Rect[1][1]]
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], line[1], PEN_THICKNESS)
+                            middle_key = 0
+                    elif middle_key == 3 or middle_key == 4:#画矩形模式
+                        rect.append(event.pos)
+                        if len(rect) == 2:
+                            x = [rect[0][0], rect[1][0]]
+                            y = [rect[0][1], rect[1][1]]
                             x.sort();y.sort()
-                            if ZJ == 3:dx = 0
-                            else:dx = d
-                            pygame.draw.rect(root, pen_C, [x[0], y[0], x[1]-x[0], y[1]-y[0]], dx)
-                            ZJ = 0
-                    elif ZJ == 5:#画横线模式
-                        Line.append(event.pos)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0],(Line[1][0],Line[0][1]), d)
-                            ZJ = 0
-                    elif ZJ == 6:#画竖线模式
-                        Line.append(event.pos)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0],(Line[0][0],Line[1][1]), d)
-                            ZJ = 0
-                    elif ZJ == 7:#画线多段线
-                        Line.append(event.pos)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0],Line[1], d)
-                            del Line[0]
-                    elif ZJ == 8:#画横线多段线
-                        Line.append(event.pos)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0],(Line[1][0],Line[0][1]), d)
-                            pygame.draw.circle(root, pen_C, (Line[1][0],Line[0][1]), d*2, 0)
-                            del Line[1]
+                            if middle_key == 3:dx = 0
+                            else:dx = PEN_THICKNESS
+                            pygame.draw.rect(root, PEN_C, [x[0], y[0], x[1] - x[0], y[1] - y[0]], dx)
+                            middle_key = 0
+                    elif middle_key == 5:#画横线模式
+                        line.append(event.pos)
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], (line[1][0], line[0][1]), PEN_THICKNESS)
+                            middle_key = 0
+                    elif middle_key == 6:#画竖线模式
+                        line.append(event.pos)
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], (line[0][0], line[1][1]), PEN_THICKNESS)
+                            middle_key = 0
+                    elif middle_key == 7:#画线多段线
+                        line.append(event.pos)
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], line[1], PEN_THICKNESS)
+                            del line[0]
+                    elif middle_key == 8:#画横线多段线
+                        line.append(event.pos)
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], (line[1][0], line[0][1]), PEN_THICKNESS)
+                            pygame.draw.circle(root, PEN_C, (line[1][0], line[0][1]), PEN_THICKNESS * 2, 0)
+                            del line[1]
                         else:
-                            pygame.draw.circle(root, pen_C, event.pos, d, 0)
-                    elif ZJ == 9:#画竖线多段线
-                        Line.append(event.pos)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0],(Line[0][0],Line[1][1]), d)
-                            pygame.draw.circle(root, pen_C, (Line[0][0],Line[1][1]), d*2, 0)
-                            del Line[1]
+                            pygame.draw.circle(root, PEN_C, event.pos, PEN_THICKNESS, 0)
+                    elif middle_key == 9:#画竖线多段线
+                        line.append(event.pos)
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], (line[0][0], line[1][1]), PEN_THICKNESS)
+                            pygame.draw.circle(root, PEN_C, (line[0][0], line[1][1]), PEN_THICKNESS * 2, 0)
+                            del line[1]
                         else:
-                            pygame.draw.circle(root, pen_C, event.pos, d, 0)
-                    elif ZJ == 10:#画竖线和横线多段线
-                        Line.append(event.pos)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0], (Line[1][0], Line[0][1]), d)#横线
-                            pygame.draw.circle(root, pen_C, (Line[1][0], Line[0][1]), d*2, 0)
-                            pygame.draw.circle(root, pen_C, (Line[1][0], Line[1][1]), d * 2, 0)
-                            pygame.draw.line(root, pen_C, Line[0],(Line[0][0],Line[1][1]), d)#竖线
-                            pygame.draw.circle(root, pen_C, (Line[0][0],Line[1][1]), d*2, 0)
+                            pygame.draw.circle(root, PEN_C, event.pos, PEN_THICKNESS, 0)
+                    elif middle_key == 10:#画竖线和横线多段线
+                        line.append(event.pos)
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], (line[1][0], line[0][1]), PEN_THICKNESS)#横线
+                            pygame.draw.circle(root, PEN_C, (line[1][0], line[0][1]), PEN_THICKNESS * 2, 0)
+                            pygame.draw.circle(root, PEN_C, (line[1][0], line[1][1]), PEN_THICKNESS * 2, 0)
+                            pygame.draw.line(root, PEN_C, line[0], (line[0][0], line[1][1]), PEN_THICKNESS)#竖线
+                            pygame.draw.circle(root, PEN_C, (line[0][0], line[1][1]), PEN_THICKNESS * 2, 0)
                             #垂直于横线的虚线
-                            p = [Line[1][1],Line[0][1]]
+                            p = [line[1][1], line[0][1]]
                             p.sort()
                             Y1 = p[0]
                             Y2 = p[1]
@@ -344,9 +344,9 @@ def Draw(dis_x=900,dis_y=700):
                                 i = 2 * i - 1
                                 y1 = a[i - 1]  # 计算两点的y坐标
                                 y2 = a[i]
-                                pygame.draw.line(root, pen_C, (Line[1][0], y1), (Line[1][0], y2), d)  # 横线
+                                pygame.draw.line(root, PEN_C, (line[1][0], y1), (line[1][0], y2), PEN_THICKNESS)  # 横线
                             # 垂直于竖线的虚线
-                            p = [Line[1][0],Line[0][0]]
+                            p = [line[1][0], line[0][0]]
                             p.sort()
                             X1 = p[0]
                             X2 = p[1]
@@ -356,17 +356,17 @@ def Draw(dis_x=900,dis_y=700):
                                 i = 2 * i - 1
                                 x1 = a[i - 1]  # 计算两点的x坐标
                                 x2 = a[i]
-                                pygame.draw.line(root, pen_C, (x1, Line[1][1]), (x2, Line[1][1]), d)  # 横线
-                            del Line[1]
+                                pygame.draw.line(root, PEN_C, (x1, line[1][1]), (x2, line[1][1]), PEN_THICKNESS)  # 横线
+                            del line[1]
                         else:
-                            pygame.draw.circle(root, pen_C, event.pos, d, 0)
-                    elif ZJ == 11:#画虚线线模式
-                        Line.append(event.pos)
-                        pygame.draw.circle(root, pen_C, event.pos, d, 0)
-                        if len(Line) == 2:
-                            if abs(Line[0][0]- Line[1][0]) >= 100:
-                                p1 = [Line[0][0],Line[1][0]]
-                                p2 = {Line[0][0]:Line[0][1],Line[1][0]:Line[1][1]}
+                            pygame.draw.circle(root, PEN_C, event.pos, PEN_THICKNESS, 0)
+                    elif middle_key == 11:#画虚线线模式
+                        line.append(event.pos)
+                        pygame.draw.circle(root, PEN_C, event.pos, PEN_THICKNESS, 0)
+                        if len(line) == 2:
+                            if abs(line[0][0] - line[1][0]) >= 100:
+                                p1 = [line[0][0], line[1][0]]
+                                p2 = {line[0][0]:line[0][1], line[1][0]:line[1][1]}
                                 p1.sort()
                                 X1 = p1[0]
                                 Y1 = p2[X1]
@@ -380,10 +380,10 @@ def Draw(dis_x=900,dis_y=700):
                                     x2 = a[i]
                                     y1 = (x1 - X1) / (X2 - X1) * (Y2 - Y1) + Y1
                                     y2 = (x2 - X1) / (X2 - X1) * (Y2 - Y1) + Y1
-                                    pygame.draw.line(root, pen_C, (x1, y1), (x2, y2), d)  # 横线
-                            elif abs(Line[0][1]- Line[1][1]) >= 100:
-                                p1 = [Line[0][1], Line[1][1]]
-                                p2 = {Line[0][1]: Line[0][0], Line[1][1]: Line[1][0]}
+                                    pygame.draw.line(root, PEN_C, (x1, y1), (x2, y2), PEN_THICKNESS)  # 横线
+                            elif abs(line[0][1] - line[1][1]) >= 100:
+                                p1 = [line[0][1], line[1][1]]
+                                p2 = {line[0][1]: line[0][0], line[1][1]: line[1][0]}
                                 p1.sort()
                                 Y1 = p1[0]
                                 X1 = p2[Y1]
@@ -397,207 +397,207 @@ def Draw(dis_x=900,dis_y=700):
                                     y2 = a[i]
                                     x1 = (y1 - Y1) / (Y2 - Y1) * (X2 - X1) + X1
                                     x2 = (y2 - Y1) / (Y2 - Y1) * (X2 - X1) + X1
-                                    pygame.draw.line(root, pen_C, (x1, y1), (x2, y2), d)  # 横线
+                                    pygame.draw.line(root, PEN_C, (x1, y1), (x2, y2), PEN_THICKNESS)  # 横线
                             else:
-                                pygame.draw.line(root, pen_C, Line[1], Line[0], d)
-                            ZJ = 0
-                    elif ZJ == 12:#画圆模式
-                        Rect.append(event.pos)
-                        if len(Rect) == 2:
-                            r = int(((Rect[0][0]-Rect[1][0])**2 + (Rect[0][1]-Rect[1][1])**2)**(1/2))#两点间求距离
-                            pygame.draw.circle(root, pen_C, Rect[0], r, 0)
-                            ZJ = 0
+                                pygame.draw.line(root, PEN_C, line[1], line[0], PEN_THICKNESS)
+                            middle_key = 0
+                    elif middle_key == 12:#画圆模式
+                        rect.append(event.pos)
+                        if len(rect) == 2:
+                            r = int(((rect[0][0] - rect[1][0]) ** 2 + (rect[0][1] - rect[1][1]) ** 2) ** (1 / 2))#两点间求距离
+                            pygame.draw.circle(root, PEN_C, rect[0], r, 0)
+                            middle_key = 0
                         else:
-                            pygame.draw.circle(root, pen_C, Rect[0], d*2, 0)
-                    elif ZJ == 13:#画圆线框模式
-                        Rect.append(event.pos)
-                        if len(Rect) == 2:
-                            r = int(((Rect[0][0]-Rect[1][0])**2 + (Rect[0][1]-Rect[1][1])**2)**(1/2))#两点间求距离
-                            pygame.draw.circle(root, pen_C, Rect[0], r, d)
-                            ZJ = 0
+                            pygame.draw.circle(root, PEN_C, rect[0], PEN_THICKNESS * 2, 0)
+                    elif middle_key == 13:#画圆线框模式
+                        rect.append(event.pos)
+                        if len(rect) == 2:
+                            r = int(((rect[0][0] - rect[1][0]) ** 2 + (rect[0][1] - rect[1][1]) ** 2) ** (1 / 2))#两点间求距离
+                            pygame.draw.circle(root, PEN_C, rect[0], r, PEN_THICKNESS)
+                            middle_key = 0
                         else:
-                            pygame.draw.circle(root, pen_C, Rect[0], d, 0)
-                    elif ZJ == 14:  # 画多边形模式
-                        Line.append(event.pos)
-                        if len(Line) == 2:
-                            pygame.draw.line(root, pen_C, Line[0], Line[1], d)
-                            del Line[0]
-                        Poly.append(event.pos)
-                    elif ZJ == 15:#画椭圆模式
-                        Rect.append(event.pos)
-                        if len(Rect) == 2:
-                            x = [Rect[0][0],Rect[1][0]]
-                            y = [Rect[0][1],Rect[1][1]]
+                            pygame.draw.circle(root, PEN_C, rect[0], PEN_THICKNESS, 0)
+                    elif middle_key == 14:  # 画多边形模式
+                        line.append(event.pos)
+                        if len(line) == 2:
+                            pygame.draw.line(root, PEN_C, line[0], line[1], PEN_THICKNESS)
+                            del line[0]
+                        poly.append(event.pos)
+                    elif middle_key == 15:#画椭圆模式
+                        rect.append(event.pos)
+                        if len(rect) == 2:
+                            x = [rect[0][0], rect[1][0]]
+                            y = [rect[0][1], rect[1][1]]
                             x.sort();y.sort()
-                            pygame.draw.ellipse(root, pen_C,[x[0], y[0], x[1]-x[0], y[1]-y[0]], 0)
-                            ZJ = 0
-                    elif ZJ == 16:#画椭圆边框模式
-                        Rect.append(event.pos)
-                        if len(Rect) == 2:
-                            x = [Rect[0][0],Rect[1][0]]
-                            y = [Rect[0][1],Rect[1][1]]
+                            pygame.draw.ellipse(root, PEN_C, [x[0], y[0], x[1] - x[0], y[1] - y[0]], 0)
+                            middle_key = 0
+                    elif middle_key == 16:#画椭圆边框模式
+                        rect.append(event.pos)
+                        if len(rect) == 2:
+                            x = [rect[0][0], rect[1][0]]
+                            y = [rect[0][1], rect[1][1]]
                             x.sort();y.sort()
-                            pygame.draw.ellipse(root, pen_C,[x[0], y[0], x[1]-x[0], y[1]-y[0]], d)
-                            ZJ = 0
+                            pygame.draw.ellipse(root, PEN_C, [x[0], y[0], x[1] - x[0], y[1] - y[0]], PEN_THICKNESS)
+                            middle_key = 0
                 elif event.button == 1:
                     Tip[2] = 1
-                    pygame.draw.circle(root, pen_C, event.pos, d, 0)
+                    pygame.draw.circle(root, PEN_C, event.pos, PEN_THICKNESS, 0)
                     m_x = event.pos[0]
                     m_y = event.pos[1]
             elif event.type == KEYDOWN:#键盘按下(长按不算)快捷键
                 if event.key == K_d:#不用点击左键画线
-                    if Done:
-                        Done = False
+                    if continuous_draw:
+                        continuous_draw = False
                     else:
-                        Done = True
+                        continuous_draw = True
                         m_x = None
                         m_y = None
                 elif event.key == K_g:#画直线
-                    Talk = '根据两个端点画直线'
-                    ZJ = 2
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    tips = '根据两个端点画直线'
+                    middle_key = 2
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_f:#画矩阵
-                    ZJ = 3
-                    Talk = '根据两个相对的顶点绘制矩形'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 3
+                    tips = '根据两个相对的顶点绘制矩形'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_s:#画矩阵边框
-                    ZJ = 4
-                    Talk = '根据两个相对的顶点绘制矩形'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 4
+                    tips = '根据两个相对的顶点绘制矩形'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_k:#画横线
-                    ZJ = 5
-                    Talk = '选择起点和与终点y坐标相同的点'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 5
+                    tips = '选择起点和与终点y坐标相同的点'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_l:#画竖线
-                    ZJ = 6
-                    Talk = '选择起点和与终点x坐标相同的点'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 6
+                    tips = '选择起点和与终点x坐标相同的点'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_j:#多段线
-                    if ZJ == 7:
-                        ZJ = 0
+                    if middle_key == 7:
+                        middle_key = 0
                     else:
-                        ZJ = 7
-                        Talk = '依次选择多段线的顶点'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                        middle_key = 7
+                        tips = '依次选择多段线的顶点'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_i:#多段线横线打点
-                    if ZJ == 8:
-                        ZJ = 0
+                    if middle_key == 8:
+                        middle_key = 0
                     else:
-                        ZJ = 8
-                        Talk = '选择终点,依次选择与其他端点y坐标相同的点(点击i结束)'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                        middle_key = 8
+                        tips = '选择终点,依次选择与其他端点y坐标相同的点(点击i结束)'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_u:#多段线竖线打点
-                    if ZJ == 9:
-                        ZJ = 0
+                    if middle_key == 9:
+                        middle_key = 0
                     else:
-                        ZJ = 9
-                        Talk = '选择终点,依次选择与其他端点x坐标相同的点(点击u结束)'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                        middle_key = 9
+                        tips = '选择终点,依次选择与其他端点x坐标相同的点(点击u结束)'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_h:#多段横竖线打点
-                    if ZJ == 10:
-                        ZJ = 0
+                    if middle_key == 10:
+                        middle_key = 0
                     else:
-                        ZJ = 10
-                        Talk = '选择参考点,再选择研究对象(点击h结束)'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                        middle_key = 10
+                        tips = '选择参考点,再选择研究对象(点击h结束)'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_q:#绘制虚线
-                    ZJ = 11
-                    Talk = '选择虚线的两个端点'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 11
+                    tips = '选择虚线的两个端点'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_c:#绘制圆形
-                    ZJ = 12
-                    Talk = '选择圆形和圆上任意一点(确定半径)'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 12
+                    tips = '选择圆形和圆上任意一点(确定半径)'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_v:#绘制圆形线框
-                    ZJ = 13
-                    Talk = '选择圆形和圆上任意一点(确定半径)'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 13
+                    tips = '选择圆形和圆上任意一点(确定半径)'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_o:#捕捉
-                    Talk = '起点已经捕捉到坐标系原点了'
-                    Line=[[XY_x,XY_y]]
-                    Rect=[[XY_x,XY_y]]
-                    Poly=[[XY_x,XY_y]]
+                    tips = '起点已经捕捉到坐标系原点了'
+                    line=[[XY_x, XY_y]]
+                    rect=[[XY_x, XY_y]]
+                    poly=[[XY_x, XY_y]]
                 elif event.key == K_y:#捕捉上y轴
-                    if len(Line) >= 1:
-                        Talk = '起点已经移动到坐标系y轴上了'
-                        Line[0][0] = XY_x
-                    if len(Rect) >= 1:
-                        Talk = '起点已经移动到坐标系y轴上了'
-                        Rect[0][0] = XY_x
-                    if len(Poly) >= 1:
-                        Talk = '起点已经移动到坐标系y轴上了'
-                        Rect[0][0] = XY_x
+                    if len(line) >= 1:
+                        tips = '起点已经移动到坐标系y轴上了'
+                        line[0][0] = XY_x
+                    if len(rect) >= 1:
+                        tips = '起点已经移动到坐标系y轴上了'
+                        rect[0][0] = XY_x
+                    if len(poly) >= 1:
+                        tips = '起点已经移动到坐标系y轴上了'
+                        rect[0][0] = XY_x
                 elif event.key == K_x:#捕捉上x轴
-                    if len(Line) >= 1:
-                        Talk = '起点已经移动到坐标系x轴上了'
-                        Line[0][1] = XY_y
-                    if len(Rect) >= 1:
-                        Talk = '起点已经移动到坐标系x轴上了'
-                        Rect[0][1] = XY_y
-                    if len(Poly) >= 1:
-                        Talk = '起点已经移动到坐标系x轴上了'
-                        Rect[0][1] = XY_y
+                    if len(line) >= 1:
+                        tips = '起点已经移动到坐标系x轴上了'
+                        line[0][1] = XY_y
+                    if len(rect) >= 1:
+                        tips = '起点已经移动到坐标系x轴上了'
+                        rect[0][1] = XY_y
+                    if len(poly) >= 1:
+                        tips = '起点已经移动到坐标系x轴上了'
+                        rect[0][1] = XY_y
                 elif event.key == K_n: # 画多边形
-                    if ZJ == 14:
-                        ZJ = 0
-                        pygame.draw.polygon(root,pen_C,Poly,0)
+                    if middle_key == 14:
+                        middle_key = 0
+                        pygame.draw.polygon(root, PEN_C, poly, 0)
                     else:
-                        Talk = '依次选择多边形的各个端点(点击n闭合并填充)'
-                        ZJ = 14
+                        tips = '依次选择多边形的各个端点(点击n闭合并填充)'
+                        middle_key = 14
                 elif event.key == K_m: # 画多边形边框
-                    if ZJ == 14:
-                        ZJ = 0
-                        pygame.draw.polygon(root, pen_C, Poly, d)
+                    if middle_key == 14:
+                        middle_key = 0
+                        pygame.draw.polygon(root, PEN_C, poly, PEN_THICKNESS)
                     else:
-                        Talk = '依次选择多边形的各个端点(点击m闭合)'
-                        ZJ = 14
-                    Line = []
-                    Rect = []
-                    Poly = []
+                        tips = '依次选择多边形的各个端点(点击m闭合)'
+                        middle_key = 14
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_e:#绘制填充椭圆
-                    ZJ = 15
-                    Talk = '选择椭圆外界矩形的两个相对的顶点'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 15
+                    tips = '选择椭圆外界矩形的两个相对的顶点'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_r:#绘制椭圆边框
-                    ZJ = 16
-                    Talk = '选择椭圆外界矩形的两个相对的顶点'
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 16
+                    tips = '选择椭圆外界矩形的两个相对的顶点'
+                    line = []
+                    rect = []
+                    poly = []
                 elif event.key == K_w:#保存
                     if BC_Dic != '':
                         pygame.image.save(root, BC_Dic)  # 保存当前环境
                 elif event.key == K_b:#清空当前操作
-                    ZJ = 0
-                    Line = []
-                    Rect = []
-                    Poly = []
+                    middle_key = 0
+                    line = []
+                    rect = []
+                    poly = []
 
 # 快捷键操作指南
 # d-不用点击左键画线(再次点击关闭)

+ 2 - 2
CGB/__init__.py

@@ -1,2 +1,2 @@
-from CGB.Write import Draw as Draw
-print('草稿版加载完毕...')
+from CGB.Write import draw_main
+print('草稿版加载完毕...')

+ 8 - 8
Hello.py

@@ -1,8 +1,8 @@
 from multiprocessing import Process
 
 def painting_board():
-    from CGB import Draw
-    Draw()
+    from CGB import draw_main
+    draw_main()
 
 def Draw():
     global top,HTB
@@ -10,8 +10,8 @@ def Draw():
     HTB.start()
 
 def Data_Science():
-    from Data_Science import Machine_learning
-    Machine_learning()
+    from Data_Science import machine_learning
+    machine_learning()
 
 def SJKX():
     global top,SJ
@@ -37,8 +37,8 @@ def HSGC():
     HsGC.start()
 
 def Algebraic_factory():
-    from DSGC import Alg
-    Alg()
+    from DSGC import algebraic_factory_main
+    algebraic_factory_main()
 
 def Dsgc():
     global top,DsGC
@@ -55,8 +55,8 @@ def MLA():
     Mla.start()
 
 def Git_Ctrl():
-    from Git_controller import Main
-    Main()
+    from Git_controller import git_main
+    git_main()
 
 def GIT_Ctrl():
     global top, Git_Ctrl