so i was making a gui for a calculator app. ok so when i run the code it opens up python and in my code i added buttons to click on. but when i click on the button in the gui , python crashes for some reason can someone help me?. im writing code in pycharm. pls help me. this is my code:
from tkinter import *
from tkinter import Button
root = Tk()
def num1():
input("")
root.title("Basic Calculator")
entry = Entry(root, width=50,bg="green", fg="black")
entry.grid()
b1 = Button(root, text="1", padx=40, pady=20, command=num1)
b2 = Button(root, text="2", padx=40, pady=20, command=num1)
b3 = Button(root, text="3", padx=40, pady=20, command=num1)
b4 = Button(root, text="4", padx=40, pady=20, command=num1)
b5 = Button(root, text="5", padx=40, pady=20, command=num1)
b6 = Button(root, text="6", padx=40, pady=20, command=num1)
b7 = Button(root, text="7", padx=40, pady=20, command=num1)
b8 = Button(root, text="8", padx=40, pady=20, command=num1)
b9 = Button(root, text="9", padx=40, pady=20, command=num1)
b0 = Button(root, text="0", padx=40, pady=20, command=num1)
b_add = Button(root, text="+", padx=40, pady=20, command=num1)
b_sub = Button(root, text="-", padx=40, pady=20, command=num1)
b_div = Button(root, text="/", padx=40, pady=20, command=num1)
b_mul = Button(root, text="*", padx=40, pady=20, command=num1)
b_cl = Button(root, text="Clear", padx=40, pady=20, command=num1)
b_equal = Button(root, text="=", padx=40, pady=20, command=num1)
b1.grid(row=1, column=0)
root.mainloop()
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!
Hi @anandu4115,
I’m not sure about the reason behind the crashes you are experiencing but I’ll recommend checking out your error_logs. In that error_logs, you should be able to get a better understanding at what the exact python error you are experiencing and see if you can fix it.
It might give you a good point to continue your Google search as well.