PyTitleButton#

class ansys.aedt.toolkits.common.ui.utils.widgets.py_title_bar.py_title_button.PyTitleButton(parent, app_parent=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', icon_path='no_icon.svg', dark_one='#1b1e23', context_color='#568af2', text_foreground='#8a95aa', is_active=False)[source]#

Customizable title button.

Inherits QPushButton and provides a customizable title button.

Parameters:
parentQWidget

Parent widget.

app_parentQWidget, optional

Application parent widget. The default is None.

tooltip_textstr, optional

Tooltip text for the button. The default is an empty string.

btn_idstr, optional

Button ID. The default is None.

widthint, optional

Width of the button. The default is 30.

heightint, optional

Height of the button. The default is 30.

radiusint, optional

Border radius of the button. The default is 8.

bg_colorstr, optional

Background color of the button. The default is "#343b48".

bg_color_hoverstr, optional

Background color when the mouse hovers over the button. The default is "#3c4454".

bg_color_pressedstr, optional

Background color when the button is pressed. The default is "#2c313c".

icon_colorstr, optional

Icon color of the button. The default is "#c3ccdf".

icon_color_hoverstr, optional

Icon color when the mouse hovers over the button. The default is "#dce1ec".

icon_color_pressedstr, optional

Icon color when the button is pressed. The default is "#edf0f5".

icon_color_activestr, optional

Icon color when the button is active. The default is "#f5f6f9".

icon_pathstr, optional

Path to the icon image. The default is "no_icon.svg".

dark_onestr, optional

Dark color for styling. The default is "#1b1e23".

context_colorstr, optional

Context color for styling. The default is "#568af2".

text_foregroundstr, optional

Text foreground color. The default is "#8a95aa".

is_activebool, optional

Initial state of the button (active or not). The default is False.

Examples

>>> import sys
>>> from PySide6.QtWidgets import QApplication, QWidget
>>> from ansys.aedt.toolkits.common.ui.utils.widgets import PyTitleButton
>>> class MyApp(QWidget):
...     def __init__(self):
...         super().__init__()
...         self.title_button = PyTitleButton(self, tooltip_text="Click me!")
...         self.title_button.clicked.connect(self.on_button_clicked)
...         self.title_button.released.connect(self.on_button_released)
...
...     def on_button_clicked(self):
...         print("Button Clicked!")
...
...     def on_button_released(self):
...         print("Button Released!")
...
>>> if __name__ == "__main__":
...     app = QApplication([])
...     window = MyApp()
...     sys.exit(app.exec())
change_style(event)[source]#

Change the style of the button based on the given event.

Parameters:
eventQEvent

The event triggering the style change.

enterEvent(event)[source]#

Event triggered when the mouse enters the button.

Parameters:
eventQEvent

Mouse enter event.

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

Draw the icon with specified colors.

Parameters:
qpQPainter

The QPainter object.

imagestr

Path to the icon image.

rectQRect

Rectangle representing the button’s area.

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]#

Event triggered when the mouse leaves the button.

Parameters:
eventQEvent

Mouse leave event.

mousePressEvent(event)[source]#

Event triggered when the left mouse button is pressed.

Parameters:
eventQEvent

Mouse press event.

mouseReleaseEvent(event)[source]#

Event triggered when the left mouse button is released.

Parameters:
eventQEvent

Mouse release event.

move_tooltip()[source]#

Move the tooltip to the appropriate position relative to the button.

paintEvent(event)[source]#

Paint the button and its icon.

Parameters:
eventQEvent

Paint event.

set_active(is_active)[source]#

Set the active state of the button.

Parameters:
is_activebool

True to set the button as active, False otherwise.

set_icon(icon_path)[source]#

Set the icon of the button.

Parameters:
icon_pathstr

Path to the icon image.