The BaseWidget
is the most basic class of
all widgets and contains common attributes and methods, each
widget of the ocempui.widgets
module has to
include. Every widget inherits from it, so that any description
and explanation in this section also to the widgets, which are
explained later on.
A widget can be set to a specific position on the main screen using the position attribute.
widget.position = 10, 15
This will not work as supposed using widgets, that are bound
to a Container
or
Bin
widget, which will be explained
in one of the following sections.
If you read the current position value of a widget, keep in mind, that it will return a tuple containing the both, x and y, coordinates.
Every widget supports a minimum size, that will be respected by the default drawing methods.
widget.size = 80, 20
The currently used width and height, which can differ from its size can be retrieved using the width and height attributes.
if (widget.width == widget.size[0]) and (widget.height == widget.size[1]): print "Widget does not exceed its minimum size."
To allow an easy and logical keyboard navigation, widgets have an index attribute, which influences the navigation order using the keyboard.
widget.index = 3
The input focus mentioned above denotes a state of the widget,
in which the user can interact with it using the keyboard only.
A Button
widget will react upon pressing
the space bar with a click while an Entry
widget will let the user type text. You can set the input focus
of a widget manually with the focus attribute.
widget.focus = True
Table
). Depedant
on the widget the set_focus() method of it
will return either True or False, which indicates, that the
input focus could be sucessfully set for that widget or not.
frame = VFrame () focusok = frame.set_focus (True) if not focusok: print "Focus could not be set."
Widgets can be disabled from user interaction and receiving events, if you set their sensitive attribute to False.
widget.sensitive = False
The renderering system of the
ocempgui.widgets
module can use different
layers, on which widgets are drawn. This is especially useful
and often necessary to place widgets above others (e.g. to place
a Window
widget above another one).
widget.depth = 3