Main Menu

search

You are here

GUIzero Widget Programming

[last updated: 2022-09-23]
GUIzero home page
-----

  • To start with, each widget has its own set of parameters.
    You can set these parameters to be what you want when you define the widget.


    After definition, you can re-set, ie. change, most of the parameters, but not all of them.

  • For example - the Box widget:
    • The Box widget has 9 parameters that can be set when you define the box:
      master, layout, height, width, border, grid, align, visible, and enabled
    • When you define a box, you must at least specify the "master" parameter. This is the name of the container that your box will be placed inside of.
    • After initial definition, you can change (some) parameters with:
      • widgetName.parameter method:
        • eg. box1.height = 50
        • box1.bg = "red"
          This is an interesting thing. The deal is that bg, background, is not listed as an official parameter of the box widget in GUIzero,
          yet you can indeed specify/change it with this code.
          I don't understand it at the moment. Suspect it's a parameter from tkinter which seems to be like the core of GUIzero.
        • Parameters I've changed with this method:
          height (of a box), bg,
      • widgetName.tk.config method:
        • [widgetName].tk.config( [paramName] = [paramValue] )
          So for example, to change the border thickness, you'd enter:
          [widgetName].tk.config(border=3)
        • For the box widget, I could not change align, visible, or grid with the tk.config method.
          I did successfully change height and width.

    • But:
      Using the tk.config method, I could change box parameters: bg (background), ...

.

.

.

eof