Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from math import *
- def setwindow(root):
- root.title('Окно программы')
- root.resizable(False, False)
- w = 800
- h = 600
- ws = root.winfo_screenwidth()
- wh = root.winfo_screenheight()
- x = int(ws / 2 - w / 2)
- y = int(wh / 2 - h / 2)
- root.geometry("{0}x{1}+{2}+{3}".format(w, h, x, y))
- def equation():
- global a
- global b
- global c
- global result
- x1 = str(float(b.get() * -1) + float(sqrt(b.get() ** 2 - float(a.get() * c.get() * 4) / float(a.get() * 2))))
- x2 = str(float(b.get() * -1) - float(sqrt(b.get() ** 2 - float(a.get() * c.get() * 4) / float(a.get() * 2))))
- result.config(text="x1 = " + x1 + "; " + "x2 = " + x2)
- root = Tk()
- setwindow(root)
- label_main = Label(root, text='ax^2 + bx + c = 0', font='tahoma 20')
- a = Entry(root, font='Tahoma 16')
- c = Entry(root, font='Tahoma 16')
- result = Label(root, font='Tahoma 18')
- but = Button(root, text='Вычеслить корень уравнения ', font='Tahoma 20', command=equation)
- labela = Label(root, text='a', font='Tahoma 16')
- labelb = Label(root, text='b', font='Tahoma 16')
- labelc = Label(root, text='c', font='Tahoma 16')
- label_main.place(relx=0.5, rely=0.01, anchor='n')
- a.place(relx=0.5, rely=0.1, anchor='n')
- b.place(relx=0.5, rely=0.2, anchor='n')
- c.place(relx=0.5, rely=0.3, anchor='n')
- labela.place(relx=0.3, rely=0.09, anchor='n')
- labelb.place(relx=0.3, rely=0.19, anchor='n')
- labelc.place(relx=0.3, rely=0.29, anchor='n')
- but.place(relx=0.5, rely=0.5, anchor='n')
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement