Config

class lib.gui.utils.config.Config(root: tk.Tk, cli_opts: CliOptions | None, statusbar: StatusBar | None)

Bases: object

The centralized configuration class for holding items that should be made available to all parts of the GUI.

This class should be initialized on GUI startup through initialize_config(). Any further access to this class should be through get_config().

Parameters:
  • root (tkinter.Tk) – The root Tkinter object

  • cli_opts (lib.gui.options.CliOptions or None) – The command line options object. Must be provided for main GUI. Must be None for tools

  • statusbar (lib.gui.custom_widgets.StatusBar or None) – The GUI Status bar. Must be provided for main GUI. Must be None for tools

Attributes Summary

cli_opts

The command line options for this GUI Session.

command_notebook

The main Faceswap Command Notebook.

default_font

The selected font as configured in user settings.

default_options

The default options for all tabs

modified_vars

The command notebook modified tkinter variables.

path_cache

The path to the GUI cache folder

project

The project session handler.

root

The root tkinter window.

scaling_factor

The scaling factor for current display.

statusbar

The GUI StatusBar tkinter.ttk.Frame.

tasks

The session tasks handler.

tk_vars

The global tkinter variables.

tools_notebook

The Faceswap Tools sub-Notebook.

user_theme

The GUI theme selection options.

Methods Summary

set_active_tab_by_name(name)

Sets the command_notebook or tools_notebook to active based on given name.

set_command_notebook(notebook)

Set the command notebook to the command_notebook attribute and enable the modified callback for project.

set_cursor_busy([widget])

Set the root or widget cursor to busy.

set_cursor_default([widget])

Set the root or widget cursor to default.

set_default_options()

Set the default options for lib.gui.projects

set_geometry(width, height[, fullscreen])

Set the geometry for the root tkinter object.

set_modified_true(command)

Set the modified variable to True for the given command in modified_vars.

set_root_title([text])

Set the main title text for Faceswap.

Attributes Documentation

cli_opts

The command line options for this GUI Session.

Type:

lib.gui.options.CliOptions

command_notebook

The main Faceswap Command Notebook.

Type:

lib.gui.command.CommandNotebook

default_font

The selected font as configured in user settings. First item is the font (str) second item the font size (int).

Type:

tuple

default_options

The default options for all tabs

Type:

dict

modified_vars

The command notebook modified tkinter variables.

Type:

dict

path_cache

The path to the GUI cache folder

Type:

str

project

The project session handler.

Type:

lib.gui.project.Project

root

The root tkinter window.

Type:

tkinter.Tk

scaling_factor

The scaling factor for current display.

Type:

float

statusbar

The GUI StatusBar tkinter.ttk.Frame.

Type:

lib.gui.custom_widgets.StatusBar

tasks

The session tasks handler.

Type:

lib.gui.project.Tasks

tk_vars

The global tkinter variables.

Type:

dict

tools_notebook

The Faceswap Tools sub-Notebook.

Type:

lib.gui.command.ToolsNotebook

user_theme

The GUI theme selection options.

Type:

dict

Methods Documentation

set_active_tab_by_name(name: str) None

Sets the command_notebook or tools_notebook to active based on given name.

Parameters:

name (str) – The name of the tab to set active

Return type:

None

set_command_notebook(notebook: CommandNotebook) None

Set the command notebook to the command_notebook attribute and enable the modified callback for project.

Parameters:

notebook (lib.gui.command.CommandNotebook) – The main command notebook for the Faceswap GUI

Return type:

None

set_cursor_busy(widget: Widget | None = None) None

Set the root or widget cursor to busy.

Parameters:

widget (tkinter object, optional) – The widget to set busy cursor for. If the provided value is None then sets the cursor busy for the whole of the GUI. Default: None.

Return type:

None

set_cursor_default(widget: Widget | None = None) None

Set the root or widget cursor to default.

Parameters:

widget (tkinter object, optional) – The widget to set default cursor for. If the provided value is None then sets the cursor busy for the whole of the GUI. Default: None

Return type:

None

set_default_options() None

Set the default options for lib.gui.projects

The Default GUI options are stored on Faceswap startup.

Exposed as the _default_opts for a project cannot be set until after the main Command Tabs have been loaded.

Return type:

None

set_geometry(width: int, height: int, fullscreen: bool = False) None

Set the geometry for the root tkinter object.

Parameters:
  • width (int) – The width to set the window to (prior to scaling)

  • height (int) – The height to set the window to (prior to scaling)

  • fullscreen (bool, optional) – Whether to set the window to full-screen mode. If True then width and height are ignored. Default: False

Return type:

None

set_modified_true(command: str) None

Set the modified variable to True for the given command in modified_vars.

Parameters:

command (str) – The command to set the modified state to True

Return type:

None

set_root_title(text: str | None = None) None

Set the main title text for Faceswap.

The title will always begin with ‘Faceswap.py’. Additional text can be appended.

Parameters:

text (str, optional) – Additional text to be appended to the GUI title bar. Default: None

Return type:

None

property cli_opts: CliOptions

The command line options for this GUI Session.

Type:

lib.gui.options.CliOptions

property command_notebook: CommandNotebook | None

The main Faceswap Command Notebook.

Type:

lib.gui.command.CommandNotebook

property default_font: tuple[str, int]

The selected font as configured in user settings. First item is the font (str) second item the font size (int).

Type:

tuple

property default_options: dict[str, dict[str, Any]]

The default options for all tabs

Type:

dict

property modified_vars: dict[str, BooleanVar]

The command notebook modified tkinter variables.

Type:

dict

property path_cache: str

The path to the GUI cache folder

Type:

str

property project: Project

The project session handler.

Type:

lib.gui.project.Project

property root: Tk

The root tkinter window.

Type:

tkinter.Tk

property scaling_factor: float

The scaling factor for current display.

Type:

float

set_active_tab_by_name(name: str) None

Sets the command_notebook or tools_notebook to active based on given name.

Parameters:

name (str) – The name of the tab to set active

Return type:

None

set_command_notebook(notebook: CommandNotebook) None

Set the command notebook to the command_notebook attribute and enable the modified callback for project.

Parameters:

notebook (lib.gui.command.CommandNotebook) – The main command notebook for the Faceswap GUI

Return type:

None

set_cursor_busy(widget: Widget | None = None) None

Set the root or widget cursor to busy.

Parameters:

widget (tkinter object, optional) – The widget to set busy cursor for. If the provided value is None then sets the cursor busy for the whole of the GUI. Default: None.

Return type:

None

set_cursor_default(widget: Widget | None = None) None

Set the root or widget cursor to default.

Parameters:

widget (tkinter object, optional) – The widget to set default cursor for. If the provided value is None then sets the cursor busy for the whole of the GUI. Default: None

Return type:

None

set_default_options() None

Set the default options for lib.gui.projects

The Default GUI options are stored on Faceswap startup.

Exposed as the _default_opts for a project cannot be set until after the main Command Tabs have been loaded.

Return type:

None

set_geometry(width: int, height: int, fullscreen: bool = False) None

Set the geometry for the root tkinter object.

Parameters:
  • width (int) – The width to set the window to (prior to scaling)

  • height (int) – The height to set the window to (prior to scaling)

  • fullscreen (bool, optional) – Whether to set the window to full-screen mode. If True then width and height are ignored. Default: False

Return type:

None

set_modified_true(command: str) None

Set the modified variable to True for the given command in modified_vars.

Parameters:

command (str) – The command to set the modified state to True

Return type:

None

set_root_title(text: str | None = None) None

Set the main title text for Faceswap.

The title will always begin with ‘Faceswap.py’. Additional text can be appended.

Parameters:

text (str, optional) – Additional text to be appended to the GUI title bar. Default: None

Return type:

None

property statusbar: StatusBar

The GUI StatusBar tkinter.ttk.Frame.

Type:

lib.gui.custom_widgets.StatusBar

property tasks: Tasks

The session tasks handler.

Type:

lib.gui.project.Tasks

property tk_vars: GlobalVariables

The global tkinter variables.

Type:

dict

property tools_notebook: ToolsNotebook

The Faceswap Tools sub-Notebook.

Type:

lib.gui.command.ToolsNotebook

property user_theme: dict[str, Any]

The GUI theme selection options.

Type:

dict