-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqt5-slider.py
29 lines (23 loc) · 879 Bytes
/
qt5-slider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
from PyQt5.QtWidgets import QApplication, QSlider, QMainWindow, QDesktopWidget
from PyQt5.QtCore import Qt
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.setWindowTitle("qt5 with python")
self.setGeometry(0, 0, 512, 512)
# center window on desktop
rectangle = self.frameGeometry()
center = QDesktopWidget().availableGeometry().center()
rectangle.moveCenter(center)
self.move(rectangle.topLeft())
slider = QSlider(Qt.Horizontal)
slider.setFocusPolicy(Qt.StrongFocus)
slider.setTickPosition(QSlider.TicksBothSides)
slider.setTickInterval(16)
slider.setSingleStep(1)
self.setCentralWidget(slider)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()