GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing maelgruandwebdev.github.io — Create a Window Using Tkinter

This page explains how to create a window in Python using the Tkinter module.
Tkinter is a Python module that allows you to create GUI applications.

Setting Up the Environment

mkdir PythonTuto cd PythonTuto # For Linux (module venv of Python) python3 -m venv env # For Windows python -m venv env # Activate the virtual environment # For Linux source env/bin/activate # For Windows env/Scripts/activate # Install Tkinter pip install tkinter # Or for Linux sudo apt install python3-tk

Python Code

import tkinter as tk # Traditional form root = tk.Tk() root.geometry("500x500") root.title("Tkinter Tutorial") root.mainloop() # Custom function def createWindow(title, size): window = tk.Tk() window.geometry(size) window.title(title) return window #In main file import window as win root = win.createWindow("A Tk Window", "500x500") root.mainloop()
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.