I was trying to open a code with pycharm and the following lines are the begining . but it doesn't open any window . what should I do ?
import tkinter
mainwindow=tkinter.Tk()
mainwindow.title("Calculator")
mainwindow.geometry('480x240')
buttonOne= tkinter.Button(mainwindow,text='1')
it runs and instantly closes without opening any window
CodePudding user response:
In order to make sure the window doesn't close you need the mainloop function.
import tkinter
mainwindow=tkinter.Tk()
mainwindow.title("Calculator")
mainwindow.geometry('480x240')
buttonOne= tkinter.Button(mainwindow,text='1')
tkinter.mainloop()