GUI zero (compared to tkinter)

Welcome to GUI zero, a new way to use tkinter

Why don’t we have another approach to GUI with python. Instead of using tkinter we could use GUI zero.

Install the module with

pip install guizero

Starting a window

It is very simple to start a window with guizero:

As you can see, the syntax is easier than the one that you use with tkinter:

… but not so different. We have App() instead of Tk(), and display, instead of mainloop at the end.

Text and Buttons

What we call Label in tkinter, here is simply text, while Button is PushButton. As argument, we have the parent widget and then text and command as usual. The command argument takes the name of the function that will be called when the button is pushed. In this cas, when the button is pushed we go to the action function that will  change the text of textshow widget into “I know, you clicked”.


Create a second window

Opening and closing windows is easy

Open a window preventing from using the other

Grid to position widgets

Example

App title

Span Text

span text in two column with grid layout

Span images

Grid layout images

Warning box

Warning popup

Yes no box

Yes No popup

PushButton that pops info

Do you really want to close?(.on_close method of App)

The rest of the documentation

This examples are based on the documentation of gui zero site. To read the rest of the documentation go here:

The size of the widgets

Colors

Images

Loops and sleeping

events

Using tkinter methods

Examples and resources

Recipes

App

Box

ButtonGroup

CheckBox

Combo

ListBox

MenuBar

Picture

PushButton

Slider

Text

TextBox

Waffle

Window

 

Tkinter test for students

Tkinter articles