标签:
# -*- coding: utf-8 -*-
__author__ = ‘Administrator‘
from PyQt4 import QtCore, QtGui
class Help(QtGui.QMainWindow):
def __init__(self):
super(Help, self).__init__()
#QTimeEdit
self.TimeEdit = QtGui.QTimeEdit()
#Hours ScrollBar
self.HourScrollBar = QtGui.QScrollBar(QtCore.Qt.Horizontal)
self.HourScrollBar.setMinimum(0)
self.HourScrollBar.setMaximum(23)
self.HourScrollBar.setFocusPolicy(QtCore.Qt.StrongFocus)
#Minutes ScrollBar
self.MinScrollBar = QtGui.QScrollBar(QtCore.Qt.Horizontal)
self.MinScrollBar.setMinimum(0)
self.MinScrollBar.setMaximum(59)
self.MinScrollBar.setFocusPolicy(QtCore.Qt.StrongFocus)
#Seconds ScrollBar
self.SecScrollBar = QtGui.QScrollBar(QtCore.Qt.Horizontal)
self.SecScrollBar.setMinimum(0)
self.SecScrollBar.setMaximum(59)
self.SecScrollBar.setFocusPolicy(QtCore.Qt.StrongFocus)
#ScrollBar connections
self.HourScrollBar.valueChanged.connect(self.HourChanged)
self.MinScrollBar.valueChanged.connect(self.MinChanged)
self.SecScrollBar.valueChanged.connect(self.SecChanged)
#Main layout and widget
MainWidget = QtGui.QWidget()
MainLayout = QtGui.QVBoxLayout()
MainLayout.addWidget(self.TimeEdit)
MainLayout.addWidget(self.HourScrollBar)
MainLayout.addWidget(self.MinScrollBar)
MainLayout.addWidget(self.SecScrollBar)
MainWidget.setLayout(MainLayout)
self.setCentralWidget(MainWidget)
def HourChanged(self):
self.TimeEdit.setTime(QtCore.QTime.fromString(str(self.HourScrollBar.value()), "h"))
def MinChanged(self):
self.TimeEdit.setTime(QtCore.QTime.fromString(str(self.MinScrollBar.value()), "m"))
def SecChanged(self):
self.TimeEdit.setTime(QtCore.QTime.fromString(str(self.SecScrollBar.value()), "s"))
if __name__ == ‘__main__‘:
import sys
app = QtGui.QApplication(sys.argv)
w = Help()
w.show()
sys.exit(app.exec_())
标签:
原文地址:http://www.cnblogs.com/mhxy13867806343/p/4200922.html