Home > Enterprise >  python tkinter main window
python tkinter main window

Time:11-20

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()
  • Related