ClockDisplay Class

digraph inheritance44cc4a6e19 { rankdir=LR; size=""; "pyglet.clock.ClockDisplay" [style="setlinewidth(0.5)",URL="#pyglet.clock.ClockDisplay",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,height=0.25,shape=box,fontsize=10]; }

class ClockDisplay(font=None, interval=0.25, format='%(fps).2f', color=(0.5, 0.5, 0.5, 0.5), clock=None)

Display current clock values, such as FPS.

This is a convenience class for displaying diagnostics such as the framerate. See the module documentation for example usage.

Ivariables :
label : pyglet.font.Text

The label which is displayed.

Deprecated :

This class presents values that are often misleading, as they reflect the rate of clock ticks, not displayed framerate. Use pyglet.window.FPSDisplay instead.

Methods

__init__([font, interval, format, color, clock]) Create a ClockDisplay.
draw() Method called each frame to render the label.
unschedule() Remove the display from its clock’s schedule.
update_text([dt]) Scheduled method to update the label text.

Descriptions

class ClockDisplay

Method details

__init__(font=None, interval=0.25, format='%(fps).2f', color=(0.5, 0.5, 0.5, 0.5), clock=None)

Create a ClockDisplay.

All parameters are optional. By default, a large translucent font will be used to display the FPS to two decimal places.

Parameters :
font : pyglet.font.Font

The font to format text in.

interval : float

The number of seconds between updating the display.

format : str

A format string describing the format of the text. This string is modulated with the dict {'fps' : fps}.

color : 4-tuple of float

The color, including alpha, passed to glColor4f.

clock : Clock

The clock which determines the time. If None, the default clock is used.

draw()

Method called each frame to render the label.

unschedule()

Remove the display from its clock’s schedule.

ClockDisplay uses Clock.schedule_interval to periodically update its display label. Even if the ClockDisplay is not being used any more, its update method will still be scheduled, which can be a resource drain. Call this method to unschedule the update method and allow the ClockDisplay to be garbage collected.

Since :pyglet 1.1
update_text(dt=0)

Scheduled method to update the label text.

Table Of Contents

Previous topic

Clock Class

Next topic

get_default