-
Notifications
You must be signed in to change notification settings - Fork 0
custom_file_dialog
version: v1.0.7
File dialogs customized by a JSON file.
Singleton object of the type _CFDType, containing the types of custom file dialogs (CFD) defined in the source JSON file.
def get_path_types(fetch_data: bool = False) -> list[str | CFDData]Returns the available custom file dialog (CFD) types.
Parameters:
- fetch_data: A flag requesting the CFDData objects themselves. The default is False.
def merge_json(path: str) -> NoneTakes an external JSON dialog data file and merges its contents to the package's own file. This way if you create dialogs you can reuse them in another project.
Parameters:
- path: Path to the external JSON dialog data file.
Data describing a configuration for a given custom file dialog (CFD).
Parameters:
- path_id: Unique text identifier of the path.
- window_title: Title to set for the dialog.
- dialog_type: Numeric identifier for open/save file or open directory.
- file_type_filter: String filter for file handler dialogs (e.g. "JSON (*.json)").
- path: Absolute path to start browsing from.
def __eq__(self, other) -> boolCustom comparison rule, comparing each field.
def soft_eq(self, other) -> boolCustom soft comparison rule, comparing only the ID.
@property
def as_dict(self) -> dictReturns a dictionary containing the set values.
@classmethod
def from_dict(cls, src: dict) -> PathDataReturns an instance built from a dictionary.
Parameters:
- src: A dictionary containing data to build an instance, extracted from the handled JSON file.
def _import_json(full_id_key: bool = False) -> dict[str, CFDData] | NoneImports data from the handled JSON file.
Parameters:
- full_id_key: A flag marking whether to keep the full ID as key or to format it (default) beforehand.
Returns: A dictionary with keys of path IDs and values of CFDData objects, imported from the handled JSON file (or None if there is no such file).
An editor for developer use.
def __init__(self) -> NoneInitializer for the class.
def _setup_ui(self) -> NoneSets up the user interface: GUI objects and layouts.
def _setup_connections(self) -> NoneSets up the connections of the GUI objects.
def _export_json(self) -> NoneExports data to the handled JSON file.
def _reset_inputs(self) -> NoneResets the input fields to their default values.
def _slot_new_type_toggled(self) -> NoneSets the visibility of the type selector based on the control combobox.
def _slot_type_selection_changed(self) -> NoneUpdates the GUI according to the control combobox.
def _update_type_list_combobox(self) -> NoneUpdates the combobox from the type list.
def _slot_delete_data(self) -> NoneAttempts to delete the set data, updating the GUI.
def _slot_export_data(self) -> NoneAdds the set data to the stored dictionary and exports it, updating the GUI.
A class for Enum-like access to custom file dialog (CFD) types.
def __init__(self) -> NoneInitializer for the class.
def __getattr__(self, name: str) -> PathData | NoneReturns a CFDData object identified by the passed string if there are CFD types loaded.
Parameters:
- name: The unique identifier of a path.
def custom_dialog(parent: QWidget, cfd_data: CFDData, custom_title: str = None) -> tuple[bool, str | None]Opens a file dialog of the requested type.
Parameters:
- parent: The widget from which the dialog is requested.
- cfd_data: An object defining the appearance and path of the dialog.
- custom_title: A custom title for the dialog. The default is None, which means that the one defined in the 'path_data' is used.
Returns: A tuple containing the success flag and the selected path or None if the selection is unsuccessful.