Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # IF YOU ENJOYED THIS CALCULATOR, PLEASE SUPPORT OUR COMMUNITY BY REGISTERING @
- # MY WEBSITE https://codedskills.net or https://codedskills.org
- #---------------------------------------------------------------------------------
- # OUR DISCORD https://discord.gg/vTtUcNa7Ya
- # MY FACEBOOK PAGE https://www.facebook.com/CodedSkillsAdmin
- # OUR FACEBOOK GROUP https://www.facebook.com/groups/1960554790806573
- # YOU MAY ALSO REACH ME AT ( [email protected] )
- #-------------------------------------------------------------------------
- from tkinter import*
- import webbrowser
- #-----------------------------------------------------
- new = 1
- url = "http://192.168.0.28/myserver/phpBB3/"
- root = Tk()
- root.title(" Calculator")
- root.configure(background='black')
- e = Entry(root, fg="red", bg="black", width=30, borderwidth=10)
- e.grid(row=0, column=0, columnspan=3, padx=10, pady=10)
- def b_click(number, fg="red", bg="black"):
- current = e.get()
- e.delete(0, END)
- e.insert(0, str(current) + str(number))
- #-----------------------------------------------------
- def b_clear():
- e.delete(0, END)
- #-----------------------------------------------------
- def b_add():
- first_number = e.get()
- global f_num
- global math
- math = "addition"
- f_num = int(first_number)
- e.delete(0, END)
- #-----------------------------------------------------
- def b_left():
- e.delete(0, END)
- #-----------------------------------------------------
- def b_right():
- e.delete(0, END)
- #-----------------------------------------------------
- def b_equal():
- second_number = e.get()
- e.delete(0, END)
- if math == "addition":
- e.insert(0, f_num + int(second_number))
- if math == "subtraction":
- e.insert(0, f_num - int(second_number))
- if math == "multiplication":
- e.insert(0, f_num * int(second_number))
- if math == "division":
- e.insert(0, f_num / int(second_number))
- if math == "percentage":
- e.insert(0, f_num % int(second_number))
- #-----------------------------------------------------
- def b_subtract():
- first_number = e.get()
- global f_num
- global math
- math = "subtraction"
- f_num = int(first_number)
- e.delete(0, END)
- #-----------------------------------------------------
- def b_percentage():
- first_number = e.get()
- global f_num
- global math
- math = "percentage"
- f_num = int(first_number)
- e.delete(0, END)
- #-----------------------------------------------------
- def b_multiply():
- first_number = e.get()
- global f_num
- global math
- math = "multiplication"
- f_num = int(first_number)
- e.delete(0, END)
- #-----------------------------------------------------
- def b_division():
- first_number = e.get()
- global f_num
- global math
- math = "division"
- f_num = int(first_number)
- e.delete(0, END)
- #-----------------------------------------------------
- def openweb():
- webbrowser.open(url,new=new)
- global f_num
- b_1 = Button(root, font = {'size' :50}, fg="red", bg="black", text="1", padx=43, pady=7, command=lambda: b_click(1))
- b_2 = Button(root, font = {'size' :50}, fg="red", bg="black", text="2", padx=46, pady=7, command=lambda: b_click(2))
- b_3 = Button(root, font = {'size' :50}, fg="red", bg="black", text="3", padx=43, pady=7, command=lambda: b_click(3))
- b_4 = Button(root, font = {'size' :50}, fg="red", bg="black", text="4", padx=43, pady=7, command=lambda: b_click(4))
- b_5 = Button(root, font = {'size' :50}, fg="red", bg="black", text="5", padx=46, pady=7, command=lambda: b_click(5))
- b_6 = Button(root, font = {'size' :50}, fg="red", bg="black", text="6", padx=43, pady=7, command=lambda: b_click(6))
- b_7 = Button(root, font = {'size' :50}, fg="red", bg="black", text="7", padx=43, pady=7, command=lambda: b_click(7))
- b_8 = Button(root, font = {'size' :50}, fg="red", bg="black", text="8", padx=46, pady=7, command=lambda: b_click(8))
- b_9 = Button(root, font = {'size' :50}, fg="red", bg="black", text="9", padx=43, pady=7, command=lambda: b_click(9))
- b_0 = Button(root, font = {'size' :50}, fg="lime", bg="black", text="0", padx=43, pady=6, command=lambda: b_click(0))
- #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
- b_add = Button(root, fg="aqua", bg="black", text="Add⏆", padx=32, pady=9, command=b_add)
- b_equal = Button(root, fg="lime", bg="black", text="=", padx=96, pady=10, command=b_equal)
- b_clear = Button(root, fg="red", bg="black", text="Clear", padx=85, pady=7, command=b_clear)
- b_percentage = Button(root, fg="pink", bg="black", text="%", padx=45, pady=5, command=b_percentage)
- b_left = Button(root, fg="white", bg="black", text="MyWeb", padx=26, pady=5, command=openweb)
- b_right = Button(root, fg="red", bg="black", text="EXIT", padx=35, pady=5, command=root.quit)
- b_subtract = Button(root, fg="orange", bg="black", text="Minus-", padx=28, pady=9, command=b_subtract)
- b_multiply = Button(root, fg="purple", bg="black", text="Times ⤫", padx=23, pady=9, command=b_multiply)
- b_divide = Button(root, fg="yellow", bg="black", text="Divide÷", padx=23, pady=9, command=b_division)
- #++++1001000010101001+++++++++++++https://codedskills.net++++++++++++++++1001000010101001+++++++
- #DEPENDING ON YOUR SCREEN RESOLUTION, YOU MAY NEED TO ADJUST THE BUTTON WIDTH
- #TO ADJUST THE BUTTON WIDTH, SIMPLY MODIFY THE "padx=?, pady=?" IN THE ABOVE CODE
- b_1.grid(row=3, column=0)
- b_2.grid(row=3, column=1)
- b_3.grid(row=3, column=2)
- b_4.grid(row=2, column=0)
- b_5.grid(row=2, column=1)
- b_6.grid(row=2, column=2)
- b_7.grid(row=1, column=0)
- b_8.grid(row=1, column=1)
- b_9.grid(row=1, column=2)
- b_0.grid(row=4, column=0)
- #-----------------------------------------------------
- b_clear.grid(row=4, column=1, columnspan=2)
- b_equal.grid(row=5, column=1, columnspan=2)
- b_add.grid(row=5, column=0)
- b_subtract.grid(row=6, column=0)
- b_multiply.grid(row=6, column=1)
- b_divide.grid(row=6, column=2)
- b_percentage.grid(row=10, column=1)
- b_left.grid(row=10, column=0)
- b_right.grid(row=10, column=2)
- #++++1001000010101001+++++++++++++https://codedskills.net++++++++++++++++1001000010101001+++++++
- root.mainloop()#----------------------------------------(END)
- # IF YOU ENJOYED THIS CALCULATOR, PLEASE SUPPORT OUR COMMUNITY BY REGISTERING @
- # MY WEBSITE https://codedskills.net or https://codedskills.org
- #---------------------------------------------------------------------------------
- # OUR DISCORD https://discord.gg/vTtUcNa7Ya
- # MY FACEBOOK PAGE https://www.facebook.com/CodedSkillsAdmin
- # OUR FACEBOOK GROUP https://www.facebook.com/groups/1960554790806573
- # YOU MAY ALSO REACH ME AT ( [email protected] )
- #-------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement