У меня есть файл 1.py
from math import *
from tkinter import *
from PIL import ImageTk, Image
W = 500
H = 500
root = Tk()
root.title('1')
root.geometry('{}x{}'.format(W + 325, H + 50))
_paramA = StringVar()
_paramB = StringVar()
_paramC = StringVar()
canv = Canvas(root, width=W, height=H, bg="white")
canv.create_line(W / 2, W, H / 2, 0, width=2, arrow=LAST)
canv.create_line(0, W / 2, H, H / 2, width=2, arrow=LAST)
canv.grid(row=0, column=3)
Label(root, text='Параметр A: ').grid(row=1, column=0)
Entry(root, textvariable=_paramA).grid(row=2, column=0)
Label(root, text='Параметр B: ').grid(row=1, column=1)
Entry(root, textvariable=_paramB).grid(row=2, column=1)
Label(root, text='Параметр C: ').grid(row=1, column=2)
Entry(root, textvariable=_paramC).grid(row=2, column=2)
pilImage = Image.open("d:/1.PNG")
image = ImageTk.PhotoImage(pilImage)
imagesprite = canv.create_image(400, 400, image=image)
paramA = 1
paramB = 1
paramC = 1
# canv.pack()
COLORS = ['green', 'red', 'blue']
N = -1
def apply():
global paramA, paramB, paramC, N
paramA = float(_paramA.get())
paramB = float(_paramB.get())
paramC = float(_paramC.get())
drawFuncX(paramA, paramB, paramC, -5 * paramB, 5 * paramB)
N += 1
STEP = 50 / paramB
for x in range(int(W / STEP)):
k = x * STEP
if x < int(W / STEP):
x = x - int((W / STEP) / 2)
canv.create_text(k, H / 2 + 15, text=str(x), fill="purple", font=("Helvectica", "10"))
canv.create_text(W / 2 + 15, k, text=str(x * -1), fill="purple", font=("Helvectica", "10"))
canv.create_line(0, k, H, k, width=0.5, fill='#333333')
canv.create_line(k, 0, k, W, width=0.5, fill='#333333')
def drawFuncX(a, b, c, alh, beta):
global N
# [alh, beta] - отрезок для непрырывной линии
maxx = W
maxy = H
_Dex = 100
ymax = ymin = funcX(alh, a, b, c)
for xx in range(maxx):
x = alh + xx * (beta - alh) / maxx
y = funcX(x, a, b, c)
if y < ymin:
ymin = y
if y > ymax:
ymax = y
_xx, _yy = 0, 0
for xx in range(maxx):
x = alh + xx * (beta - alh) / maxx
y = funcX(x, a, b, c)
if y == None:
continue
# yy = (y - ymax) * maxy / (ymin - ymax)
yy = maxy / 2 - maxy / (beta - alh) * y
print("Это цифры", ymax / 2, ymax / (beta - alh) * y)
if abs(_yy - yy) < _Dex:
print(xx, yy, x, y)
canv.create_line(_xx, _yy, xx, yy, width=2, fill=COLORS[N])
_xx = xx
_yy = yy
def funcX(x, a, b, c):
numerator = float(x * a)
denominator = float(x + b) * pow(float(c - x), 2)
if denominator == 0:
denominator = 0.1
print(numerator, denominator)
e = numerator / denominator
return e
# print(x)
# print(np.power((x*x*a)/(b+x), 1/3))
button = Button(text="Применить", command=apply).grid(row=1, column=3)
root.mainloop()
Как сделать так, что бы командой tkinter из файла 2.py вызвать выполнение 1.py по нажатию на кнопку