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:
- parent
QWidget Parent widget.
- app_parent
QWidget,optional Application parent widget. The default is
None.- tooltip_text
str,optional Tooltip text for the button. The default is an empty string.
- btn_id
str,optional Button ID. The default is
None.- width
int,optional Width of the button. The default is
30.- height
int,optional Height of the button. The default is
30.- radius
int,optional Border radius of the button. The default is
8.- bg_color
str,optional Background color of the button. The default is
"#343b48".- bg_color_hover
str,optional Background color when the mouse hovers over the button. The default is
"#3c4454".- bg_color_pressed
str,optional Background color when the button is pressed. The default is
"#2c313c".- icon_color
str,optional Icon color of the button. The default is
"#c3ccdf".- icon_color_hover
str,optional Icon color when the mouse hovers over the button. The default is
"#dce1ec".- icon_color_pressed
str,optional Icon color when the button is pressed. The default is
"#edf0f5".- icon_color_active
str,optional Icon color when the button is active. The default is
"#f5f6f9".- icon_path
str,optional Path to the icon image. The default is
"no_icon.svg".- dark_one
str,optional Dark color for styling. The default is
"#1b1e23".- context_color
str,optional Context color for styling. The default is
"#568af2".- text_foreground
str,optional Text foreground color. The default is
"#8a95aa".- is_activebool,
optional Initial state of the button (active or not). The default is
False.
- parent
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:
- event
QEvent The event triggering the style change.
- event
- enterEvent(event)[source]#
Event triggered when the mouse enters the button.
- Parameters:
- event
QEvent Mouse enter event.
- event
- icon_paint(qp, image, rect)[source]#
Draw the icon with specified colors.
- Parameters:
- qp
QPainter The QPainter object.
- image
str Path to the icon image.
- rect
QRect Rectangle representing the button’s area.
- qp
- 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:
- event
QEvent Mouse leave event.
- event
- mousePressEvent(event)[source]#
Event triggered when the left mouse button is pressed.
- Parameters:
- event
QEvent Mouse press event.
- event
- mouseReleaseEvent(event)[source]#
Event triggered when the left mouse button is released.
- Parameters:
- event
QEvent Mouse release event.
- event