Created
October 9, 2022 15:54
-
-
Save 4193883-eng/870616d68ebd7c629ecdc7c17e580b6f to your computer and use it in GitHub Desktop.
exam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
eqal = "" | |
def render(): | |
global displayLabel | |
global eqal | |
displayLabel.config(text=eqal) | |
def one(): | |
global eqal | |
eqal += "1" | |
render() | |
def two(): | |
global eqal | |
eqal += "2" | |
render() | |
def three(): | |
global eqal | |
eqal += "3" | |
render() | |
def four(): | |
global eqal | |
eqal += "4" | |
render() | |
def five(): | |
global eqal | |
eqal += "5" | |
render() | |
def six(): | |
global eqal | |
eqal += "6" | |
render() | |
def seven(): | |
global eqal | |
eqal += "7" | |
render() | |
def eight(): | |
global eqal | |
eqal += "8" | |
render() | |
def nine(): | |
global eqal | |
eqal += "9" | |
render() | |
def zero(): | |
global eqal | |
eqal += "0" | |
render() | |
def plus(): | |
global eqal | |
eqal += "+" | |
render() | |
def minus(): | |
global eqal | |
eqal += "-" | |
render() | |
def enter(): | |
global eqal | |
global displayLabel | |
a = eval(eqal) | |
eqal = str(a) | |
displayLabel.config(text=a) | |
def ac(): | |
eqal= "" | |
render() | |
def dev(): | |
global eqal | |
eqal += "/" | |
render() | |
def mul(): | |
global eqal | |
eqal += "*" | |
render() | |
root = Tk() | |
displayLabel = Label(root, text = "start calculating!", bg= "black", fg = "white") | |
displayLabel.place(x=30, y= 10, width=150) | |
button1 = Button(root,text='1', command = one) | |
button1.place(x=30, y = 50, width =30, height=30) | |
button2 = Button(root,text='2', command = two) | |
button2.place(x=60, y = 50, width =30, height=30) | |
button3 = Button(root,text='3', command = three) | |
button3.place(x=90, y = 50, width =30, height=30) | |
button4 = Button(root,text='4', command = four) | |
button4.place(x=30, y =80, width =30, height=30) | |
button5 = Button(root,text='5', command = five) | |
button5.place(x=60, y =80, width =30, height=30) | |
button6 = Button(root,text='6', command = six) | |
button6.place(x=90, y =80, width =30, height=30) | |
button7 = Button(root,text='7', command = seven) | |
button7.place(x=30, y =110, width =30, height=30) | |
button8 = Button(root,text='8', command = eight) | |
button8.place(x=60, y =110, width =30, height=30) | |
button9 = Button(root,text='9', command = nine) | |
button9.place(x=90, y =110, width =30, height=30) | |
button0 = Button(root,text='0', command = zero) | |
button0.place(x=30, y =140, width =30, height=30) | |
buttonplus = Button(root,text='+', command = plus) | |
buttonplus.place(x=60, y =140, width =30, height=30) | |
buttonminus = Button(root,text='-', command = minus) | |
buttonminus.place(x=90, y =140, width =30, height=30) | |
buttonenter = Button(root,text='=', command = enter) | |
buttonenter.place(x=120, y =140, width =30, height=30) | |
buttonac = Button(root,text='AC', command = ac) | |
buttonac.place(x=120, y = 50, width =30, height=30) | |
buttondev = Button(root,text='/', command = dev) | |
buttondev.place(x=120, y =80, width =30, height=30) | |
buttonmul = Button(root,text='x', command = mul) | |
buttonmul.place(x=120, y =110, width =30, height=30) | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment