iOS Style Toggle Button for Autodesk Maya (2014, 2016, 2017, 2018) using PySide / PySide2 (Python for Qt)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
screenshots
LICENSE
README.md
toggle_button.py

README.md

ios-togglebutton-for-maya

iOS Toggle Button Style for Autodesk Maya (2014, 2016, 2017, 2018), using PySide / PySide2 (Python for Qt)

Class

Inherited from QtWidgets.QWidget

class ToggleButton(QtWidgets.QWidget)

class ToggleButton(parent=None,
                   width=None, height=None,
                   colorSwitch=WHITE,
                   colorActive=BLUE_LIGHT,
                   colorInactive=GRAY,
                   roundedCorner = True)

Parameters

Type Flag Description
QWidget parent Parent widget
int width Width, default to (height * 2) if not provided
int height Height, default to (width * 0.5) if not provided.
Default to 32 if both width & height is not provided.
QColor colorSwitch Switch color.
QColor colorActive Background color when Toggle Button is active.
QColor colorInctive Background color when Toggle Button is inactive.
bool roundedCorner Rounded / Square corner style.

Properties

Type Name Description
bool state Toggle button state

Signal

Name Description
clicked(bool) Called when toggle button is clicked

Example Usage

import toggle_button

def print_me(state):
  print 'Toggle State: ', state

# Default toggle button with 32 height, and blue color as the active color
widget = toggle_button.ToggleButton()
widget.show()
widget.clicked.connect(print_me)

alt text

import toggle_button

widget = toggle_button.ToggleButton(width=100, colorActive=toggle_button.RED)
widget.show()

alt text

import toggle_button
widget = toggle_button.ToggleButton(height=20, colorActive=toggle_button.QtGui.QColor('#8BC34A'),
                                    colorInactive=toggle_button.QtGui.QColor('#FF9800'))
widget.show()

alt text

import toggle_button
# A Square Toggle Button with custom size & colors
widget = toggle_button.ToggleButton(width=100, height=40,
                                    colorActive=toggle_button.QtGui.QColor(149,117,205),
                                    colorInactive=toggle_button.QtGui.QColor(77,182,172),
                                    colorSwitch=toggle_button.QtGui.QColor(240,244,195),
                                    roundedCorner=False)
widget.show()

alt text