Create a window in Python

The code in this article shows you how to create a window in Python. For the purpose of this example, we did this in Visual Studio Code.

Code listing to create a window in Python

Below is the code listing for this program.

import tkinter as mainWin
win = mainWin.Tk()
win.mainloop()

Output

Here is the output for the above program.

show window in python - Techronology
Additional ways to show a window in Python
from tkinter import *
root = Tk()
root.mainloop()

Developer’s note

If you have any questions or comments, then send us an email at support@techronology.com.


Python page

Click on the button below to go to our Python page.

Python page


Create a menu in Python - Techronology

Python is a high-level computer programming language. If you want more information on Python, then visit Python Software Foundation.


Techronology home  Code library  Reference desk