Widgets and Qt helpers¶
Qt helpers¶
Actions¶
- guidata.qthelpers.create_action(parent: QW.QWidget | None, title: str, triggered: Callable | None = None, toggled: Callable | None = None, shortcut: QG.QKeySequence | None = None, icon: QG.QIcon | None = None, tip: str | None = None, checkable: bool | None = None, context: QC.Qt.ShortcutContext = 1, enabled: bool | None = None) QW.QAction ¶
Create a new QAction
- Parameters:
parent (QWidget or None) – Parent widget
title (str) – Action title
triggered (Callable or None) – Triggered callback
toggled (Callable or None) – Toggled callback
shortcut (QKeySequence or None) – Shortcut
icon (QIcon or None) – Icon
tip (str or None) – Tooltip
checkable (bool or None) – Checkable
context (ShortcutContext) – Shortcut context
enabled (bool or None) – Enabled
- Returns:
New action
- Return type:
- guidata.qthelpers.add_actions(target: QMenu | QToolBar, actions: Iterable[QAction | QMenu | QToolButton | QPushButton | None]) None ¶
Add actions (list of QAction instances) to target (menu, toolbar)
Simple widgets¶
- guidata.qthelpers.create_toolbutton(parent: QW.QWidget, icon: QG.QIcon | str | None = None, text: str | None = None, triggered: Callable | None = None, tip: str | None = None, toggled: Callable | None = None, shortcut: QG.QKeySequence | None = None, autoraise: bool = True, enabled: bool | None = None) QW.QToolButton ¶
Create a QToolButton
- Parameters:
- Returns:
New toolbutton
- Return type:
Icons¶
Application¶
- guidata.qthelpers.qt_app_context(exec_loop: bool = False) Generator[QApplication, None, None] ¶
Context manager handling Qt application creation and persistance
- Parameters:
exec_loop (bool) – If True, execute Qt event loop
Note
This context manager was strongly inspired by the one in the DataLab project which is more advanced and complete than this one (it handles faulthandler and traceback log files, which need to be implemented at application level, that is why they were not included here).
Other¶
- guidata.qthelpers.grab_save_window(widget: QWidget, name: str) None ¶
Grab window screenshot and save it
- guidata.qthelpers.click_on_widget(widget: QWidget) None ¶
Click on widget and eventually save a screenshot
- Parameters:
widget (QWidget) – Widget to click on
- guidata.qthelpers.block_signals(widget: QWidget, enable: bool) Generator[None, None, None] ¶
Eventually block/unblock widget Qt signals before/after doing some things (enable: True if feature is enabled)
- guidata.qthelpers.qt_wait(timeout: float, except_unattended: bool = False, show_message: bool = False, parent: QWidget | None = None) None ¶
Freeze GUI during timeout (seconds) while processing Qt events.
- Parameters:
timeout – timeout in seconds
except_unattended – if True, do not wait if unattended mode is enabled
show_message – if True, show a message box with a timeout
parent – parent widget of the message box
Ready-to-use Qt widgets¶
Data editors¶
- class guidata.widgets.arrayeditor.ArrayEditor(parent: QWidget = None)¶
Array Editor Dialog
- Parameters:
parent – Parent widget (default: None)
- class guidata.widgets.collectionseditor.CollectionsEditor(parent=None)¶
Collections Editor Dialog
- class guidata.widgets.dataframeeditor.DataFrameEditor(parent=None)¶
Dialog for displaying and editing DataFrame and related objects.
Signals¶
- sig_option_changed(str, object): Raised if an option is changed.
Arguments are name of option and its new value.
- class guidata.widgets.texteditor.TextEditor(text, title='', font=None, parent=None, readonly=False, size=(400, 300))¶
Array Editor Dialog
Console and code editor¶
- class guidata.widgets.console.Console(parent=None, namespace=None, message=None, commands=None, multithreaded=True, debug=False)¶
Python console that run an interactive shell linked to the running process.
- class guidata.widgets.console.DockableConsole(parent, namespace, message, commands=None, multithreaded=True, debug=False)¶
Dockable Python console that run an interactive shell linked to the running process.
- class guidata.widgets.codeeditor.CodeEditor(parent: QWidget = None, language: str | None = None, font: QFont | None = None, columns: int | None = None, rows: int | None = None, inactivity_timeout: int = 1000)¶
Code editor widget
- Parameters:
parent – Parent widget
language – Language used for syntax highlighting
font – Font used for the text
columns – Number of columns
rows – Number of rows
inactivity_timeout – after this delay of inactivity (in milliseconds), the
CodeEditor.SIG_EDIT_STOPPED
signal is emitted