Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- main = Tk()
- note = ttk.Notebook(main)
- main.title("Multi Tools")
- main.geometry("360x100")
- ############-WEIGHTCONVERT-###################(1.0)
- ###################################################
- #Function
- def mult():
- if v.get() == 1 :
- blank.delete(0, END)
- ans = int(weight1.get()) * 0.45
- blank.insert(0, ans)
- else:
- blank.delete(0, END)
- ans = int(weight1.get()) / 0.45
- blank.insert(0, ans)
- def clear():
- weight1.delete(0, END)
- blank.delete(0, END)
- #Tab(1.0)
- tab1 = ttk.Frame(note)
- tab2 = ttk.Frame(note)
- tab3 = ttk.Frame(note)
- tab4 = ttk.Frame(note)
- #TAB(1.1)
- note.add(tab1, text = "Weight",compound=TOP)
- #note.add(tab1, text = "Tab One", compound=TOP)
- note.add(tab2, text = "Calculator")
- note.add(tab3, text = "Temperature")
- note.add(tab4, text= "Lenght")
- note.grid()
- #Text(1.0)
- Label(tab1, text="Enter Amount: ").grid(row=0, column=0)
- Label(tab1, text="Weight: ").grid(row=1, column=0)
- #EntryCase(1.0)
- weight1= Entry(tab1)
- blank = Entry(tab1)
- weight1.grid(row=0, column=1)
- blank.grid(row=1, column=1)
- #Checkbutton(1.0)
- v = IntVar()
- v1 = IntVar()
- Checkbutton(tab1, text="Lbs to Kg", variable=v, onvalue=1, offvalue=0).grid(row=0, column=5)
- Checkbutton(tab1, text="Kg to Lbs", variable=v1, onvalue=1, offvalue=0).grid(row=1, column=5)
- #Button(1.0)
- Button(tab1, text="Calculate", command=mult).grid(row=4, column=1)
- Button(tab1, text="Clear", command=clear).grid(row=4, column=2)
- ###########-CALCULATOR-###################(2.0)
- ###############################################
- #Function
- def clear():
- first.delete(0, END)
- second.delete(0, END)
- result.delete(0, END)
- def add():
- result.delete(0, END)
- ans = int(first.get()) + int(second.get())
- result.insert(0, ans)
- def sub():
- result.delete(0, END)
- ans = int(first.get()) - int(second.get())
- result.insert(0, ans)
- def mult():
- result.delete(0, END)
- ans = int(first.get()) * int(second.get())
- result.insert(0, ans)
- def div():
- result.delete(0, END)
- ans = int(first.get()) / int(second.get())
- result.insert(0, ans)
- #Text(2.0)
- Label(tab2, text="Enter first number:").grid(row=0, column=0)
- Label(tab2, text="Enter second number:").grid(row=1, column=0)
- Label(tab2, text=" Result:").grid(row=2, column=0)
- #EntryCase(2.0)
- first = Entry(tab2)
- second = Entry(tab2)
- result = Entry(tab2)
- first.grid(row=0, column=1)
- second.grid(row=1, column=1)
- result.grid(row=2, column=1)
- #Button
- Button(tab2, text="ADD(+)", command=add).grid(row=0, column=2)
- Button(tab2, text="SUB(-)", command=sub).grid(row=0, column=3)
- Button(tab2, text="MULT(*)", command=mult).grid(row=1, column=2)
- Button(tab2, text="DIV(/)", command=div).grid(row=1, column=3)
- Button(tab2, text="Calculate").grid(row=2, column=2)
- Button(tab2, text="Clear", command=clear).grid(row=2, column=3)
- ###########-TEMPERATURE-###################(3.0)
- ###############################################
- #Function
- def ctof():
- if not cel.get():
- ans = int(fah.get()) - 32
- ans1 = ans * 0.55
- cel.insert(0, ans1)
- else:
- ans3 = int(cel.get()) * 1.8 + 32
- fah.insert(0, ans3)
- def clear():
- cel.delete(0, END)
- fah.delete(0, END)
- #Text(3.0)
- Label(tab3, text="Celcius:").grid(row=0, column=0)
- Label(tab3, text="Fahrenheit:").grid(row=1, column=0)
- #EntryCase(3.0)
- cel = Entry(tab3)
- fah = Entry(tab3)
- cel.grid(row=0, column=1)
- fah.grid(row=1, column=1)
- #Button(3.0)
- Button(tab3, text="Convert", command=ctof).grid(row=2, column=1)
- Button(tab3, text="Clear", command=clear).grid(row=2, column=2)
- main.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement