The Misc-Module

Contains code that did not make it into an own module.

pyparadigm.misc.display(surface)[source]

Displays a pygame.Surface in the window.

in pygame the window is represented through a surface, on which you can draw as on any other pygame.Surface. A refernce to to the screen can be optained via the pygame.display.get_surface() function. To display the contents of the screen surface in the window pygame.display.flip() needs to be called.

display() draws the surface onto the screen surface at the postion (0, 0), and then calls flip().

Parameters:surface (pygame.Surface) – the pygame.Surface to display
pyparadigm.misc.empty_surface(fill_color, size=None)[source]

Returns an empty surface filled with fill_color.

Parameters:
  • fill_color (pygame.Color) – color to fill the surface with
  • size (int-2-tuple) – the size of the new surface, if None its created to be the same size as the screen
pyparadigm.misc.init(resolution, pygame_flags=0, display_pos=(0, 0))[source]

Creates a window of given resolution.

Parameters:
  • resolution (tuple) – the resolution of the windows as (width, height) in pixels
  • pygame_flags (int) – modify the creation of the window. For further information see Creating a Window
  • display_pos (tuple) – determines the position on the desktop where the window is created. In a multi monitor system this can be used to position the window on a different monitor. E.g. the monitor to the right of the main-monitor would be at position (1920, 0) if the main monitor has the width 1920.
Returns:

a reference to the display screen

Return type:

pygame.Surface

pyparadigm.misc.slide_show(slides, continue_handler)[source]

Displays one “slide” after another.

After displaying a slide, continue_handler is called without arguments. When continue_handler returns, the next slide is displayed.

Usage example

slide_show(text_screens,
           partial(event_listener.wait_for_n_keypresses, pygame.K_RETURN))  

(partial is imported from the functools module.)

Parameters:
  • slides (iterable) – pygame.Surfaces to be displayed.
  • continue_handler (callable with arity 0.) – function, that returns when the next slide should be displayed.