Templates Package#

Submodules#

Menu Templates Class#

class visualizer.templates.menu_templates.Basic(screen: Surface, title: str)[source]#

Bases: MenuTemplate

The Basic class is a default template that can be used for the menu screens. It inherits from MenuTemplate and expands on the inherited methods. If different templates are desired, create more classes in this file. This Basic class can be used as a template for any future classes.

load_results_screen(results: dict) None[source]#

This method will update the self.winning_team_name variable based on the results dict given. :param results: :return: None

results_render() None[source]#

This renders the results screen by placing the title and winning team name(s) on the screen. :return:

start_render() None[source]#

This method calls the inherited method to render the start button. It also renders the title :return: None

class visualizer.templates.menu_templates.MenuTemplate(screen: Surface)[source]#

Bases: object

Menu Template is used as an interface. It provides a screen object from pygame.Surface, a ‘Start Game’ and ‘Exit’ button. These are common attributes to all menus, so they are provided to facilitate creating them. Any other buttons should be created.

This class also provides methods that are expanded upon in the Basic class, which is also in this file. Refer to that class’ documentation for further detail. These provided methods can be used via inheritance and expanded upon as needed.

NOTE: The provided buttons are already made to be in the center of the screen.

load_results_screen(results: dict)[source]#
results_events(event: <module 'pygame.event' from 'C:\\Users\\ianth\\.virtualenvs\\byte_le_engine\\Lib\\site-packages\\pygame\\event.cp311-win_amd64.pyd'>) Any[source]#

This method will return if the user presses the ‘Exit’ button on the results screen. The return type is Any since that’s what the mouse_clicked() method returns. :param event: :return: Any

results_render() None[source]#

Renders the Results button. :return: None

start_events(event: <module 'pygame.event' from 'C:\\Users\\ianth\\.virtualenvs\\byte_le_engine\\Lib\\site-packages\\pygame\\event.cp311-win_amd64.pyd'>) Any[source]#

This method will return if the user presses the ‘Start Game’ button. The return type is Any since that’s what the mouse_clicked() method returns. :param event: :return: Any

start_render() None[source]#

Renders the Start button. :return: None

Playback Template#

class visualizer.templates.playback_template.PlaybackButtons(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Flag

These are enums that are used to represent the playback buttons on the visualizer. They inherit from Flag and not Enum because Flag enums can use bitwise operators (& AND, | OR, ^ XOR, ~ INVERT). This allows for multiple values to be returned at the same time. Refer to https://docs.python.org/3.11/library/enum.html#enum.Flag to read more on it.

END_BUTTON = 32#
FASTEST_SPEED_BUTTON = 256#
FAST_SPEED_BUTTON = 128#
NEXT_BUTTON = 4#
NORMAL_SPEED_BUTTON = 64#
PAUSE_BUTTON = 1#
PREV_BUTTON = 8#
SAVE_BUTTON = 2#
START_BUTTON = 16#
class visualizer.templates.playback_template.PlaybackTemplate(screen: Surface)[source]#

Bases: object

This class provides a menu of buttons during runtime of the visualizer to control the playback of the visualizer, including pausing, start, end, frame scrubbing, speeding up, and slowing down, as well as saving it to a .mp4 file.

Buttons from this template are centered at the bottom of the screen, placed in three rows of three.

playback_events(event: <module 'pygame.event' from 'C:\\Users\\ianth\\.virtualenvs\\byte_le_engine\\Lib\\site-packages\\pygame\\event.cp311-win_amd64.pyd'>) PlaybackButtons[source]#

This handles all the playback events. By using the given event, this will return the playback buttons and execute each one’s function. This is done by using the reduce() method. Read the documentation on the reduce() method for more information. Refer to the Button class for more information on how the mouse.clicked() method works. :param event: :return: PlaybackButtons

playback_render() None[source]#

This renders all the playback buttons. :return: None

Module contents#