PyQt5系列文章
基本控件 |
- |
- |
- |
1.按钮QPushButton |
2.标签QLabel |
3.可编辑框QTextEdit |
4.文本提示QToolTip |
5.单行输入框QLineEdit |
6.消息框QMessageBox |
7.单选按钮QRadioButton |
8.下拉列表QComboBox |
9.图片显示QPixmap |
10.分组框QGroupBox |
11.进度条QProgressBar |
12.对话框QDialog |
13.进度条对话框QProgressDialog |
14.复选框QCheckBox |
15.滑块QSlider |
16.状态栏QStatusBar |
17.文件对话框QFileDialog |
18.工具栏QToolBar |
19.分割条QSplitter |
20.菜单栏QMenuBar |
21.滚动条QScrollBar |
22.时间编辑框QTimeEdit |
23.日期编辑框QDateEdit |
24.时间日期编辑框QDateTimeEdit |
高级控件 |
- |
- |
- |
1.列表控件QListWidget |
2.表格控件QTableWidget |
3.树形控件QTreeWidget |
4.选项卡QTabWidget |
5.浮动窗口QDockWidget |
6.堆叠窗口QStackedWidget |
7.堆叠布局QStackedLayout |
8.网格布局QGridLayout |
9.表单布局QFormLayout |
10.水平布局QHBoxLayout |
11.垂直布局QVBoxLayout |
12.日历QCalendarWidget |
13.线程QThread |
14.定时器QTimer |
- |
- |
效果图
完整代码
import sys
from PyQt5.QtWidgets import QLabel,QScrollBar,QHBoxLayout,QWidget,QApplication,QMainWindow
class QScrollBarDemo(QMainWindow):
def __init__(self):
super(QScrollBarDemo, self).__init__()
self.resize(400, 150)
self.setWindowTitle("QScrollBarDemo")
self.label = QLabel('滚动条的值')
self.scrollBar1 = QScrollBar()
self.scrollBar1.setMaximum(255)
self.scrollBar1.sliderMoved.connect(self.sliderChange)
self.scrollBar2 = QScrollBar()
self.scrollBar2.setMaximum(255)
self.scrollBar2.sliderMoved.connect(self.sliderChange)
layout = QHBoxLayout()
layout.addWidget(self.label)
layout.addWidget(self.scrollBar1)
layout.addWidget(self.scrollBar2)
mainFrame = QWidget()
mainFrame.setLayout(layout)
self.setCentralWidget(mainFrame)
def sliderChange(self):
self.label.setText("滚动条1的值:"+str(self.scrollBar1.value())+", 滚动条2的值:"+str(self.scrollBar2.value()))
if __name__ == '__main__':
app = QApplication(sys.argv)
main = QScrollBarDemo()
main.show()
sys.exit(app.exec_())