Template object - base for all widgets.
Widget(**params)
A number of optional params may be passed to the Widget initializer.
- decorate
defaults to True. If true, will call theme.decorate(self) to allow the theme a chance to decorate the widget.
- style
a dict of style parameters.
- x, y, width, height
position and size parameters, passed along to style
- align, valign
alignment parameters, passed along to style
- font, color, background
other common parameters that are passed along to style
- cls
class name as used by Theme
- name
name of widget as used by Form. If set, will call form.add(self,name) to add the widget to the most recently created Form.
- focusable
True if this widget can receive focus via Tab, etc. Defaults to True.
- disabled
True of this widget is disabled. Defaults to False.
- value
initial value
Example - Creating your own Widget
This example shows which methods are template methods.
class Draw(gui.Widget):
def paint(self,s):
#paint the pygame.Surface
return
def update(self,s):
#update the pygame.Surface and return the update rects
return [pygame.Rect(0,0,self.rect.w,self.rect.h)]
def event(self,e):
#handle the pygame.Event
return
def resize(self,width=None,height=None):
#return the width and height of this widget
return 256,256