pyggui.configure package

Submodules

pyggui.configure.asset_builder module

Module for building assets objects used in Game object.

class pyggui.configure.asset_builder.AssetBuilder(directory: Optional[str] = None)[source]

Bases: object

Class used for building the Directory object.

build() Dict[source]

Method will build and return the correct object for using assets in game. If path was not defined the dummy Asset object gets returned, so if access to some file is attempted an error gets returned.

class pyggui.configure.asset_builder.Assets[source]

Bases: object

Dummy class for raising error (when fetching attribute) when Asset directory was not defined.

class pyggui.configure.asset_builder.Directory(directory_structure: Dict)[source]

Bases: object

Class for building directory objects. Every directories file and sub-directory can be accessed through attributes, if the file/directory does not exist the AssetDoesNotExistError gets raised.

Properties:

files: Returns a list of file paths of files contained in the directory. directories (List[]): Returns a list of directory paths of sub-directories. empty (bool): If directory is empty. path (str): Will return the directories path.

Directory can be iterated through every one of its contents, where sub-directories come first and files second. Printing out the object will output its structure. TODO: Implement repr method.

property directories: List[str]
property empty: bool
property files: List[str]
pyggui.configure.asset_builder.build_directory(directory_structure: Dict) pyggui.configure.asset_builder.Directory[source]

Function builds directory object by setting it appropriate attributes, sub-directories get also added as attributes and recursively built.

Parameters

directory_structure (Dict) – Dictionary containing structure, created inside the AssetBuilder.build method.

Returns

Directory – Object.

pyggui.configure.build module

Module containing functionality for pre-setting build config files, directories, …

pyggui.configure.build.update_config_file(dir_path: str, data: Dict) None[source]

Function updates the current config file in the project using this library. Where config file is just a config.json file saved in the build directory on the top level of the project.

Parameters
  • dir_path (str) – Path to projects directory.

  • data (Dict) – Dictionary of key, value pairs to update in the file.

pyggui.configure.pages module

Module used for setting up page classes and page-holding modules throughout directory. Ultimately the functions used here are used for importing all modules that contain classes that inherit from one parent class of the _pyggui.gui.page module. This is then used by the controller class to fetch all Page type classes.

pyggui.configure.pages.create_module_import_string(package_name: str, module_path: str) str[source]

Function creates a module import string (ex. foo.bar.module) based on the package name and file path of python file. Import string will be created from the package_name ahead (not including package name at beginning).

Parameters
  • package_name (str) – Name of package where the python module is contained (root. dir. of project).

  • module_path (str) – Absolute path of module.

Returns

str – Module import string

pyggui.configure.pages.get_all_page_classes() Dict[str, any][source]
Function returns a dictionary containing all classes that:

Are imported and are subclasses of classes defined in the _pyggui.gui.page module

Returns

dict[str, any] – Where: key = str(name_of_class), value = class.

pyggui.configure.pages.get_all_page_import_strings(dir_path: str, called_from_module: str) List[str][source]

Function reads and creates all needed import strings in the directory structure except the called_from_module.

Parameters
  • dir_path (str) – Directory root to import all modules from its structure.

  • called_from_module (str) – Absolute path of module where call originated (main module), will be ignored.

pyggui.configure.pages.import_all_modules(dir_path: str, called_from_module: str) None[source]

Function imports all modules in the directory structure except the called_from_module.

Parameters
  • dir_path (str) – Directory root to import all modules from its structure.

  • called_from_module (str) – Absolute path of module where call originated (main module), will be ignored.

pyggui.configure.pages.setup(call_from: inspect.FrameInfo, directory: Optional[str] = None) None[source]

Function imports all modules in the directory. If directory is not passed it will import all modules in the directory where the call originated from i.e. call_from modules parent directory. Function should be used for importing modules of type page, i.e. modules containing classes that inherit from Page, or any other class defined in the _pyggui.gui.page module.

Parameters
  • call_from (inspect.FrameInfo) – FrameInfo object where the call originated from, this object should be fetched from inspect.stack() when calling function, in argument.

  • directory (str) – Absolute or relative path of directory to search and import modules.

Module contents