PyToggle#
- class ansys.aedt.toolkits.common.ui.utils.widgets.py_toggle.py_toggle.PyToggle(width=50, bg_color='#777', circle_color='#DDD', active_color='#00BCFF', animation_curve=Type.OutBounce)[source]#
Customizable toggle switch.
Inherits QCheckBox and provides a customizable toggle switch with options for width, background color, circle color, active color, and animation curve.
- Parameters:
- width
int
,optional
Width of the toggle switch. The default is
50
.- bg_color
str
,optional
Background color of the toggle switch. The default is
"#777"
.- circle_color
str
,optional
Color of the circle in the toggle switch. The default is
"#DDD"
.- active_color
str
,optional
Color of the toggle switch when active. The default is
"#00BCFF"
.- animation_curve
QEasingCurve
,optional
Animation curve for the toggle switch. The default is
QEasingCurve.OutBounce
.
- width
Examples
>>> import sys >>> from PySide6.QtWidgets import QApplication >>> from ansys.aedt.toolkits.common.ui.utils.widgets import PyToggle
>>> class MyApp(QWidget): ... def __init__(self): ... super().__init__() ... self.toggle = PyToggle() ... self.toggle.stateChanged.connect(self.toggle_state_changed) ... self.toggle.show()
… def toggle_state_changed(self, state): … print(“Toggle State:”, state)
>>> if __name__ == "__main__": ... app = QApplication([]) ... window = MyApp() ... sys.exit(app.exec())
- hitButton(pos: QPoint)[source]#
Determine if a button press occurred within the toggle switch.
- Parameters:
- pos
QPoint
The position of the button press.
- pos
- Returns:
- bool
True if the button press occurred within the toggle switch, False otherwise.
- position = <PySide6.QtCore.Property object>#