'How to use Tkinter Buttons to help in calculator [closed]
Hello programmers from around the world, welcome to a new day.
I have an project I made using Python, it is a calculator with GUI made using Tkinter, it's name is CalculatorX. You can check the code here on GitHub: Omar8345/CalculatorX
I want to calculate and view the answer on the GUI, I mostly did the most important part which I made a function which runs when the button is pressed and changes a variable it's name differs upon to the button name like buttonClicked1 and buttonClicked2 and when button is clicked, it's variable is set from False to True. And we can also add to return to the old value False after taking what we need from the variable, I mean the number, like 1 or 2 or 3 just examples. Code is on GitHub, help is much appreciated programmers... Thank you
Function for identifying which button pressed (Sample):
def checkbutton1():
global buttonClicked1
buttonClicked1 = not buttonClicked1
print('button 1 clicked')
buttonClicked1 = False # set it false before clicking the button
Button 1 (Sample):
button1 = tkinter.Button(window, text="1", width=10, height=10, command=checkbutton1) # create button 1
button1.grid(row=3, column=1) # arrange button 1 place
button1['font'] = font.Font(size=15) # set button 1 font size
Full code is available on GitHub Repository, you can check here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
