python实现分页效果
作者:飞奔的猫 发布时间:2021-07-12 16:00:44
标签:python,分页
本文实例为大家分享了python实现分页效果展示的具体代码,供大家参考,具体内容如下
难点:清空Layout
#!/usr/bin/python
#-*-coding:utf-8-*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class PageWidget(QWidget):
def __init__(self,parent=None):
super(PageWidget,self).__init__(parent)
self.btns=[]
self.count=0
self.presign=0 #当前点击标识
self.nextsign=0 #当前点击标识
self.pre_button=QPushButton()
self.pre_button.setText("<<")
self.pre_button.setFixedSize(25,25)
self.connect(self.pre_button,SIGNAL("clicked()"),self,SLOT("prepage()"))
self.next_button=QPushButton()
self.next_button.setText(">>")
self.connect(self.next_button,SIGNAL("clicked()"),self,SLOT("nextpage()"))
self.next_button.setFixedSize(25,25)
self.center_layout=QHBoxLayout()
self.nextpage()
self.page_layput=QHBoxLayout()
self.page_layput.addWidget(self.pre_button)
self.page_layput.addLayout(self.center_layout)
self.page_layput.addWidget(self.next_button)
self.setLayout(self.page_layput)
@pyqtSlot()
def prepage(self):
self.presign=1
self.num=0
if (len(self.btns)>0) and (self.count>=10):
for p in range(10):
self.center_layout.removeWidget(self.btns[p])
self.btns[p].deleteLater()
self.btns=[]
if self.count>=10:
if self.nextsign==1:
self.count=self.count-20
self.nextsign=0
else:
self.count=self.count-10
self.num=self.count
for i in range(10):
self.num+=1
self.center_button=QPushButton()
self.center_button.setText(str(self.num))
self.center_button.setFixedSize(25,25)
self.btns.append(self.center_button)
self.center_layout.addWidget(self.center_button)
#print self.count
@pyqtSlot()
def nextpage(self):
self.nextsign=1
if len(self.btns)>0:
for p in range(10):
self.center_layout.removeWidget(self.btns[p])
self.btns[p].deleteLater()
self.btns=[]
if self.presign==1:
self.count=self.count+10
self.presign=0
#mapper转有参数
signal_mapper = QSignalMapper(self)
for i in range(10):
self.count+=1
self.center_button=QPushButton()
self.center_button.setText(str(self.count))
self.center_button.setFixedSize(25,25)
self.btns.append(self.center_button)
self.connect(self.center_button,SIGNAL("clicked()"),signal_mapper,SLOT("map()"))
signal_mapper.setMapping(self.center_button, str(self.count))
self.center_layout.addWidget(self.center_button)
self.connect(signal_mapper, SIGNAL("mapped(QString)"), self, SLOT("showpage(QString)"))
#print self.count
@pyqtSlot(QString)
def showpage(self,page):
print page
if __name__=='__main__':
import sys
app=QApplication(sys.argv)
page=PageWidget()
page.show()
sys.exit(app.exec_())
效果图:
来源:http://blog.csdn.net/jylonger/article/details/45767237


猜你喜欢
- 背景:加入现在有这样的数据,可能一条ocr代表两个label,并且label通过","分隔。我们想把数据转换成下面的。原
- 一、深复制与浅复制列表是Python中自带的一种数据结构,在使用列表时,拷贝操作不可避免,下面简单讨论一下列表的深复制(拷贝)与浅复制首先看
- 以下虚线框内为mk.asp文件的具体代码:<%filename="test.htm"if request
- 本文实例讲述了Python让字典保持有序的方法。分享给大家供大家参考,具体如下:问题:创建一个字典,同时对字典做迭代或序列化操作时,也能控制
- operator模块是python中内置的操作符函数接口,它定义了一些算术和比较内置操作的函数。operator模块是用c实现的,所以执行速
- 运行go中本地包的时候如果出现这个报错,网上很多说是需要修改GO111MODULE=on, 但是对于我来说都没用, 最后发现是因为命名导致的
- 原作者:Nik Piepenbreier翻译&内容补充:费弗里原文地址:https://towardsdatascience.com
- 1. 首先VC++的DLL的导出函数定义成标准C的导出函数: #ifdef LRDLLTEST_EXPORTS #define LRDLLT
- 1、概述Golang是一种强类型语言,虽然在代码中经常看到i:=12这种写法,这其实是编译器在编译期间自动做了类型推断。编译器会对数据进行类
- 一、数据库的备份1、选择要备份的数据库“accountInfo”,点击鼠标右键 → 任务 → 备份2、在打开的“备份数据库 —account
- 摘要:不同方法读取excel中的多个不同sheet表格性能比较# 方法1def read_excel(path): df=pd.
- 摘要:本文主要是讲解怎么样替换某一列的一个值。应用场景:假如我们有以下的数据集:我们想把里面不是pre的字符串全部换成Nonpre,我们要怎
- Problem:Solution:参考stackoverflow给出的解决方案:https://stackoverflow.com/ques
- 一、merge(合并)的语法:pd.merge(left, right, how='inner', on=None, lef
- TensorFlow是一款优秀的深度学习框架,支持多种常见的操作系统,例如Windows10,Mac Os等等,同时也支持运行在NVIDIA
- 对大家推荐很好使用的MySql节点系统,像让大家对MySql节点系统有所了解,然后对MySql节点系统全面讲解介绍,希望对大家有用在向大家详
- 代码为:import matplotlib.pyplot as plt #用于显示图片import matplotlib.image as
- 跳过开头首先是跳过开始部分,这个在我们读取文本的时候最常用。在实际的应用当中,比如记录的日志或者是代码等等,一般来说头部都会附上一段说明,或
- 项目需求:如何通过js获取上传的图片信息(临时保存路径,名称,大小)然后通过ajax传递给后端题主用jquery接收<input na
- 一、MYSQL的索引索引(Index):帮助Mysql高效获取数据的一种数据结构。用于提高查找效率,可以比作字典。可以简单理解为排好序的快速