msl.qt.widgets.button module¶
A QToolButton
to display text, an icon and a menu.
- class msl.qt.widgets.button.Button(*, text=None, icon=None, icon_size=None, left_click=None, right_click=None, is_text_under_icon=True, tooltip=None, parent=None)[source]¶
Bases:
QToolButton
A
QToolButton
to display text, an icon and a menu.- Parameters:
text (
str
, optional) – The text to display on the button.icon (
object
, optional) – Any icon object that is supported byto_qicon()
.icon_size (
int
,float
,tuple
ofint
orQtCore.QSize
, optional) – Rescale the icon to the specified size. If the value isNone
then do not rescale the icon. If anint
then set the width and the height to be the size value. If afloat
then a scaling factor. If atuple
then the (width, height) values.left_click (
callable
, optional) – The function to be called for a mouse left-click event.right_click (
callable
, optional) – The function to be called for a mouse right-click event.is_text_under_icon (
bool
, optional) – If displaying an icon and text then whether to place the text under,True
, or beside,False
, the icon.tooltip (
str
, optional) – The tooltip to display for the button.parent (
QtWidgets.QWidget
, optional) – The parent widget.
- add_menu_item(*, text=None, triggered=None, icon=None, shortcut=None, tooltip=None)[source]¶
Add a new item to the action menu.
- Parameters:
text (
str
, optional) – The text to display for this item.triggered (
callable
, optional) – The function to be called when this item is selected. IfNone
then the item is displayed, but it is disabled.icon (
object
, optional) – Any icon object that is supported byto_qicon()
.shortcut (
str
, optional) – The keyboard shortcut to use to select this item, e.g.,'CTRL+A'
tooltip (
str
, optional) – The tooltip to display for this item.
- class msl.qt.widgets.button.ButtonMenu(self, parent: PySide6.QtWidgets.QWidget | None = None)[source]¶
- class msl.qt.widgets.button.ButtonMenu(self, title: str, parent: PySide6.QtWidgets.QWidget | None = None)
Bases:
QMenu
Initialize self. See help(type(self)) for accurate signature.
- showEvent(event)[source]¶
Overrides
QtWidgets.QWidget.showEvent()
.