preview package

preview module

The Preview Module is the main entry point into the Preview Tool.

cli module

control_panels module

Manages the widgets that hold the bottom ‘control’ area of the preview tool

class tools.preview.control_panels.ActionFrame(app: Preview, parent: ttk.Frame)

Bases: Frame

Frame that holds the left hand side options panel containing the command line options.

Parameters:
  • app (Preview) – The main tkinter Preview app

  • parent (tkinter object) – The parent tkinter object that holds the Action Frame

property busy_progress_bar: BusyProgressBar

The progress bar that appears on the left hand side whilst a swap/patch is being applied

Type:

BusyProgressBar

property convert_args: dict[str, Any]

Currently selected Command line arguments from the ActionFrame.

Type:

dict

class tools.preview.control_panels.BusyProgressBar(parent: Frame)

Bases: object

An infinite progress bar for when a thread is running to swap/patch a group of samples

start() None

Start and display progress bar

stop() None

Stop and hide progress bar

class tools.preview.control_panels.ConfigFrame(parent: OptionsBook, config_key: str, options: dict[str, Any])

Bases: Frame

Holds the configuration options for a convert plugin inside the OptionsBook.

Parameters:
  • parent (tkinter object) – The tkinter object that will hold this configuration frame

  • config_key (str) – The section/plugin key for these configuration options

  • options (dict) – The options for this section/plugin

class tools.preview.control_panels.ConfigTools

Bases: object

Tools for loading, saving, setting and retrieving configuration file values.

tk_vars

Global tkinter variables. Refresh and Busy tkinter.BooleanVar

Type:

dict

property config: Config

plugins.convert._config.Config The convert configuration

property config_dicts: dict[str, Any]

The convert configuration options in dictionary form.

Type:

dict

property plugins_dict: dict[str, list[str]]

Dictionary of configuration option sections as key with a list of containing plugins as the value

Type:

dict

reset_config_to_default(section: str | None = None) None

Reset the GUI parameters to their default configuration values.

Parameters:

section (str, optional) – The configuration section to reset the values for, If None provided then all sections are reset. Default: None

reset_config_to_saved(section: str | None = None) None

Reset the GUI parameters to their saved values within the configuration file.

Parameters:

section (str, optional) – The configuration section to reset the values for, If None provided then all sections are reset. Default: None

save_config(section: str | None = None) None

Save the configuration .ini file with the currently stored values.

Notes

We cannot edit the existing saved config as comments tend to get removed, so we create a new config and populate that.

Parameters:

section (str, optional) – The configuration section to save, If None provided then all sections are saved. Default: None

property sections: list[str]

The sorted section names that exist within the convert Configuration options.

Type:

list

update_config() None

Update config with the currently selected values from the GUI.

class tools.preview.control_panels.OptionsBook(parent: ttk.Frame, config_tools: ConfigTools, patch_callback: Callable[[], None])

Bases: Notebook

The notebook that holds the Convert configuration options.

Parameters:
  • parent (tkinter object) – The parent tkinter object that holds the Options book

  • config_tools (ConfigTools) – Tools for loading and saving configuration files

  • patch_callback (python function) – The function to execute when a patch callback is received

config_tools

Tools for loading and saving configuration files

Type:

ConfigTools

viewer module

Manages the widgets that hold the top ‘viewer’ area of the preview tool

class tools.preview.viewer.FacesDisplay(app: Preview, size: int, padding: int)

Bases: object

Compiles the 2 rows of sample faces (original and swapped) into a single image

Parameters:
  • app (Preview) – The main tkinter Preview app

  • size (int) – The size of each individual face sample in pixels

  • padding (int) – The amount of extra padding to apply to the outside of the face

update_source

Flag to indicate that the source images for the preview have been updated, so the preview should be recompiled.

Type:

bool

source

The list of numpy.ndarray source preview images for top row of display

Type:

list

destination

The list of numpy.ndarray swapped and patched preview images for bottom row of display

Type:

list

set_centering(centering: Literal['face', 'head', 'legacy']) None

The centering that the model uses is not known at initialization time. Set _centering when the model has been loaded.

Parameters:

centering (str) – The centering that the model was trained on

set_display_dimensions(dimensions: tuple[int, int]) None

Adjust the size of the frame that will hold the preview samples.

Parameters:

dimensions (tuple) – The (width, height) of the frame that holds the preview

property tk_image: PhotoImage | None

The compiled preview display in tkinter display format

Type:

PIL.ImageTk.PhotoImage

update_tk_image() None

Build the full preview images and compile tk_image for display.

class tools.preview.viewer.ImagesCanvas(app: Preview, parent: ttk.PanedWindow)

Bases: Frame

tkinter Canvas that holds the preview images.

Parameters:
  • app (Preview) – The main tkinter Preview app

  • parent (tkinter object) – The parent tkinter object that holds the canvas

reload() None

Update the images in the canvas and redraw