Phil's pyGame Utilities Documentation

Overview

Scripts
tileedit | leveledit | tganew | levelfancy

Reference
algo | ani | engine | fonts | high | html | layout | text | timer | vid

Tutorials
1 | 2 | 3 | 4 | 5

GUI Ref.
theme | style | widget | surface | const

Containers
container | app | table | document | area

Forms
form | group

Widgets
basic | button | input | keysym | slider | select | misc

Other
menus | dialog

Tutorials
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

gui.widget

sections
Widget
Widget.__init__
Widget.focus
Widget.blur
Widget.open
Widget.close
Widget.is_hovering
Widget.resize
Widget.chsize
Widget.update
Widget.paint
Widget.repaint
Widget.repaintall
Widget.reupdate
Widget.next
Widget.previous
Widget.get_abs_rect
Widget.connect
Widget.send
Widget.event
Widget.get_toplevel
Widget.collidepoint

Widget

Base class for all PGU graphical objects. Example - Creating your own Widget: 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

Widget.__init__

Create a new Widget instance given the style parameters. Keyword arguments: decorate -- whether to call theme.decorate(self) to allow the theme a chance to decorate the widget. (default is true) style -- a dict of style parameters. x, y -- position parameters width, height -- size parameters align, valign -- alignment parameters, passed along to style font -- the font to use with this widget color -- the color property, if applicable background -- the widget used to paint the background 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. (default is True) disabled -- True of this widget is disabled (defaults is False) value -- initial value

Widget.focus

Focus this Widget.

Widget.blur

Blur this Widget.

Widget.open

Open this widget as a modal dialog.

Widget.close

Close this widget, if it is currently an open dialog.

Widget.is_hovering

Returns true if the mouse is hovering over this widget.

Widget.resize

Resize this widget and all sub-widgets, returning the new size. This should be implemented by a subclass.

Widget.chsize

Signal that this widget has changed its size.

Widget.update

Updates the surface and returns a rect list of updated areas This should be implemented by a subclass.

Widget.paint

Render this widget onto the given surface This should be implemented by a subclass.

Widget.repaint

Request a repaint of this Widget.

Widget.repaintall

Request a repaint of all Widgets.

Widget.reupdate

Request a reupdate of this Widget.

Widget.next

Pass focus to next Widget. Widget order determined by the order they were added to their container.

Widget.previous

Pass focus to previous Widget. Widget order determined by the order they were added to their container.

Widget.get_abs_rect

Returns the absolute rect of this widget on the App screen.

Widget.connect

Connect an event code to a callback function. Note that there may be multiple callbacks per event code. Arguments: code -- event type fnc -- callback function *values -- values to pass to callback. Please note that callbacks may also have "magicaly" parameters. Such as: _event -- receive the event _code -- receive the event code _widget -- receive the sending widget Example: def onclick(value): print 'click', value w = Button("PGU!") w.connect(gui.CLICK,onclick,'PGU Button Clicked')

Widget.send

Send a code, event callback trigger.

Widget.event

Called when an event is passed to this object. Please note that if you use an event, returning the value True will stop parent containers from also using the event. (For example, if your widget handles TABs or arrow keys, and you don't want those to also alter the focus.) This should be implemented by a subclass.

Widget.get_toplevel

Returns the top-level widget (usually the Desktop) by following the chain of 'container' references.

Widget.collidepoint

Test if the given point hits this widget. Over-ride this function for more advanced collision testing.

all content (c) 2006 Phil Hassey - Phil's pyGame Utilities