qt #
Qt objects for app_model.
QCommandAction #
QCommandAction(command_id: str, app: Application | str, parent: QObject | None = None)
Bases: QAction
Base QAction for a command id. Can execute the command.
Parameters:
-
command_id
(str
) –Command ID.
-
app
(Application | str
) –Application instance or name of application instance.
-
parent
(QObject | None
, default:None
) –Optional parent widget, by default None
Source code in app_model/backends/qt/_qaction.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
QCommandRuleAction #
QCommandRuleAction(command_rule: CommandRule, app: Application | str, parent: QObject | None = None, *, use_short_title: bool = False)
Bases: QCommandAction
QAction for a CommandRule.
Parameters:
-
command_rule
(CommandRule
) –CommandRule
instance to create an action for. -
app
(Application | str
) –Application instance or name of application instance.
-
parent
(QObject | None
, default:None
) –Optional parent widget, by default None
-
use_short_title
(bool
, default:False
) –If True, use the
short_title
of the command rule, if it exists.
Source code in app_model/backends/qt/_qaction.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
update_from_context #
update_from_context(ctx: Mapping[str, object]) -> None
Update the enabled state of this menu item from ctx
.
Source code in app_model/backends/qt/_qaction.py
106 107 108 109 110 111 112 113 114 115 |
|
QKeyBindingSequence #
QKeyBindingSequence(kb: KeyBinding)
Bases: QKeySequence
A QKeySequence based on a KeyBinding instance.
Source code in app_model/backends/qt/_qkeymap.py
110 111 112 |
|
QMenuItemAction #
QMenuItemAction(menu_item: MenuItem, app: Application | str, parent: QObject | None = None)
Bases: QCommandRuleAction
QAction for a MenuItem.
Mostly the same as a CommandRuleAction
, but aware of the menu_item.when
clause
to toggle visibility.
Parameters:
-
menu_item
(MenuItem
) –MenuItem
instance to create an action for. -
app
(Application | str
) –Application instance or name of application instance.
-
parent
(QObject | None
, default:None
) –Optional parent widget, by default None
Source code in app_model/backends/qt/_qaction.py
146 147 148 149 150 151 152 153 154 155 |
|
create
classmethod
#
create(menu_item: MenuItem, app: Application | str, parent: QObject | None = None) -> Self
Create a new QMenuItemAction for the given menu item.
Prefer this method over __init__
to ensure that the cache is used,
so that:
a1 = QMenuItemAction.create(action, full_app)
a2 = QMenuItemAction.create(action, full_app)
a1 is a2 # True
Source code in app_model/backends/qt/_qaction.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
update_from_context #
update_from_context(ctx: Mapping[str, object]) -> None
Update the enabled/visible state of this menu item from ctx
.
Source code in app_model/backends/qt/_qaction.py
189 190 191 192 |
|
QModelKeyBindingEdit #
Bases: QKeySequenceEdit
Editor for a KeyBinding instance.
This is a QKeySequenceEdit with a method that converts the current keySequence to an app_model KeyBinding instance.
keyBinding #
keyBinding() -> Optional[KeyBinding]
Return app_model KeyBinding instance for the current keySequence.
Source code in app_model/backends/qt/_qkeybindingedit.py
18 19 20 21 22 |
|
QModelMainWindow #
QModelMainWindow(app: Application | str, parent: QWidget | None = None)
Bases: QMainWindow
QMainWindow with app-model support.
Source code in app_model/backends/qt/_qmainwindow.py
19 20 21 |
|
addModelToolBar #
addModelToolBar(menu_id: str, *, exclude: Collection[str] | None = None, area: Qt.ToolBarArea | None = None, toolbutton_style: Qt.ToolButtonStyle = Qt.ToolButtonStyle.ToolButtonIconOnly) -> QModelToolBar
Add a tool bar to the main window.
Source code in app_model/backends/qt/_qmainwindow.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
setModelMenuBar #
setModelMenuBar(menu_ids: Mapping[str, str] | Sequence[str | tuple[str, str]]) -> QModelMenuBar
Set the menu bar to a list of menu ids.
Parameters:
-
menu_ids
(Mapping[str, str] | Sequence[str | tuple[str, str]]
) –A mapping of menu ids to menu titles or a sequence of menu ids.
Source code in app_model/backends/qt/_qmainwindow.py
23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
QModelMenu #
QModelMenu(menu_id: str, app: Application | str, title: str | None = None, parent: QWidget | None = None)
Bases: QMenu
QMenu for a menu_id in an app_model
MenusRegistry.
Parameters:
-
menu_id
(str
) –Menu ID to look up in the registry.
-
app
(Application | str
) –Application instance or name of application instance.
-
title
(str | None
, default:None
) –Optional title for the menu, by default None
-
parent
(QWidget | None
, default:None
) –Optional parent widget, by default None
Source code in app_model/backends/qt/_qmenu.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
findAction #
findAction(object_name: str) -> QAction | QModelMenu | None
Find an action by its ObjectName.
Parameters:
-
object_name
(str
) –Action ID to find. Note that
QCommandAction
haveObjectName
set to theircommand.id
Source code in app_model/backends/qt/_qmenu.py
63 64 65 66 67 68 69 70 71 72 |
|
rebuild #
rebuild(include_submenus: bool = True, exclude: Collection[str] | None = None) -> None
Rebuild menu by looking up self._menu_id in menu_registry.
Source code in app_model/backends/qt/_qmenu.py
93 94 95 96 97 98 99 100 101 102 103 |
|
update_from_context #
update_from_context(ctx: Mapping[str, object], _recurse: bool = True) -> None
Update the enabled/visible state of each menu item with ctx
.
See app_model.expressions
for details on expressions.
Parameters:
-
ctx
(Mapping
) –A namespace that will be used to
eval()
the'enablement'
and'when'
expressions provided for each action in the menu. ALL variables used in these expressions must either be present in thectx
dict, or be builtins. -
_recurse
(bool
, default:True
) –recursion check, internal use only
Source code in app_model/backends/qt/_qmenu.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
QModelMenuBar #
QModelMenuBar(menus: Mapping[str, str] | Sequence[str | tuple[str, str]], app: Application | str, parent: QWidget | None = None)
Bases: QMenuBar
QMenuBar that is built from a list of model menu ids.
Parameters:
-
menus
(Mapping[str, str] | Sequence[str | tuple[str, str]]
) –A mapping of menu ids to menu titles or a sequence of menu ids.
-
app
(Application | str
) –Application instance or name of application instance.
-
parent
(QWidget | None
, default:None
) –Optional parent widget, by default None
Source code in app_model/backends/qt/_qmenu.py
268 269 270 271 272 273 274 275 276 277 278 279 |
|
update_from_context #
update_from_context(ctx: Mapping[str, object], _recurse: bool = True) -> None
Update the enabled/visible state of each menu item with ctx
.
See app_model.expressions
for details on expressions.
Parameters:
-
ctx
(Mapping
) –A namespace that will be used to
eval()
the'enablement'
and'when'
expressions provided for each action in the menu. ALL variables used in these expressions must either be present in thectx
dict, or be builtins. -
_recurse
(bool
, default:True
) –recursion check, internal use only
Source code in app_model/backends/qt/_qmenu.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
QModelSubmenu #
QModelSubmenu(submenu: SubmenuItem, app: Application | str, parent: QWidget | None = None)
Bases: QModelMenu
QMenu for a menu_id in an app_model
MenusRegistry.
Parameters:
-
submenu
(SubmenuItem
) –SubmenuItem for which to create a QMenu.
-
app
(Application | str
) –Application instance or name of application instance.
-
parent
(QWidget | None
, default:None
) –Optional parent widget, by default None
Source code in app_model/backends/qt/_qmenu.py
134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
findAction #
findAction(object_name: str) -> QAction | QModelMenu | None
Find an action by its ObjectName.
Parameters:
-
object_name
(str
) –Action ID to find. Note that
QCommandAction
haveObjectName
set to theircommand.id
Source code in app_model/backends/qt/_qmenu.py
63 64 65 66 67 68 69 70 71 72 |
|
rebuild #
rebuild(include_submenus: bool = True, exclude: Collection[str] | None = None) -> None
Rebuild menu by looking up self._menu_id in menu_registry.
Source code in app_model/backends/qt/_qmenu.py
93 94 95 96 97 98 99 100 101 102 103 |
|
update_from_context #
update_from_context(ctx: Mapping[str, object], _recurse: bool = True) -> None
Update the enabled state of this menu item from ctx
.
Source code in app_model/backends/qt/_qmenu.py
148 149 150 151 152 153 |
|
QModelToolBar #
QModelToolBar(menu_id: str, app: Application | str, *, exclude: Collection[str] | None = None, title: str | None = None, parent: QWidget | None = None)
Bases: QToolBar
QToolBar that is built from a list of model menu ids.
Parameters:
-
menu_id
(str
) –Menu ID to look up in the registry.
-
app
(Application | str
) –Application instance or name of application instance.
-
exclude
(Collection[str] | None
, default:None
) –Optional list of menu ids to exclude from the toolbar, by default None
-
title
(str | None
, default:None
) –Optional title for the menu, by default None
-
parent
(QWidget | None
, default:None
) –Optional parent widget, by default None
Source code in app_model/backends/qt/_qmenu.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
addMenu #
addMenu(menu: QMenu) -> None
No-op for toolbar.
Source code in app_model/backends/qt/_qmenu.py
202 203 |
|
findAction #
findAction(object_name: str) -> QAction | QModelMenu | None
Find an action by its ObjectName.
Parameters:
-
object_name
(str
) –Action ID to find. Note that
QCommandAction
haveObjectName
set to theircommand.id
Source code in app_model/backends/qt/_qmenu.py
205 206 207 208 209 210 211 212 213 214 |
|
rebuild #
rebuild(include_submenus: bool = True, exclude: Collection[str] | None = None) -> None
Rebuild toolbar by looking up self._menu_id in menu_registry.
Source code in app_model/backends/qt/_qmenu.py
235 236 237 238 239 240 241 242 243 244 245 |
|
update_from_context #
update_from_context(ctx: Mapping[str, object], _recurse: bool = True) -> None
Update the enabled/visible state of each menu item with ctx
.
See app_model.expressions
for details on expressions.
Parameters:
-
ctx
(Mapping
) –A namespace that will be used to
eval()
the'enablement'
and'when'
expressions provided for each action in the menu. ALL variables used in these expressions must either be present in thectx
dict, or be builtins. -
_recurse
(bool
, default:True
) –recursion check, internal use only
Source code in app_model/backends/qt/_qmenu.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
qkey2modelkey #
qkey2modelkey(key: Qt.Key) -> KeyCode | KeyCombo
Return KeyCode from Qt.Key.
Source code in app_model/backends/qt/_qkeymap.py
298 299 300 301 302 303 304 305 |
|
qkeycombo2modelkey #
qkeycombo2modelkey(key: QKeyCombination) -> KeyCode | KeyCombo
Return KeyCode or KeyCombo from QKeyCombination.
Source code in app_model/backends/qt/_qkeymap.py
308 309 310 311 312 313 314 315 |
|
qkeysequence2modelkeybinding #
qkeysequence2modelkeybinding(key: QKeySequence) -> KeyBinding
Return KeyBinding from QKeySequence.
Source code in app_model/backends/qt/_qkeymap.py
318 319 320 321 322 |
|
qmods2modelmods #
qmods2modelmods(modifiers: Qt.KeyboardModifier) -> KeyMod
Return KeyMod from Qt.KeyboardModifier.
Source code in app_model/backends/qt/_qkeymap.py
276 277 278 279 280 281 282 283 284 285 |
|
to_qicon #
to_qicon(icon: Icon, theme: Literal['dark', 'light'] = 'dark') -> QIcon
Create QIcon from Icon.
Source code in app_model/backends/qt/_util.py
14 15 16 17 18 19 20 21 22 23 24 25 |
|