Guest User

Untitled

a guest
Apr 17th, 2020
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from math import *
  3. def setwindow(root):
  4. root.title('Окно программы')
  5. root.resizable(False, False)
  6. w = 800
  7. h = 600
  8. ws = root.winfo_screenwidth()
  9. wh = root.winfo_screenheight()
  10. x = int(ws / 2 - w / 2)
  11. y = int(wh / 2 - h / 2)
  12. root.geometry("{0}x{1}+{2}+{3}".format(w, h, x, y))
  13.  
  14. def equation():
  15. global a
  16. global b
  17. global c
  18. global result
  19. x1 = str(float(b.get() * -1) + float(sqrt(b.get() ** 2 - float(a.get() * c.get() * 4) / float(a.get() * 2))))
  20. x2 = str(float(b.get() * -1) - float(sqrt(b.get() ** 2 - float(a.get() * c.get() * 4) / float(a.get() * 2))))
  21. result.config(text="x1 = " + x1 + "; " + "x2 = " + x2)
  22.  
  23. root = Tk()
  24. setwindow(root)
  25.  
  26. label_main = Label(root, text='ax^2 + bx + c = 0', font='tahoma 20')
  27. a = Entry(root, font='Tahoma 16')
  28. c = Entry(root, font='Tahoma 16')
  29. result = Label(root, font='Tahoma 18')
  30. but = Button(root, text='Вычеслить корень уравнения ', font='Tahoma 20', command=equation)
  31. labela = Label(root, text='a', font='Tahoma 16')
  32. labelb = Label(root, text='b', font='Tahoma 16')
  33. labelc = Label(root, text='c', font='Tahoma 16')
  34.  
  35. label_main.place(relx=0.5, rely=0.01, anchor='n')
  36. a.place(relx=0.5, rely=0.1, anchor='n')
  37. b.place(relx=0.5, rely=0.2, anchor='n')
  38. c.place(relx=0.5, rely=0.3, anchor='n')
  39. labela.place(relx=0.3, rely=0.09, anchor='n')
  40. labelb.place(relx=0.3, rely=0.19, anchor='n')
  41. labelc.place(relx=0.3, rely=0.29, anchor='n')
  42. but.place(relx=0.5, rely=0.5, anchor='n')
  43. root.mainloop()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×