from math import *
from tkinter import *
y0 = 0; a = 45;x = 0; y = 0; x0 = 0; v0 = 10
g = 9.8
root = Tk()
win = Toplevel(root,relief=SUNKEN,bd=10,bg="white")
win.title("Выбор исxодныx данныx")
win.minsize(width=400,height=300)
lab1 = Label(win, text="X0", font="Arial 18")
lab2 = Label(win, text="Y0", font="Arial 18")
lab3 = Label(win, text="V0", font="Arial 18")
lab4 = Label(win, text="A", font="Arial 18")
sca1 = Scale(win,orient=HORIZONTAL,length=300,
from_=0,to=10,tickinterval=1,resolution=1)
sca2 = Scale(win,orient=HORIZONTAL,length=300,
from_=0,to=10,tickinterval=1,resolution=1)
sca3 = Scale(win,orient=HORIZONTAL,length=300,
from_=0,to=30,tickinterval=2,resolution=1)
sca4 = Scale(win,orient=HORIZONTAL,length=300,
from_=0,to=90,tickinterval=10,resolution=1)
def display(event):
global x0
global y0
global v0
global a
x0 = sca1.get()
y0 = sca2.get()
v0 = sca3.get()
a = sca4.get()
def f(n):
y = v0*sin(a)*(x/(v0*cos(a)))-((g*x*x)/(2*v0*v0*cos(a)*cos(a)))
return n
but = Button(win,text="Получить значение")
but.bind('<Button-1>',display)
lab1.grid(row = 1, column = 1)
lab2.grid(row = 2, column = 1)
lab3.grid(row = 3, column = 1)
lab4.grid(row = 4, column = 1)
sca1.grid(row = 1, column = 2)
sca2.grid(row = 2, column = 2)
sca3.grid(row = 3, column = 2)
sca4.grid(row = 4, column = 2)
but.grid(row = 5, column = 2)
canv = Canvas(root, width = 500, height = 500, bg = "white")
canv.create_line(5,500,5,0,width=2,arrow=LAST)
canv.create_line(5,500,500,500,width=2,arrow=LAST)
y = f(x)
x = f(y)
def b1(event):
First_x = 0;
for i in range(16000):
if (i % 800 == 0):
k = First_x + (1 / 128) * i
canv.create_line(8*k + 0, -3 + 500, 8*k + 0, 3 + 500, width = 0.5, fill = 'black')
canv.create_text(8*k + 15, -10 + 500, text = str(k), fill="purple", font=("Helvectica", "10"))
if (k != 0):
canv.create_line(-3 + 5, 8*k + 0, 3 + 5, 8*k + 0, width = 0.5, fill = 'black')
while x < 500:
global x0
global y0
global x
y = f(x)
#x = f(y)
canv.create_line(x0,500-y0,x,500-y,width=1,fill="blue")
x0 = x; y0 = y
x+=5
y+=5
#def b1(event):
root.bind('<Button-1>',b1)
canv.pack()
root.mainloop()