{"id":15021590,"url":"https://github.com/yjg30737/pyqt-switch","last_synced_at":"2025-09-08T05:32:45.634Z","repository":{"id":57676955,"uuid":"447848504","full_name":"yjg30737/pyqt-switch","owner":"yjg30737","description":"PyQt Switch (O ) -\u003e ( O)","archived":false,"fork":false,"pushed_at":"2024-09-25T02:47:58.000Z","size":33,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T09:21:32.914Z","etag":null,"topics":["pyqt","pyqt-examples","pyqt-gui","pyqt-tutorial","pyqt5","pyqt5-examples","pyqt5-gui","pyqt5-tutorial","pyqtsignal","python","python3","python37","qpushbutton","qt","switchbutton"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yjg30737.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-14T05:03:35.000Z","updated_at":"2024-09-25T02:48:02.000Z","dependencies_parsed_at":"2024-10-23T05:59:51.175Z","dependency_job_id":null,"html_url":"https://github.com/yjg30737/pyqt-switch","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.03448275862068961,"last_synced_commit":"da9bf7792b4f1de5ef6581a44791af46df5cd48a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpyqt-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yjg30737","download_url":"https://codeload.github.com/yjg30737/pyqt-switch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232282813,"owners_count":18499327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pyqt","pyqt-examples","pyqt-gui","pyqt-tutorial","pyqt5","pyqt5-examples","pyqt5-gui","pyqt5-tutorial","pyqtsignal","python","python3","python37","qpushbutton","qt","switchbutton"],"created_at":"2024-09-24T19:56:45.911Z","updated_at":"2025-01-03T02:52:06.213Z","avatar_url":"https://github.com/yjg30737.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyqt-switch\nPyQt Switch (O ) -\u003e ( O)\n\nYou can choose the option to set the colorizing/moving animation.\n\n## Requirements\nPyQt5 \u003e= 5.8\n\n## Setup\n`python -m pip install pyqt-switch`\n\n## Feature\n* Provide `toggled(bool)` signal\n* Set the animation with `setAnimation(f: bool)`. Default is False.\n* Set the diameter of circle-shaped switch button with `setCircleDiameter(diameter: int)`. Default is 20(px).\n* `setChecked(bool)` - Toggle the switch programmatically\n* `isChecked()` - Check switch is turned on\n\n## Example\nCode Sample\n```python\nfrom PyQt5.QtWidgets import QWidget, QFormLayout, QApplication, QLabel\nfrom pyqt_switch import PyQtSwitch\n\n\nclass Widget(QWidget):\n    def __init__(self):\n        super().__init__()\n        self.__initUi()\n\n    def __initUi(self):\n        self.__label = QLabel()\n        self.__label.setText('No')\n\n        switch = PyQtSwitch()\n        switch.toggled.connect(self.__toggled)\n        switch.setAnimation(True)\n        # switch.setChecked(True)\n        # switch.setCircleDiameter(40)\n\n        # if switch.isChecked():\n        #     print('Yes')\n        # else:\n        #     print('No')\n\n        lay = QFormLayout()\n        lay.addRow(self.__label, switch)\n        self.setLayout(lay)\n\n    def __toggled(self, f):\n        if f:\n            self.__label.setText('Yes')\n        else:\n            self.__label.setText('No')\n\n\nif __name__ == \"__main__\":\n    import sys\n\n    app = QApplication(sys.argv)\n    example = Widget()\n    example.show()\n    app.exec_()\n```\n\nResult\n\nhttps://user-images.githubusercontent.com/55078043/169001914-0b86407a-5670-4ae4-ac28-54ec85460bc0.mp4\n\nIf you set the circle diameter to 40 with `switch.setCircleDiameter(40)`\n\n![image](https://user-images.githubusercontent.com/55078043/169002295-8717adf8-a1e6-4126-8ef9-42ff8bb3988c.png)\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjg30737%2Fpyqt-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyjg30737%2Fpyqt-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjg30737%2Fpyqt-switch/lists"}