Func_Matlib.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. import numpy,pandas
  2. from matplotlib import pyplot as plt
  3. from matplotlib import rcParams
  4. import tkinter,tkinter.messagebox
  5. import math
  6. import random
  7. from tkinter.filedialog import asksaveasfile
  8. import tkinter.messagebox
  9. from os import path
  10. from HSCH.HS import HS_lambda,HS_CSV
  11. from HSCH.Func_advanced import Advanced_Control
  12. def Float(IN,si = float,n = True):#Float筛选系统
  13. x = []
  14. for i in IN:
  15. try:
  16. if si(i) == si(0) and n: continue
  17. x.append(si(i))
  18. except ValueError:
  19. pass
  20. return x
  21. def Fucn_Draw():
  22. global HS,X_Input,fig,Xlim_Input,Ylim_Input,YK_Input,XK_Input
  23. #画板创造
  24. addNews('生成绘制取...')
  25. fig = plt.figure(num='CoTan函数') # 定义一个图像窗口
  26. plt.grid(True,ls='--') # 显示网格(不能放到后面,因为后面调整成为了笛卡尔坐标系)
  27. ax = plt.gca()
  28. ax.spines['right'].set_color('none')
  29. ax.spines['top'].set_color('none')
  30. ax.xaxis.set_ticks_position('bottom')
  31. ax.yaxis.set_ticks_position('left')
  32. ax.spines['bottom'].set_position(('data', 0))# 设置x轴, y轴在(0, 0)的位置
  33. ax.spines['left'].set_position(('data', 0))
  34. #检测x
  35. try:
  36. if XK_Input.get()[0] == 'c':#如果输入函数cx#-10#10#1#1
  37. _HS = XK_Input.get()[1:].split('#')#第一部分HS,第二部分S,第三部分E,第四部分KD,第五部分JD
  38. P = ['x',-10,10,1,2]#保护系统
  39. try:
  40. P[0] = _HS[0]
  41. P[1] = int(_HS[1])
  42. P[2] = int(_HS[2])
  43. P[3] = int(_HS[3])
  44. P[4] = int(_HS[4])
  45. except:#迭代匹配直到出现错误
  46. pass
  47. _HS = P
  48. x = Float(HS_lambda(_HS[0],'x','',_HS[1],_HS[2],_HS[3],_HS[4]).Cul()[1])#取y
  49. ax.set_xticks(x)
  50. elif XK_Input.get()[0] == 'y':#输入函数y
  51. x = abs(int(XK_Input.get()[1:]))
  52. x_major_locator=plt.MultipleLocator(x)
  53. ax.xaxis.set_major_locator(x_major_locator)
  54. else:#输入纯数字
  55. x = Float(XK_Input.get().split(','))
  56. ax.set_xticks(x)
  57. except:
  58. x_major_locator = plt.MultipleLocator(2)
  59. ax.xaxis.set_major_locator(x_major_locator)
  60. #检测y
  61. try:#意外捕捉
  62. if YK_Input.get()[0] == 'c': # 如果输入函数cx#-10#10#1#1
  63. _HS = YK_Input.get()[1:].split('#') # 第一部分HS,第二部分S,第三部分E,第四部分KD,第五部分JD
  64. P = ['x', -10, 10, 1, 2] # 保护系统
  65. try:
  66. P[0] = _HS[0]
  67. P[1] = int(_HS[1])
  68. P[2] = int(_HS[2])
  69. P[3] = int(_HS[3])
  70. P[4] = int(_HS[4])
  71. except: # 迭代匹配直到出现错误
  72. pass
  73. _HS = P
  74. y = Float(HS_lambda(_HS[0], 'y', '', _HS[1], _HS[2], _HS[3], _HS[4]).Cul()[1]) # 取y
  75. ax.set_yticks(y)
  76. elif YK_Input.get()[0] == 'y': # 输入函数y
  77. y = abs(int(YK_Input.get()[1:]))
  78. y_major_locator = plt.MultipleLocator(y)
  79. ax.yaxis.set_major_locator(y_major_locator)
  80. else:
  81. y = Float(YK_Input.get().split(','))
  82. ax.set_yticks(y)
  83. except:
  84. y_major_locator = plt.MultipleLocator(2)
  85. ax.yaxis.set_major_locator(y_major_locator)
  86. #极限设计
  87. try:
  88. xlim_IN = Float(Xlim_Input.get().split(','),si=int,n=False)
  89. ylim_IN = Float(Ylim_Input.get().split(','),si=int,n=False)
  90. try:_xlim = [xlim_IN[0], xlim_IN[1]]
  91. except:_xlim = [-10,10]
  92. try:_ylim = [ylim_IN[0], ylim_IN[1]]
  93. except:_ylim = _xlim
  94. except:
  95. _xlim = [-10, 10]
  96. _ylim = [-10,10]
  97. _xlim.sort()
  98. _ylim.sort()
  99. plt.xlim(_xlim)
  100. plt.ylim(_ylim)
  101. #函数绘图系统
  102. addNews('图像绘制中...')
  103. if not HS:return False
  104. for Fucn in HS:
  105. get = Fucn.Draw_Cul()
  106. fx = get[0]
  107. fy = get[1]
  108. Func_label = get[2]
  109. View = get[3]
  110. First = True
  111. for i in range(len(fx)):
  112. x = fx[i]
  113. y = fy[i]
  114. if First:
  115. plt.plot(x, y,View,label = Func_label) # plot()画出曲线
  116. First = False
  117. else:
  118. plt.plot(x, y, View)
  119. get = Fucn.getMemory()
  120. m_x = get[0]
  121. m_y = get[1]
  122. max_x,max_y,min_x,min_y = Fucn.Best_value()
  123. plt.plot(m_x, m_y, View[0]+'o',label=f'Point of {Func_label}') # 画出一些点
  124. len_x = sorted(list(set(m_x)))#去除list重复项目
  125. JZD = max_x + min_x
  126. o_x = None
  127. for i in range(len(len_x)):
  128. if i in JZD:continue#去除极值点
  129. _x = len_x[i]#x
  130. if o_x == None or abs(_x - o_x) >= 1:#确保位置
  131. num = m_x.index(_x)#y的座位
  132. _y = m_y[num]
  133. plt.text(_x,_y,f'({_x},{int(_y)})', fontdict={'size': '10', 'color':'b'})# 标出坐标
  134. o_x = _x
  135. o_x = None
  136. n_max = []
  137. for i in range(len(max_x)):#画出最大值
  138. _x = max_x[i]
  139. if o_x == None or abs(_x - o_x) >= 1: # 确保位置
  140. plt.text(_x-1, max_y, f'max:({_x},{int(max_y)})', fontdict={'size': '10', 'color': 'b'}) # 标出坐标
  141. n_max.append(_x)
  142. o_x = _x
  143. o_x = None
  144. n_min = []
  145. for i in range(len(min_x)):#画出最小值
  146. _x = min_x[i]
  147. if o_x == None or abs(_x - o_x) >= 1:
  148. n_min.append(_x)
  149. plt.text(_x-1, min_y, f'min:({_x},{int(min_y)})', fontdict={'size': '10', 'color': 'b'}) # 标出坐标
  150. o_x = _x
  151. plt.plot(n_min, [min_y] * len(n_min), View[0] + 'o') # 画出一些点
  152. plt.plot(n_max, [max_y] * len(n_max), View[0] + 'o') # 画出一些点
  153. addNews('绘制完毕')
  154. plt.legend()#显示图示
  155. plt.show() # 显示图像
  156. return True
  157. def Fucn_Cul_CSV():#添加函数
  158. global HS,HS_str,lb,x_I,Name_Input,View_C,View_Co,View_Input
  159. File = tkinter.filedialog.askopenfilename(title='载入表格',filetypes=[("CSV", ".csv")])
  160. view = View_Input.get().split('#')
  161. try:
  162. if view[0] not in View_Co:view[0] = 'b'
  163. v_2 = View_C.get(view[1], '-')
  164. except:
  165. view = ['','']
  166. view[0] = random.choice(View_Co)
  167. v_2 = '-'
  168. V = view[0] + v_2
  169. try:
  170. addNews('读取CSV')
  171. read = pandas.read_csv(File)
  172. name = path.basename(File)[0:-4].replace(' ', '')
  173. if not name:name = random.randint(1,1000)
  174. name += '(In CSV)'
  175. _HS = numpy.array(read).tolist()
  176. if len(_HS[0]) != len(_HS[1]):
  177. raise Exception
  178. HS_str.append(name)
  179. HS.append(HS_CSV(_HS,name,V))
  180. lb.delete(0, tkinter.END)
  181. lb.insert(tkinter.END, *HS)
  182. addNews('读取完毕')
  183. except:
  184. addNews('读取失败')
  185. def Fucn_Cul():#添加函数
  186. global HS,HS_str,lb,x_I,Name_Input,View_C,View_Co,View_Input
  187. get = Func_Input.get().replace(' ', '')
  188. x_I = X_Input.get().split(',')
  189. name = Name_Input.get().replace(' ', '')
  190. view = View_Input.get().split('#')
  191. if not name:name = get
  192. try:
  193. if view[0] not in View_Co:view[0] = 'b'
  194. v_2 = View_C.get(view[1], '-')
  195. except:
  196. view = ['','']
  197. view[0] = random.choice(View_Co)
  198. v_2 = '-'
  199. V = view[0] + v_2
  200. try:
  201. c = x_I[2]
  202. if c[0] == 'H':
  203. Name = {'Pi': math.pi, 'e': math.e, 'log': math.log,
  204. 'sin': math.sin, 'cos': math.cos, 'tan': math.tan,
  205. 'cot': lambda x: 1 / math.tan(x), 'csc': lambda x: 1 / math.sin(x),
  206. 'sec': lambda x: 1 / math.cos(x), 'sinh': math.sinh, 'cosh': math.cosh,
  207. 'tanh': math.tanh, 'asin': math.asin, 'acos': math.acos,
  208. 'atan': math.atan}
  209. x_I[2] = eval(c[1:],Name)
  210. except:
  211. pass
  212. if get and get not in HS_str:
  213. HS_str.append(get)
  214. HS.append(HS_lambda(get,name,V,*x_I))
  215. lb.delete(0, tkinter.END)
  216. lb.insert(tkinter.END, *HS)
  217. addNews('函数生成完毕')
  218. else:
  219. addNews('函数生成失败')
  220. pass
  221. def Fucn_Cul_Clear():#添加函数
  222. global HS,HS_str,lb,x_I,Name_Input,View_C,View_Co,View_Input
  223. if tkinter.messagebox.askokcancel('提示', '是否清空所有函数?)'):
  224. HS_str = []
  225. HS = []
  226. lb.delete(0, tkinter.END)
  227. addNews('函数清空完毕')
  228. def Fucn_Numpy():#显示xy
  229. global HS,lb,Pr_BOX
  230. try:
  231. Fucn = HS[lb.curselection()[0]]
  232. Pr_BOX.delete(0, tkinter.END)
  233. Pr_BOX.insert(tkinter.END,*Fucn.returnList())
  234. addNews('表格创建成功')
  235. except:
  236. addNews('无法创建表格')
  237. pass
  238. def Cul_Y_Clear():
  239. global Xcul_Input,lb,HS
  240. try:
  241. if tkinter.messagebox.askokcancel('提示', f'确定删除{HS[lb.curselection()[0]]}的记忆吗?'):
  242. Y_cul.delete(0, tkinter.END)
  243. Fucn = HS[lb.curselection()[0]]
  244. Fucn.Clear_Memory()
  245. addNews('删除完毕')
  246. else:
  247. addNews('删除取消')
  248. except:
  249. addNews('删除失败')
  250. def Cul_Y_YC():#显示xy
  251. global HS,Y_cul
  252. try:
  253. Fucn = HS[lb.curselection()[0]]
  254. Y_cul.delete(0, tkinter.END)
  255. Fucn.YC_On_Off()
  256. addNews('已清空卡槽')
  257. except:
  258. addNews('隐藏(显示)失败')
  259. def Cul_Y_Check():#显示xy
  260. global HS,Y_cul
  261. try:
  262. Fucn = HS[lb.curselection()[0]]
  263. Y_cul.delete(0, tkinter.END)
  264. m_x,m_y = Fucn.getMemory()
  265. answer = []
  266. for i in range(len(m_x)):
  267. answer.append(f'x={m_x[i]} -> y={m_y[i]}')
  268. Y_cul.insert(tkinter.END, *answer)
  269. addNews('输出完成')
  270. except:
  271. addNews('操作失败')
  272. def Fucn_XZ():
  273. global HS,lb,XZ_box
  274. try:
  275. addNews('预测过程程序可能无响应')
  276. Fucn = HS[lb.curselection()[0]]
  277. XZ_box.delete(0, tkinter.END)
  278. answer = Fucn.Nature(addNews)
  279. XZ_box.insert(tkinter.END, *answer)
  280. addNews('性质预测完成')
  281. except IndexError:
  282. addNews('性质预测失败')
  283. def Cul_Y():
  284. global HS,Y_cul,Xcul_Input,lb
  285. try:
  286. addNews('计算过程程序可能无响应')
  287. Fucn = HS[lb.curselection()[0]]
  288. Y_cul.delete(0, tkinter.END)
  289. x = Xcul_Input.get().split(',')
  290. answer = Fucn.Cul_Y(x)
  291. Y_cul.insert(tkinter.END, *answer)
  292. addNews('系统计算完毕')
  293. except IndexError:
  294. addNews('计算失败')
  295. def Fucn_Save():#导出CSV
  296. global CSV
  297. if not lb.curselection():return False
  298. try:
  299. Fucn = HS[lb.curselection()[0]]
  300. Fucn.Out()
  301. addNews('CSV导出成功')
  302. except:
  303. addNews('CSV导出失败')
  304. def Fucn_Del():#删除函数
  305. global HS,HS_str,lb
  306. del_Fucn = lb.curselection()
  307. for i in del_Fucn:#只存在一项
  308. lb.delete(i)
  309. del HS[i]
  310. del HS_str[i]
  311. addNews('函数删除完毕')
  312. def Find(x,y,in_y):
  313. m = []
  314. while True: # 筛选求出最大值极值点
  315. try:
  316. num = y.index(in_y)
  317. m.append(x[num])
  318. del x[num]
  319. del y[num]
  320. except ValueError:
  321. break
  322. return m
  323. def Cul_X():
  324. global HS,Y_cul,Ycul_Input,E_Input
  325. try:
  326. addNews('计算过程程序可能无响应')
  327. Fucn = HS[lb.curselection()[0]]#获取目标函数
  328. Y_cul.delete(0, tkinter.END)#清空
  329. y = Ycul_Input.get().split(',')#拆解输入
  330. E = E_Input.get().split('#') # 拆解输入
  331. answer = []
  332. addNews('系统运算中')
  333. for i in y:
  334. answer += Fucn.Cul_dichotomy(float(i),*E)[0]
  335. if answer:
  336. addNews('系统运算完成')
  337. Y_cul.insert(tkinter.END, *answer)
  338. else:addNews('系统运算无结果')
  339. except :
  340. addNews('系统运算失败')
  341. Y_cul.delete(0, tkinter.END)
  342. def Cul_X_TD():
  343. global HS,Y_cul,YTDcul_Input
  344. try:
  345. addNews('计算过程程序可能无响应')
  346. Fucn = HS[lb.curselection()[0]]#获取目标函数
  347. Y_cul.delete(0, tkinter.END)#清空
  348. E = YTDcul_Input.get().split('#')#拆解输入
  349. addNews('系统运算中')
  350. answer = Fucn.Iterative_method_Of_Huan(*E)
  351. if answer[1]:
  352. Y_cul.insert(tkinter.END, answer[0])
  353. addNews('系统运算完成')
  354. else:addNews('系统运算无结果')
  355. except :
  356. addNews('系统运算失败,请注意参数设置')
  357. Y_cul.delete(0, tkinter.END)
  358. def addNews(News):
  359. global News_box,T
  360. T += 1
  361. News = str(News)
  362. News_box.insert(0, News+f'({T})')
  363. top.update()
  364. def Fucn_DHS():
  365. global HS, lb, XZ_box,HS_str,x_I,Name_Input,View_C,View_Co,View_Input
  366. try:
  367. Fucn = HS[lb.curselection()[0]]
  368. DHS = Fucn.DHS
  369. if DHS != None and str(DHS):
  370. get = str(DHS)
  371. HS_str.append(get)
  372. HS.append(HS_lambda(get, '(导)'+Fucn.Func_Name+' Of ', Fucn.View,Fucn.start,Fucn.end,Fucn.kd,Fucn.JD))
  373. lb.delete(0, tkinter.END)
  374. lb.insert(tkinter.END, *HS)
  375. addNews('函数生成完毕')
  376. else:
  377. raise Exception
  378. except:
  379. addNews('导函数创建失败')
  380. def Func_Control():
  381. global top,FONT,View_C,View_Co,CSV,Func_Input,X_Input,Name_Input,View_Input,XK_Input,YK_Input,Xlim_Input,Ylim_Input
  382. global lb,Pr_BOX,Xcul_Input,Y_cul,HS,HS_str,Ycul_Input,E_Input,YTDcul_Input,XZ_box,News_box,T
  383. HS = []
  384. HS_str = []
  385. T = 0
  386. #控制面板使用Tk实现
  387. top = tkinter.Tk() # 设置屏幕
  388. top.title('CoTan函数测绘')
  389. top.resizable(width=False, height=False)
  390. top.geometry(f'+10+10')
  391. FONT = ('Font\ZKST.ttf', 11)#设置字体
  392. rcParams['font.family'] = 'simhei'
  393. rcParams['axes.unicode_minus']=False
  394. View_C = {'实线':'-',
  395. '短横线':'--',
  396. '点划线':'-,',
  397. '虚线':':',
  398. '点标记':'.',
  399. '圆标记':'o',
  400. '倒三角':'v',
  401. '正三角':'^',
  402. '左三角':'&lt',
  403. '下箭头':'1',
  404. '上箭头':'2',
  405. '左箭头':'3',
  406. '右箭头':'4',
  407. '正方形':'s',
  408. '五边形':'p',
  409. '星形':'*',
  410. '六边形':'h',
  411. '六边形2':'H',
  412. '+号':'+',
  413. 'X标记':'x',}#函数样式翻译表
  414. View_Co = ['g','r','c','m','y','k']
  415. CSV = []
  416. width_B = 12#标准宽度
  417. height_B=1
  418. #column-水平方向,row-竖直方向
  419. #设置解析式
  420. tkinter.Label(top,text='输入解析式:',font=FONT,width=width_B,height=height_B).grid(column = 0,row = 0)#设置说明
  421. Func_Input = tkinter.Entry(top,width=width_B * 2)
  422. Func_Input.grid(column = 1,row = 0,columnspan = 2,sticky = tkinter.E+tkinter.W)
  423. #设置定义域
  424. tkinter.Label(top,font=FONT,text='定义域:',width=width_B,height=height_B).grid(column = 0,row = 1)#设置说明
  425. X_Input = tkinter.Entry(top,width=width_B * 2)
  426. X_Input.grid(column = 1,row = 1,columnspan = 2,sticky = tkinter.E+tkinter.W)
  427. #设置函数名字
  428. tkinter.Label(top,font=FONT,text='函数名字:',width=width_B,height=height_B).grid(column = 0,row = 2)#设置说明
  429. Name_Input = tkinter.Entry(top,width=width_B * 2)
  430. Name_Input.grid(column = 1,row = 2,columnspan = 2,sticky = tkinter.E+tkinter.W)
  431. #设置函数图示
  432. tkinter.Label(top,font=FONT,text='函数样式:',width=width_B,height=height_B).grid(column = 0,row = 3)#设置说明
  433. View_Input = tkinter.Entry(top,width=width_B * 2)
  434. View_Input.grid(column = 1,row = 3,columnspan = 2,sticky = tkinter.E+tkinter.W)
  435. a_y = 4#按钮统一纵坐标
  436. tkinter.Button(top,text='添加新函数',command=Fucn_Cul,font=FONT,width=width_B,height=height_B).grid(column = 0,row = a_y)#添加函数
  437. tkinter.Button(top,text='删除选中函数',command=Fucn_Del,font=FONT,width=width_B,height=height_B).grid(column = 1,row = a_y)#删除函数
  438. tkinter.Button(top,text='清除函数',command=Fucn_Cul_Clear,font=FONT,width=width_B,height=height_B).grid(column = 2,row = a_y)#绘制函数
  439. a_y += 1
  440. #显示函数
  441. lb=tkinter.Listbox(top,width=width_B*3+2)#暂时不启用多选
  442. TD_a_y = 10
  443. lb.grid(column = 0,row = a_y,columnspan = 3,rowspan = TD_a_y,sticky = tkinter.S+tkinter.N+tkinter.E+tkinter.W)
  444. a_y += TD_a_y
  445. tkinter.Label(top, font=FONT, text='', width=width_B, height=1).grid(column=0, row=a_y)
  446. tkinter.Label(top, font=FONT, text='', width=1).grid(column=4, row=0) # 占用第四
  447. a_y = 0
  448. #输入x函数求y值
  449. tkinter.Label(top, font=FONT, text='计算(y):', width=width_B, height=height_B).grid(column=5, row=a_y) # 设置说明
  450. Xcul_Input = tkinter.Entry(top,width=width_B * 2)
  451. Xcul_Input.grid(column = 6,row = a_y,columnspan = 2,sticky = tkinter.E+tkinter.W)
  452. a_y += 1
  453. #输入x函数求y值
  454. tkinter.Label(top, font=FONT, text='二分法计算(y):', width=width_B, height=height_B).grid(column=5, row=a_y) # 设置说明
  455. Ycul_Input = tkinter.Entry(top,width=width_B * 2)
  456. Ycul_Input.grid(column = 6,row = a_y,columnspan = 2,sticky = tkinter.E+tkinter.W)
  457. a_y += 1
  458. tkinter.Label(top, font=FONT, text='二分法参数:', width=width_B, height=height_B).grid(column=5, row=a_y) # 设置说明
  459. E_Input = tkinter.Entry(top, width=width_B * 2)
  460. E_Input.grid(column=6, row=a_y, columnspan=2,sticky = tkinter.E+tkinter.W)
  461. a_y += 1
  462. #输入x函数求y值
  463. tkinter.Label(top, font=FONT, text='梯度法计算(y):', width=width_B, height=height_B).grid(column=5, row=a_y) # 设置说明
  464. YTDcul_Input = tkinter.Entry(top,width=width_B * 2)
  465. YTDcul_Input.grid(column = 6,row = a_y,columnspan = 2,sticky = tkinter.E+tkinter.W)
  466. a_y += 1
  467. tkinter.Button(top, text='计算(y)', command=Cul_Y, font=FONT, width=width_B, height=height_B).grid(column=5,row=a_y) # 设置说明
  468. tkinter.Button(top, text='二分法计算(x)', command=Cul_X, font=FONT, width=width_B, height=height_B).grid(column=6,row=a_y)
  469. tkinter.Button(top, text='梯度法计算(x)', command=Cul_X_TD, font=FONT, width=width_B, height=height_B).grid(column=7,row=a_y)
  470. a_y += 1
  471. #绘制函数坐标表格
  472. tkinter.Button(top,text='查看记忆',command=Cul_Y_Check,font=FONT,width=width_B,height=height_B).grid(column = 5,row = a_y)
  473. tkinter.Button(top, text='隐藏记忆', command=Cul_Y_YC, font=FONT, width=width_B, height=height_B).grid(column=6,row=a_y)
  474. tkinter.Button(top,text='清空记忆',command=Cul_Y_Clear,font=FONT,width=width_B,height=height_B).grid(column = 7,row = a_y)
  475. a_y += 1
  476. #显示函数
  477. Y_cul=tkinter.Listbox(top,width=width_B*3+2,height=17)#暂时不启用多选
  478. Y_cul.grid(column = 5,row = a_y,columnspan = 3,sticky = tkinter.N+tkinter.E+tkinter.W)
  479. a_y += 1
  480. #设置坐标系刻度
  481. tkinter.Label(top,font=FONT,text='X轴(函数):',width=width_B,height=height_B).grid(column = 5,row = a_y,sticky = tkinter.N)#设置说明
  482. XK_Input = tkinter.Entry(top,width=width_B * 2)
  483. XK_Input.grid(column = 6,row = a_y,columnspan = 2,sticky = tkinter.N+tkinter.E+tkinter.W)
  484. a_y += 1
  485. #设置坐标系刻度
  486. tkinter.Label(top,font=FONT,text='Y轴(函数):',width=width_B,height=height_B).grid(column = 5,row = a_y)#设置说明
  487. YK_Input = tkinter.Entry(top,width=width_B * 2)
  488. YK_Input.grid(column = 6,row = a_y,columnspan = 2,sticky = tkinter.E+tkinter.W)
  489. a_y += 1
  490. #设置坐标系刻度
  491. tkinter.Label(top,font=FONT,text='X轴极限:',width=width_B,height=height_B).grid(column = 5,row = a_y)#设置说明
  492. Xlim_Input = tkinter.Entry(top,width=width_B * 2)
  493. Xlim_Input.grid(column = 6,row = a_y,columnspan = 2,sticky = tkinter.E+tkinter.W)
  494. a_y += 1
  495. #设置坐标系刻度
  496. tkinter.Label(top,font=FONT,text='Y轴极限:',width=width_B,height=height_B).grid(column = 5,row = a_y)#设置说明
  497. Ylim_Input = tkinter.Entry(top,width=width_B * 2)
  498. Ylim_Input.grid(column = 6,row = a_y,columnspan = 2,sticky = tkinter.E+tkinter.W)
  499. a_y += 1
  500. tkinter.Button(top, text='绘制函数', command=Fucn_Draw, font=FONT, width=width_B, height=height_B).grid(column=5,row=a_y) # 绘制函数
  501. tkinter.Button(top, text='计算性质', command=Fucn_XZ, font=FONT, width=width_B, height=height_B).grid(column=6,
  502. row=a_y) # 绘制函数
  503. tkinter.Button(top, text='创建导函数', command=Fucn_DHS, font=FONT, width=width_B, height=height_B).grid(column=7,
  504. row=a_y) # 绘制函数
  505. a_y += 1
  506. XZ_box = tkinter.Listbox(top, width=width_B * 3 + 2, height=10) # 暂时不启用多选
  507. XZ_box.grid(column=5, row=a_y, columnspan=3, sticky=tkinter.N + tkinter.E + tkinter.W)
  508. a_y += 1
  509. News_box = tkinter.Listbox(top, width=width_B * 3 + 2, height=5) # 暂时不启用多选
  510. News_box.grid(column=5, row=a_y, columnspan=3, sticky=tkinter.N + tkinter.E + tkinter.W)
  511. tkinter.Label(top, font=FONT, text='', width=1).grid(column=8, row=a_y) # 占用第四
  512. a_y = 0
  513. #绘制函数坐标表格
  514. tkinter.Button(top,text='导入表格',command=Fucn_Cul_CSV,font=FONT,width=width_B,height=height_B).grid(column = 9,row = a_y)
  515. tkinter.Button(top,text='生成表格',command=Fucn_Numpy,font=FONT,width=width_B,height=height_B).grid(column = 10,row = a_y)
  516. tkinter.Button(top,text='导出表格',command=Fucn_Save,font=FONT,width=width_B,height=height_B).grid(column = 11,row = a_y)
  517. a_y += 1
  518. #显示函数的xy
  519. Pr_BOX=tkinter.Listbox(top,width=width_B*3+2)#暂时不启用多选
  520. Pr_BOX.grid(column = 9,row = a_y,columnspan = 3,rowspan = TD_a_y + 4,sticky = tkinter.S+tkinter.N+tkinter.E+tkinter.W)
  521. addNews('加载完成,欢迎使用!')
  522. top.mainloop()