How to create buttons is a GUI with Python and the module tkinter

Python is very easy to learn and it has the built in module tkinter to create GUI or graphic user interfaces. Let’s get started with a very simpe GUI with a button that does a very simple thing, it changes the text on the button itself. Let’s have fun. This video maybe followed by other ones to make the other widgets with tkinter.

Before you click
After you clicked
import tkinter as tk

def hello():
	but["text"] = "You clicked"


root = tk.Tk()

but = tk.Button(
	root,
	text="Click",
	command=hello)
but.pack()

root.mainloop()

The next video is right here where we talk about labels in tkinter:

How to create a label in a GUI with Python


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.