Python GUI Development: Tkinter

Reading time ~2 minutes

Main Course Link

This Series is a part of 30 Days of Learning.

  • tkinter is tool for GUI development in Python.

  • Provides UI elements like buttons, widgets etc.

  • Tk GUI can run on most common OS.

  • TK 8.0 can match the theme of your OS.

  • Basic tk UI

# Importing all functions
from tkinter import *

# Create a constructor
root = Tk()

# Pack the geometry
Label(root, text="Hello, Tkinter!").pack()

# Run the main loop

  • Creating and Configuring Widgets, Each Widget is a class. All widgets exits after root. The widgets have heirarchy and the parent is the geometry manager of its child.
from tkinter import *

# Library for the widgets

from tkinter import ttk

# Create Constructer
root = Tk()

# Add a button Widget, pass the parent widget 
button = ttk.Button(root, text = 'Click Me')

# Add to the window

# Configuring button widget

button['text'] = 'Click Me'
button.config(text = 'Push Me')

# Get all the propoerties with the widget object

# Get UID of widget


ttk.Label(root, text ='Hello, Tkinter!').pack()

# mainloop() add

  • How to manage widget placement. We can do this using Geometry management. There are different Geometry managers. Each is created for diffrent uses.

  • Event handling. Using command property or event bindings

My First 10K run

> 10K doneI ran my first 5k in Nov 2015. I was quite elated at the experience that wrote a post in this blogThis year, I had set a goal f...… Continue reading

Walking around in Ranikhet and Majkhali

Published on July 04, 2021

Remote Office for Maximum Productivity

Published on June 22, 2021