Advertisement
Guest User

Andengradsligningberegner

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. import math
  2. from tkinter import *
  3.  
  4. def Reset():
  5. firstnum.set("0")
  6. secondnum.set("0")
  7. thirdnum.set("0")
  8. Total.set("0")
  9.  
  10.  
  11.  
  12. def Exit():
  13. qExit = messagebox.askyesno("Andengradsligningsberegner", "Vil du afslutte programmet?")
  14. if qExit > 0:
  15. root.destroy()
  16. return
  17.  
  18.  
  19. def Sum():
  20. a=int(firstnum.get())
  21. b=int(secondnum.get())
  22. c=int(thirdnum.get())
  23. plus1=(-b+(math.sqrt((b**2)-(4*a*c)))/(2*a))
  24. minus1=(-b-(math.sqrt((b**2)-(4*a*c)))/(2*a))
  25. plus = round(plus1,4)
  26. minus = round(minus1,4)
  27. Total.set(plus)
  28. Total1.set(minus)
  29.  
  30.  
  31. root = Tk()
  32. root.geometry("825x500+180+20")
  33. root.title("Andengradsligningsberegner")
  34. root.configure(background="#282d38")
  35. root.iconbitmap(r'c:\Python34\DLLs\icon.ico')
  36.  
  37. Tops = Frame(root, width=600,height=50, bd=0, relief="raise")
  38. Tops.pack(side=TOP)
  39.  
  40. inBotto1=Frame(root,width=600,height=600, bd=1,relief="raise", bg="#282d38", highlightbackground="white", highlightthickness=3)
  41. inBotto1.pack(side=LEFT)
  42.  
  43. inBotto2=Frame(root,width=600,height=600, bd=1,relief="raise", bg="#282d38", highlightbackground="white", highlightthickness=3)
  44. inBotto2.pack(side=RIGHT)
  45.  
  46. Tops.configure(background="#282d38")
  47.  
  48. lblInformation = Label(Tops, font =("Raleway",31,"bold"),text=" Andengradsligningsberegner ", bd=16, anchor="w", fg="#282d38") .grid(row=0,column=0)
  49.  
  50. var = IntVar()
  51. firstnum = IntVar()
  52. secondnum = IntVar()
  53. thirdnum = IntVar()
  54. Total = IntVar()
  55. Total1 = IntVar()
  56.  
  57. lblFirstnum = Label(inBotto1, font =("Raleway",21), text ="A", fg="white", bg="#282d38").grid(row = 4, column = 0, sticky=W)
  58. txtFirstnum = Entry(inBotto1, font =("Raleway",17), bd=4, width=13, fg="#282d38", textvariable=firstnum).grid(row=4, column=1)
  59.  
  60. lblSecondnum = Label(inBotto1, font =("Raleway",21), text ="B", fg="white", bg="#282d38").grid(row = 5, column = 0, sticky=W)
  61. txtSecondnum = Entry(inBotto1, font =("Raleway",17), bd=4, width=13, fg="#282d38", textvariable=secondnum).grid(row=5, column=1)
  62.  
  63. lblThirdnum = Label(inBotto1, font =("Raleway",21), text ="C", fg="white",bg="#282d38").grid(row = 6, column = 0, sticky=W)
  64. txtThirdnum = Entry(inBotto1, font =("Raleway",17), bd=4, width=13, fg="#282d38", textvariable=thirdnum).grid(row=6, column=1)
  65.  
  66.  
  67. lblTotal = Label (inBotto1, font =("Raleway",17), text = "Første løsning",bg="#282d38",fg="white",bd=16).grid(row=7,column=0,sticky=W)
  68.  
  69. lblAnswer = Label (inBotto1, font =("Raleway",17), bd=4, width=12, bg="white",fg="#282d38", textvariable=Total,relief="sunken",justify="left").grid(row=7,column=1,sticky=W)
  70.  
  71. lblTotal1 = Label (inBotto1, font =("Raleway",17), text = "Anden løsning",bg="#282d38",fg="white",bd=16).grid(row=8,column=0,sticky=W)
  72.  
  73. lblAnswer1 = Label (inBotto1, font =("Raleway",17), bd=4, width=12, bg="white",fg="#282d38",textvariable=Total1,relief="sunken",justify="left").grid(row=8,column=1,sticky=W)
  74.  
  75.  
  76. btnTotal = Button(inBotto2, pady=8,bd=8,fg="#282d38",font =("Raleway",20), width=15,height=1,text="Beregn", bg="white", command=Sum).grid(row=0, column=0)
  77.  
  78. btnReset = Button(inBotto2, pady=8,bd=8,fg="#282d38",font =("Raleway",20), width=15,height=1,text="Nulstil", bg="white", command=Reset).grid(row=1, column=0)
  79.  
  80. btnExit = Button(inBotto2, pady=8,bd=8,fg="#282d38",font =("Raleway",20), width=15,height=1,text="Afslut", bg="white", command=Exit).grid(row=2, column=0)
  81.  
  82.  
  83. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement