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_pathstr

Path to the icon image file.

tooltip_textstr, optional

Text for tooltip.

btn_idstr, optional

Identifier for the button.

widthint, optional

Width of the button.

heightint, optional

Height of the button.

radiusint, optional

Radius for rounded corners.

bg_colorstr, optional

Background color in hex color code.

bg_color_hoverstr, optional

Background color when hovered in hex color code.

bg_color_pressedstr, optional

Background color when being pressed in hex color code.

icon_colorstr, optional

Icon color in hex color code.

icon_color_hoverstr, optional

Icon color when hovered in hex color code.

icon_color_pressedstr, optional

Icon color when being pressed in hex color code.

icon_color_activestr, optional

Active icon color in hex color code.

dark_onestr, optional

Color for dark theme in hex color code.

text_foregroundstr, optional

Text color in hex color code.

context_colorstr, optional

Context color in hex color code.

top_marginint, 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.

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:
eventQEvent

Event triggering the style change.

enterEvent(event)[source]#

Handle the enter event.

Parameters:
eventQEvent

Enter event.

icon_paint(qp, image, rect)[source]#

Paint the icon on the button.

Parameters:
qpQPainter

QPainter object.

imagestr

Path to the icon image file.

rectQRect

Rectangle for the icon placement.

is_active()[source]#

Check if the button is in an active state.

Returns:
bool

True if the button is active, False otherwise.

leaveEvent(event)[source]#

Handle the leave event.

Parameters:
eventQEvent

Leave event.

mousePressEvent(event)[source]#

Handle the mouse press event.

Parameters:
eventQEvent

Mouse press event.

mouseReleaseEvent(event)[source]#

Handle the mouse release event.

Parameters:
eventQEvent

Mouse release event.

paintEvent(event)[source]#

Paint the button.

Parameters:
eventQEvent

Paint event.

set_active(is_active)[source]#

Set the active state of the button.

Parameters:
is_activebool

Whether the button is active or not.

set_icon(icon_path)[source]#

Set the icon for the button.

Parameters:
icon_pathstr

Path to the icon image file.