Class GameView

class graphics.GameView(**kwargs)

The view class for a GameController application.

You may need to access an instance of this class to add and/or remove GObject instances. However, you will never need to construct one. You should only use the one provided in the view attribute of GameController. See GameController for more information.

Attributes

There are no publically accessible attributes in GameView.

Methods

add(widget, timeout=0, callback=None)

Add a new GObject to this view.

param widget:widget to add

Precondition: an instance of GObject

param timeout:time to remove widget in seconds; never if 0

Precondition: a non-negative number (int or float)

param callback:function called after delay; ignored if timeout is 0.

Precondition: a function reference; must be a function that takes the widget as an argument

Objects are drawn ‘bottom-up’, with later objects drawn on top of objects added earlier. If you wish for an object to be in the background, it must be added first.

The timeout attribute is a simple way to provide a widget that quickly flashes up on screen, though the delay method in GameController has the same effect.

remove(widget)

Removes the widget from this view.

param widget:widget to remove

Precondition: a GObject stored in this view

Manually removes a GObject widget from this view. You should call this method if the graphics object was added with timeout 0; otherwise the application will automatically remove the widget for you.

This method does nothing if widget is not in this view.

Table Of Contents

Previous topic

Game Classes

Next topic

Class GameController

This Page