Widgets are how you create your GUI. They are the things which appear on the GUI, everything from the app itself to text boxes, buttons and pictures.
Note: This is an overview of the widgets in guizero. Be sure to view the specific documentation for each widget for more information.
The App object is the basis of all GUIs created using guizero. It is the main window which contains all of the other widgets.
app = App() app.display()
Box object is an invisible container which can contain other widgets.
box = Box(app) box = Box(app, border=True)
ButtonGroup object displays a group of radio buttons, allowing the user to choose a single option.
choice = ButtonGroup(app, options=["cheese", "ham", "salad"])
CheckBox object displays a check box to allow an option to be ticked or un-ticked.
checkbox = CheckBox(app, text="salad ?")
Combo object displays a drop down box allowing a single option to be selected from a list of options.
combo = Combo(app, options=["cheese", "ham", "salad"])
Drawing object allows shapes, images and text to be created.
drawing = Drawing(app)
ListBox object displays a list of items from which either single or multiple items can be selected.
listbox = ListBox(app, items=["cheese", "ham", "salad"])
Picture object displays an image.
picture = Picture(app, image="guizero.png")
PushButton object displays a button with text or an image, which calls a function when pressed.
def do_nothing(): print("button pressed") button = PushButton(app, command=do_nothing)
Slider object displays a bar and selector which can be used to specify a value in a range.
slider = Slider(app)
Text object displays non editable text in your app, useful for titles, labels and instructions.
text = Text(app, text="Hello World")
TextBox object displays a text box which the user can type in.
textbox = TextBox(app)
TitleBox object is an container with a title which can contain other widgets.
titlebox = TitleBox(app, "Title") titlebox = TitleBox(app, "Title", border=False)
Waffle object display an n*n grid of squares with custom dimensions and padding.
waffle = Waffle(app)
Window object create a new window in guizero.
window = Window(app)
All widgets are customisable through their properties. These properties are typical for most widgets. Check the widgets document for more information.
|align||string||The alignment of this widget within its container|
|bg||string, List||The background colour of the widget|
|font||string||The font of the text|
|height||int, string||The height of the widget.|
|master||App, Window, Box||The container to which this widget belongs|
|value||int, string, bool||The widgets current "value", e.g. the text in a TextBox|
|visible||boolean||If this widget is visible|
|width||size||The width of the widget.|
|text_size||int||The size of the text|
|text_color||color||The colour of the text|
Widgets can be interacted with through their methods. The methods supported are dependent on the widget, so check the documentation. These methods are typical across most widgets.
|after(time, command, args=None)||Schedules a single call to
|cancel(command)||Cancels a scheduled call to
|destroy()||Destroys the widget|
|disable()||Disables the widget so that it cannot be interacted with|
|enable()||Enables the widget|
|focus()||Gives focus to the widget|
|hide()||Hides the widget from view|
|repeat(time, command, args=None)||Schedules a call to
|resize(width, height)||Sets the width and height of the widget|
|show()||Displays the widget if it was previously hidden|
|update_command(command, args =None)||Updates the function to call when the widget is used|