Hyperbola_control.py 2.6 KB
Newer Older
geekincode's avatar
geekincode 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
from Hyperbola_draw import hyperbola

import tkinter as tk  

from tkinter import *


def function():

    # print(e1.get(),e2.get())
    # h = hyperbola()
    a = eval(e1.get())
    b = eval(e2.get())
    ax_range = eval(e4.get())
    # line_range = eval(e5.get())
    focus_ax = e3.get()
    h = hyperbola(ax_range,ax_range*7)
    h.hb_data(a,b,focus=focus_ax)
    h.hb_draw()
    h.asymptote()

    h.display()
# def e1press1(self):
#     e1.config(bg='skyblue')
# def e1press2(self):
#     e1.config(bg='white')
# def e2press1(self):
#     e2.config(bg='skyblue')
# def e2press2(self):
#     e2.config(bg='white')
# def e3press1(self):
#     e3.config(bg='skyblue')
# def e3press2(self):
#     e3.config(bg='white')

root=Tk()
root.geometry('500x350')
root.geometry('+400+300')
root.title('双曲线')
root.resizable(False, False)


l1 = tk.Label(root, text='a:', 
                font=('Arial Black',12),
                width=3, height=1)
l1.place(relx=0.25, rely=0.03)

l2 = tk.Label(root, text='b:', 
                font=('Arial Black',12),
                width=3, height=1)
l2.place(relx=0.25, rely=0.13)

l3 = tk.Label(root, text='焦点:', 
                font=('楷体',13),
                width=5, height=1)
l3.place(relx=0.215, rely=0.23)

l3_ = tk.Label(root, text='x or y', 
                font=('Arial',10),
                width=5, height=1)
l3_.place(relx=0.65, rely=0.23)

l4 = tk.Label(root, text='坐标轴长度:', 
                font=('楷体',13),
                width=13, height=1)
l4.place(relx=0.15, rely=0.33)


e1 = tk.Entry(root, show = None, bg='white',font=('Arial',10))#显示成明文形式
e1.place(relx=0.35,rely=0.05)
# e1.bind('<Enter>',e1press1)
# e1.bind('<Leave>',e1press2)


e2 = tk.Entry(root, show = None, bg='white', font=('Arial',10))#显示成明文形式
e2.place(relx=0.35, rely=0.15)
# e2.bind('<Enter>',e2press1)
# e2.bind('<Leave>',e2press2)

e3 = tk.Entry(root, show = None, bg='white', font=('Arial',10))#显示成明文形式
e3.place(relx=0.35, rely=0.25)
# e3.bind('<Enter>',e3press1)
# e3.bind('<Leave>',e3press2)
e4 = tk.Entry(root, show = None, bg='white', font=('Arial',10))#显示成明文形式
e4.place(relx=0.35, rely=0.35)

# e5 = tk.Entry(root, show = None, bg='white', font=('Arial',10))#显示成明文形式
# e5.place(relx=0.35, rely=0.45)
# # 第5步,在窗口界面设置放置Button按键hyperbola.Kp
b = tk.Button(root,
                 text='Show Hyperbola', 
                 font=('Arial', 12), 
                 width=15, height=1, 
                 bg='lightcoral',
                 command=function)
b.place(relx=0.38, rely=0.75)

root.mainloop()