Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- from tkinter import *
- def Reset():
- firstnum.set("0")
- secondnum.set("0")
- thirdnum.set("0")
- Total.set("0")
- def Exit():
- qExit = messagebox.askyesno("Andengradsligningsberegner", "Vil du afslutte programmet?")
- if qExit > 0:
- root.destroy()
- return
- def Sum():
- a=int(firstnum.get())
- b=int(secondnum.get())
- c=int(thirdnum.get())
- plus1=(-b+(math.sqrt((b**2)-(4*a*c)))/(2*a))
- minus1=(-b-(math.sqrt((b**2)-(4*a*c)))/(2*a))
- plus = round(plus1,4)
- minus = round(minus1,4)
- Total.set(plus)
- Total1.set(minus)
- root = Tk()
- root.geometry("825x500+180+20")
- root.title("Andengradsligningsberegner")
- root.configure(background="#282d38")
- root.iconbitmap(r'c:\Python34\DLLs\icon.ico')
- Tops = Frame(root, width=600,height=50, bd=0, relief="raise")
- Tops.pack(side=TOP)
- inBotto1=Frame(root,width=600,height=600, bd=1,relief="raise", bg="#282d38", highlightbackground="white", highlightthickness=3)
- inBotto1.pack(side=LEFT)
- inBotto2=Frame(root,width=600,height=600, bd=1,relief="raise", bg="#282d38", highlightbackground="white", highlightthickness=3)
- inBotto2.pack(side=RIGHT)
- Tops.configure(background="#282d38")
- lblInformation = Label(Tops, font =("Raleway",31,"bold"),text=" Andengradsligningsberegner ", bd=16, anchor="w", fg="#282d38") .grid(row=0,column=0)
- var = IntVar()
- firstnum = IntVar()
- secondnum = IntVar()
- thirdnum = IntVar()
- Total = IntVar()
- Total1 = IntVar()
- lblFirstnum = Label(inBotto1, font =("Raleway",21), text ="A", fg="white", bg="#282d38").grid(row = 4, column = 0, sticky=W)
- txtFirstnum = Entry(inBotto1, font =("Raleway",17), bd=4, width=13, fg="#282d38", textvariable=firstnum).grid(row=4, column=1)
- lblSecondnum = Label(inBotto1, font =("Raleway",21), text ="B", fg="white", bg="#282d38").grid(row = 5, column = 0, sticky=W)
- txtSecondnum = Entry(inBotto1, font =("Raleway",17), bd=4, width=13, fg="#282d38", textvariable=secondnum).grid(row=5, column=1)
- lblThirdnum = Label(inBotto1, font =("Raleway",21), text ="C", fg="white",bg="#282d38").grid(row = 6, column = 0, sticky=W)
- txtThirdnum = Entry(inBotto1, font =("Raleway",17), bd=4, width=13, fg="#282d38", textvariable=thirdnum).grid(row=6, column=1)
- lblTotal = Label (inBotto1, font =("Raleway",17), text = "Første løsning",bg="#282d38",fg="white",bd=16).grid(row=7,column=0,sticky=W)
- 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)
- lblTotal1 = Label (inBotto1, font =("Raleway",17), text = "Anden løsning",bg="#282d38",fg="white",bd=16).grid(row=8,column=0,sticky=W)
- 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)
- 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)
- 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)
- 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)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement