PyIconButton#
- class ansys.aedt.toolkits.common.ui.utils.widgets.py_icon_button.py_icon_button.PyIconButton(icon_path=None, tooltip_text='', btn_id=None, width=30, height=30, radius=8, bg_color='#343b48', bg_color_hover='#3c4454', bg_color_pressed='#2c313c', icon_color='#c3ccdf', icon_color_hover='#dce1ec', icon_color_pressed='#edf0f5', icon_color_active='#f5f6f9', dark_one='#1b1e23', text_foreground='#8a95aa', context_color='#568af2', top_margin=40, is_active=False)[source]#
Icon button widget that can be used as a colored icon.
The icon and color can be customized during initialization.
- Parameters:
- icon_path
str
Path to the icon image file.
- tooltip_text
str
,optional
Text for tooltip.
- btn_id
str
,optional
Identifier for the button.
- width
int
,optional
Width of the button.
- height
int
,optional
Height of the button.
- radius
int
,optional
Radius for rounded corners.
- bg_color
str
,optional
Background color in hex color code.
- bg_color_hover
str
,optional
Background color when hovered in hex color code.
- bg_color_pressed
str
,optional
Background color when being pressed in hex color code.
- icon_color
str
,optional
Icon color in hex color code.
- icon_color_hover
str
,optional
Icon color when hovered in hex color code.
- icon_color_pressed
str
,optional
Icon color when being pressed in hex color code.
- icon_color_active
str
,optional
Active icon color in hex color code.
- dark_one
str
,optional
Color for dark theme in hex color code.
- text_foreground
str
,optional
Text color in hex color code.
- context_color
str
,optional
Context color in hex color code.
- top_margin
int
,optional
Top margin for tooltip.
- is_activebool,
optional
Whether the button is currently active.
- The rest of the parameters customize the look and emit signals for
- different user interactions.
- icon_path
Examples
>>> import sys >>> from PySide6.QtWidgets import QApplication, QVBoxLayout, QPushButton >>> from ansys.aedt.toolkits.common.ui.utils.widgets import *
>>> class Example(QWidget): >>> def __init__(self): >>> super().__init__() >>> layout = QVBoxLayout(self) >>> layout.addWidget(QPushButton("Button 1")) >>> layout.addWidget(PyIconButton('icon_signal.svg', "#FF0000", tooltip_text="Example") >>> ) >>> layout.addWidget(QPushButton("Button 2"))
>>> if __name__ == "__main__": >>> app = QApplication([]) >>> window = Example() >>> window.show() >>> app.exec()
- change_style(event)[source]#
Change the style of the button based on the given event.
- Parameters:
- event
QEvent
Event triggering the style change.
- event
- icon_paint(qp, image, rect)[source]#
Paint the icon on the button.
- Parameters:
- qp
QPainter
QPainter object.
- image
str
Path to the icon image file.
- rect
QRect
Rectangle for the icon placement.
- qp
- is_active()[source]#
Check if the button is in an active state.
- Returns:
- bool
True if the button is active, False otherwise.
- mousePressEvent(event)[source]#
Handle the mouse press event.
- Parameters:
- event
QEvent
Mouse press event.
- event
- mouseReleaseEvent(event)[source]#
Handle the mouse release event.
- Parameters:
- event
QEvent
Mouse release event.
- event