gui¶
GUI frontend for tools, based on customtkinter.
The window is built from the click commands of the tool, with a checkbox for each command flag. Log messages are shown in a textbox, and progress bars are reported through logging messages with a “prg-” prefix.
- class hacktools.gui.tqdm_gui(*args, **kwargs)[source]¶
Progress bar that also reports its state through logging messages.
The messages use a “prg-” prefix, they’re hidden from the log file and turned into progress bar updates by
LogHandler. The console bar is still shown when the tool has a console attached.
- class hacktools.gui.LogHandler(guiapp)[source]¶
Logging handler that forwards log messages to the GUI.
- Parameters:
guiapp (GUIApp) – The application window to forward messages to.
- guiapp¶
The application window.
- prgtotal¶
Total count of the progress bar being updated.
- emit(record)[source]¶
Show a log record in the textbox, or update the progress bar.
Records with the “prg-” prefix logged by
tqdm_guiupdate the progress bar, the others are added to the textbox. Records below info level are ignored.- Parameters:
record (LogRecord) – Log record to show.
- Return type:
None
- class hacktools.gui.GUIOptions(advanced=False, appearance='System', command='extract', options=[])[source]¶
Options saved in the tool json config file.
- advanced¶
Whether advanced mode is enabled.
- appearance¶
Appearance mode, “System”, “Light” or “Dark”.
- command¶
Last command that was selected.
- options¶
Names of the flags that were checked for the last command.
- class hacktools.gui.GUIApp[source]¶
Main window of the GUI frontend, a singleton.
The window is created empty and built by
initialize().- initialize(cligroup, appname, appversion, datafolder)[source]¶
Build the window and load the saved options.
- Parameters:
- Return type:
None
- entryPressed(_)[source]¶
Run the command typed in the manual entry.
- Parameters:
_ – Key event, unused.
- Return type:
None
- changeCommand(currentval)[source]¶
Switch to a command, showing a checkbox for each of its flags.
- Parameters:
currentval (str) – Name of the command to switch to.
- Return type:
None
- runThread(func)[source]¶
Run an async function in a new thread with its own event loop.
- Parameters:
func (Callable) – Async function to run.
- Return type:
None
- addMessages(messages)[source]¶
Append messages to the textbox and scroll to the bottom.
- Parameters:
messages (list[str]) – List of messages to add.
- Return type:
None
- setInputEnabled(enabled)[source]¶
Enable or disable all the input widgets.
- Parameters:
enabled (bool) – Whether the widgets should be enabled.
- Return type:
None
- clickContext(choice)[source]¶
Handle the context menu, toggling advanced mode or the appearance.
- Parameters:
choice (str) – Selected menu entry.
- Return type:
None