Utility functions#
- edifice.utilities.alert(message, choices=None)[source]#
Displays a message in an alert box.
If choices is specified, the alert box contain a list of buttons showing each of the choices, and this function will return the user’s choice.
- Parameters:
message (
str
) – message to displaychoices (
Optional
[Sequence
[str
]]) – optional list of choice texts, which will be displayed as buttons.
- Return type:
int
|None
- Returns:
Index of chosen option.
- edifice.utilities.file_dialog(caption='', directory='', file_filter=None)[source]#
Displays a file choice dialog.
- Parameters:
caption (
str
) – the file dialog’s captiondirectory (
str
) – starting directory for the file dialogfile_filter (
Optional
[Sequence
[str
]]) –Sequence of allowed file extensions. For example:
"*.cpp *.cc *.C *.c++" "C++ files (*.cpp *.cc *.C *.c++)"
are both valid ways of specifying a file filter.
- Return type:
str
|None
- Returns:
Path of chosen file
- edifice.utilities.palette_dump(palette, palette_compare=None)[source]#
Dump the palette to the console.
- Parameters:
palette (
QPalette
) – Dump the palette to the console.palette_compare (
Optional
[QPalette
]) – Compare the palette with another palette if palette_compare is not None.
- Return type:
None
- edifice.utilities.palette_edifice_dark()[source]#
Edifice dark theme palette. This is the Qt Linux default dark theme palette, with some adjustments.
- Return type:
QPalette
- edifice.utilities.palette_edifice_light()[source]#
Edifice light theme palette. This is the Qt Linux default light theme palette, with some adjustments.
- Return type:
QPalette
- edifice.utilities.set_trace()[source]#
Set a tracepoint in the Python debugger that works with PyQt.
PDB does not work well with PyQt applications.
edifice.set_trace()
is equivalent topdb.set_trace()
, but it can properly pause the PyQt event loop to enable use of the debugger (users of PySide need not worry about this).
- edifice.utilities.theme_is_light()[source]#
Detect the operating environment theme.
True if light theme, false if dark theme.
Example:
def initializer(): palette = palette_edifice_light() if theme_is_light() else palette_edifice_dark() cast(QApplication, QApplication.instance()).setPalette(palette) return palette palette, _ = ed.use_state(initializer) with Window():
- Return type:
bool