edifice.QtWidgetComponent¶
-
class
edifice.
QtWidgetComponent
(style=None, tool_tip=None, cursor=None, context_menu=None, css_class=None, on_click=None, on_key_down=None, on_key_up=None, on_mouse_down=None, on_mouse_up=None, on_mouse_enter=None, on_mouse_leave=None, on_mouse_move=None)[source]¶ Bases:
edifice._component.WidgetComponent
Base Qt Widget.
All Qt widgets inherit from this component and its props, which add basic functionality such as styling and event handlers.
- Parameters
style (
Union
[Mapping
[str
,Any
],Sequence
[Mapping
[str
,Any
]],None
]) – style for the widget. Could either be a dictionary or a list of dictionaries. See docs/style.md for a primer on styling.tool_tip (
Optional
[str
]) – the tool tip displayed when hovering over the widget.cursor (
Optional
[str
]) – the shape of the cursor when mousing over this widget. Must be one of: default, arrow, pointer, grab, grabbing, text, crosshair, move, wait, ew-resize, ns-resize, nesw-resize, nwse-resize, not-allowed, forbiddencontext_menu (
Optional
[Mapping
[str
,Union
[None
,Callable
[[],Any
],Mapping
[str
,Union
[None
,Callable
[[],Any
],ForwardRef
]]]]]) – the context menu to display when the user right clicks on the widget. Expressed as a dict mapping the name of the context menu entry to either a function (which will be called when this entry is clicked) or to another sub context menu. For example, {“Copy”: copy_fun, “Share”: {“Twitter”: twitter_share_fun, “Facebook”: facebook_share_fun}}css_class (
Optional
[Any
]) –a string or a list of strings, which will be stored in the “css_class” property of the Qt Widget. This can be used in an application stylesheet, like:
QLabel[css_class=”heading”] { font-size: 18px; }
on_click (
Optional
[Callable
[[QMouseEvent
],Any
]]) – callback for click events (mouse pressed and released). Takes a QMouseEvent object as argumenton_key_down (
Optional
[Callable
[[QKeyEvent
],Any
]]) – callback for key down events (key pressed). Takes a QKeyEvent object as argument. The key() method of QKeyEvent returns the raw key pressed (an element of the QtCore.Qt.Key enum, which is conveniently exposed as edifice.Key). The text() method returns the unicode of the key press, taking modifier keys (e.g. Shift) into account.on_key_up (
Optional
[Callable
[[QKeyEvent
],Any
]]) – callback for key up events (key released). Takes a QKeyEvent object as argument.on_mouse_down (
Optional
[Callable
[[QMouseEvent
],Any
]]) – callback for mouse down events (mouse pressed). Takes a QMouseEvent object as argumenton_mouse_up (
Optional
[Callable
[[QMouseEvent
],Any
]]) – callback for mouse up events (mouse released). Takes a QMouseEvent object as argumenton_mouse_enter (
Optional
[Callable
[[QMouseEvent
],Any
]]) – callback for mouse enter events (triggered once every time mouse enters widget). Takes a QMouseEvent object as argumenton_mouse_leave (
Optional
[Callable
[[QMouseEvent
],Any
]]) – callback for mouse leave events (triggered once every time mouse leaves widget). Takes a QMouseEvent object as argumenton_mouse_move (
Optional
[Callable
[[QMouseEvent
],Any
]]) – callback for mouse move events (triggered every time mouse moves within widget). Takes a QMouseEvent object as argument
Methods
Attributes
children
The children of this component.
props
The props of this component.