After you have installed guizero you are ready to create your GUI with guizero.
This is a quick start guide, for more information see Using Widgets
Let's create an app window with the title "Hello world" and display it.
from guizero import App app = App(title="Hello world") app.display()
Save and run the code - you've created your first guizero app!
Add some text
To add things to your app you will need to use widgets.
Use the Text widget to add a message to your app.
from guizero import App, Text app = App(title="Hello world") message = Text(app, text="Welcome to the Hello world app!") app.display()
text parameter of the
TextBox sets the text that will be displayed on the GUI.
Make something happen
You can make your app do things by using other widgets which a user can interact with.
Use the PushButton widget to create a button which will change the
message when it is clicked.
from guizero import App, Text, PushButton def change_message(): message.value = "You pressed the button!" app = App(title="Hello world") message = Text(app, text="Welcome to the Hello world app!") button = PushButton(app, text="Press me", command=change_message) app.display()
PushButton widget includes a
command parameter which is set to the name of a function -
change_message function is called each time the button is clicked.
And that's it! Take a look at Using Widgets for more information on how to use guizero.