• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

python实现分页效果

python 搞代码 4年前 (2022-01-08) 22次浏览 已收录 0个评论

这篇文章主要为大家详细介绍了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.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: <div style="color:transparent">来源gaodai.ma#com搞##代!^码网</div>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_()) 

 效果图:

以上就是python实现分页效果的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:python实现分页效果
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址