https://github.com/kleydon/segmentedcontrol-demo-qt-python
Segmented control widget for Python and Qt
https://github.com/kleydon/segmentedcontrol-demo-qt-python
interface pyqt python qt segmented-controls segmentedcontrol ui ui-components widget widget-toolkit
Last synced: about 1 year ago
JSON representation
Segmented control widget for Python and Qt
- Host: GitHub
- URL: https://github.com/kleydon/segmentedcontrol-demo-qt-python
- Owner: kleydon
- License: mit
- Created: 2019-05-09T00:42:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-09T22:05:14.000Z (almost 7 years ago)
- Last Synced: 2025-01-13T08:34:21.169Z (over 1 year ago)
- Topics: interface, pyqt, python, qt, segmented-controls, segmentedcontrol, ui, ui-components, widget, widget-toolkit
- Language: Python
- Size: 24.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SegmentedControl-Demo-Qt-Python
PyQt hasn't included a "stock" segmented control (set of mutually-exclusive, visually abbutting buttons), so I wrote one in Python.
## Usage:
```
#Disabled, Two Buttons:
sc0 = SegmentedControl()
sc0.AppendSegmentButton("No")
sc0.AppendSegmentButton("Yes")
sc0.setEnabled(False)
#Enabled, Three Buttons:
sc1 = SegmentedControl()
sc1.AppendSegmentButton("No")
sc1.AppendSegmentButton("Maybe")
sc1.AppendSegmentButton("Yes")
#Enabled, NOT Mutually Exclusive:
sc2 = SegmentedControl(False)
sc2.AppendSegmentButton("No")
sc2.AppendSegmentButton("Maybe")
sc2.AppendSegmentButton("Yes")
#Text with Icon:
sc3 = SegmentedControl()
sc3.AppendSegmentButton("No", "./../Images/img20x20.png", QtCore.QSize(12, 12))
sc3.AppendSegmentButton("Maybe", "./../Images/img20x20.png", QtCore.QSize(12, 12))
sc3.AppendSegmentButton("Yes", "./../Images/img20x20.png", QtCore.QSize(12, 12))
#Icon Only:
sc4 = SegmentedControl()
sc4.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(14, 14))
sc4.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(14, 14))
sc4.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(14, 14))
#Larger Icon:
sc5 = SegmentedControl()
sc5.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
sc5.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
sc5.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
#Mixed; Four Buttons, with an Initial Selection:
sc6 = SegmentedControl()
sc6.AppendSegmentButton("No")
sc6.AppendSegmentButton("Yes", "./../Images/img10x10.png", QtCore.QSize(10, 10))
sc6.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(20, 20))
sc6.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
sc6.setButtonState(1, True)
#Setting up Button Callbacks
#Clicked:
sc0.buttonIdClicked.connect(firstRowClickedButtonId)
#Pressed:
sc0.buttonIdPressed.connect(firstRowPressedButtonId)
#Released:
sc0.buttonIdReleased.connect(firstRowReleasedButtonId)
```