Skip to main content

pyqt-switch

PyQt Switch (O ) -> ( O)

You can choose the option to set the colorizing/moving animation.

Requirements

PyQt5 >= 5.8

Setup

python -m pip install pyqt-switch

Feature

  • Provide toggled(bool) signal

  • Set the animation with setAnimation(f: bool). Default is False.

  • Set the diameter of circle-shaped switch button with setCircleDiameter(diameter: int). Default is 20(px).

Example

Code Sample

from PyQt5.QtWidgets import QWidget, QFormLayout, QApplication, QLabel

from pyqt_switch import PyQtSwitch





class Widget(QWidget):

    def __init__(self):

        super().__init__()

        self.__initUi()



    def __initUi(self):

        switch = PyQtSwitch()

        switch.toggled.connect(self.__toggled)

        switch.setAnimation(True)

        # switch.setCircleDiameter(40)



        self.__label = QLabel()

        self.__label.setText('No')

        lay = QFormLayout()

        lay.addRow(self.__label, switch)

        self.setLayout(lay)



    def __toggled(self, f):

        if f:

            self.__label.setText('Yes')

        else:

            self.__label.setText('No')





if __name__ == "__main__":

    import sys



    app = QApplication(sys.argv)

    example = Widget()

    example.show()

    app.exec_()

Result

https://user-images.githubusercontent.com/55078043/169001914-0b86407a-5670-4ae4-ac28-54ec85460bc0.mp4

If you set the circle diameter to 40 with switch.setCircleDiameter(40)

image

Release files for pyqt-switch 0.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyqt-switch 0.0.16
File Size Uploaded
pyqt-switch-0.0.16.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyqt-switch 0.0.16
File Interpreter ABI Platform
pyqt_switch-0.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / pyqt-switch-0.0.16.tar.gz

Download URL pyqt-switch-0.0.16.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b32f9105b3f5492d31cd668d81d37c67b688607f6dab849e3b6a5fe0ade52733
BLAKE2b-256 checksum
How to use checksums
0c985891e9b6d8f8ce9358762e548de021f922742c376209e63e82a5d91263a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 CPython/3.7.6

Release files / pyqt_switch-0.0.16-py3-none-any.whl

Download URL pyqt_switch-0.0.16-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f15d7f8e87c72b0da3759689d7466c9ebb67c2bee99829fe5f267d5d663a7fd9
BLAKE2b-256 checksum
How to use checksums
423f9894af17ce4fbfe65338da11e05b931334bf1f6001cd70a774d8c39e28f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.0.16 This release

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page