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:
widthint, optional

Width of the toggle switch. The default is 50.

bg_colorstr, optional

Background color of the toggle switch. The default is "#777".

circle_colorstr, optional

Color of the circle in the toggle switch. The default is "#DDD".

active_colorstr, optional

Color of the toggle switch when active. The default is "#00BCFF".

animation_curveQEasingCurve, optional

Animation curve for the toggle switch. The default is QEasingCurve.OutBounce.

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

The position of the button press.

Returns:
bool

True if the button press occurred within the toggle switch, False otherwise.

paintEvent(e)[source]#

Paint the toggle switch.

Parameters:
eQPaintEvent

Paint event.

position = <PySide6.QtCore.Property object>#