国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python實現(xiàn)分頁效果

2020-02-16 10:28:57
字體:
供稿:網(wǎng)友

本文實例為大家分享了python實現(xiàn)分頁效果展示的具體代碼,供大家參考,具體內(nèi)容如下

難點:清空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      #當(dāng)前點擊標識     self.nextsign=0     #當(dāng)前點擊標識     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轉(zhuǎn)有參數(shù)     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_())             
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴文县| 章丘市| 息烽县| 顺平县| 遂昌县| 宣恩县| 乐平市| 武安市| 贵阳市| 伊金霍洛旗| 安岳县| 仁布县| 玛纳斯县| 文昌市| 西吉县| 洛隆县| 塘沽区| 平乡县| 清涧县| 乐业县| 沾化县| 耿马| 江阴市| 新民市| 明溪县| 梁河县| 木兰县| 资兴市| 浦北县| 安西县| 南开区| 普兰县| 新宁县| 上思县| 天水市| 荃湾区| 南平市| 白朗县| 彭水| 嘉峪关市| 白城市|