代码拉取完成,页面将自动刷新
同步操作将从 PyQt5/CustomWidgets 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2019年7月23日
@author: Irony
@site: https://pyqt5.com https://github.com/892768447
@email: 892768447@qq.com
@file: TestCpaginationBar1
@description:
"""
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIntValidator
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QSpacerItem,\
QSizePolicy, QLineEdit, QPushButton
from CustomWidgets.CPaginationBar import CPaginationBar, FlatStyle, Style
__Author__ = 'Irony'
__Copyright__ = 'Copyright (c) 2019 Irony'
__Version__ = 1.0
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QVBoxLayout(self)
# 测试1
self.pageLabel1 = QLabel('当前页: 1', self, alignment=Qt.AlignCenter)
layout.addWidget(self.pageLabel1)
# 分页控件
self.paginationBar1 = CPaginationBar(self, totalPages=20)
# 设置扁平样式
self.paginationBar1.setStyleSheet(FlatStyle)
self.paginationBar1.pageChanged.connect(
lambda page: self.pageLabel1.setText('当前页: %d' % page))
layout.addWidget(self.paginationBar1)
layout.addItem(QSpacerItem(
20, 40, QSizePolicy.Minimum, QSizePolicy.Minimum))
# 测试2
self.pageLabel2 = QLabel('当前页: 1', self, alignment=Qt.AlignCenter)
layout.addWidget(self.pageLabel2)
# 分页控件
self.paginationBar2 = CPaginationBar(self, totalPages=20)
# 设置普通样式
self.paginationBar2.setStyleSheet(Style)
self.paginationBar2.pageChanged.connect(
lambda page: self.pageLabel2.setText('当前页: %d' % page))
layout.addWidget(self.paginationBar2)
layout.addItem(QSpacerItem(
20, 40, QSizePolicy.Minimum, QSizePolicy.Minimum))
# 测试3
self.pageLabel3 = QLabel('当前页: 1', self, alignment=Qt.AlignCenter)
layout.addWidget(self.pageLabel3)
# 分页控件
self.paginationBar3 = CPaginationBar(self, totalPages=20)
# 设置信息
self.paginationBar3.setInfos('共 400 条')
# 设置扁平样式
self.paginationBar3.setStyleSheet(FlatStyle)
self.paginationBar3.pageChanged.connect(
lambda page: self.pageLabel3.setText('当前页: %d' % page))
layout.addWidget(self.paginationBar3)
layout.addItem(QSpacerItem(
20, 40, QSizePolicy.Minimum, QSizePolicy.Minimum))
# 测试4
self.pageLabel4 = QLabel('当前页: 1', self, alignment=Qt.AlignCenter)
layout.addWidget(self.pageLabel4)
# 分页控件
self.paginationBar4 = CPaginationBar(self, totalPages=20)
# 设置信息
self.paginationBar4.setInfos('共 400 条')
# 开启跳转功能
self.paginationBar4.setJumpWidget(True)
# 设置普通样式
self.paginationBar4.setStyleSheet(Style)
self.paginationBar4.pageChanged.connect(
lambda page: self.pageLabel4.setText('当前页: %d' % page))
layout.addWidget(self.paginationBar4)
layout.addItem(QSpacerItem(
40, 40, QSizePolicy.Minimum, QSizePolicy.Minimum))
self.pageEdit = QLineEdit(self)
self.pageEdit.setValidator(QIntValidator(self.pageEdit))
self.pageEdit.setPlaceholderText('输入总页数')
layout.addWidget(self.pageEdit)
self.setButton = QPushButton(
'设置总页数', self, clicked=self.doSetPageNumber)
layout.addWidget(self.setButton)
def doSetPageNumber(self):
page = self.pageEdit.text().strip()
if not page:
return
page = int(page)
self.paginationBar1.setTotalPages(page)
self.paginationBar2.setTotalPages(page)
self.paginationBar3.setTotalPages(page)
self.paginationBar4.setTotalPages(page)
if __name__ == '__main__':
import sys
import cgitb
sys.excepthook = cgitb.enable(1, None, 5, '')
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。