成都网站建设设计

将想法与焦点和您一起共享

PythonPyQt4实现QQ抽屉效果-创新互联

本文实例为大家分享了Python PyQt4实现QQ抽屉效果展示的具体代码,供大家参考,具体内容如下

创新互联公司长期为上千多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为加查企业提供专业的成都网站设计、成都网站建设,加查网站改版等技术服务。拥有十多年丰富建站经验和众多成功案例,为您定制开发。

先看截图效果:

主要是使用了QT的QTabWidget、QToolBox多页窗口部件

# -*- coding: utf-8 -*- 
from PyQt4.QtGui import * 
from PyQt4.QtCore import * 
import sys 
 
QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) 
 
class MyQQ(QTabWidget): 
  def __init__(self,parent=None): 
    super(MyQQ,self).__init__(parent) 
     
    toolButton1=QToolButton() 
    toolButton1.setText(self.tr("gavin")) 
    toolButton1.setIcon(QIcon("d:/image/1.png")) 
    toolButton1.setIconSize(QSize(60,60)) 
    toolButton1.setAutoRaise(True) 
    toolButton1.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) 
 
 
    toolButton2=QToolButton() 
    toolButton2.setText(self.tr("问题的方法")) 
    toolButton2.setIcon(QIcon("d:/image/2.png")) 
    toolButton2.setIconSize(QSize(60,60)) 
    toolButton2.setAutoRaise(True) 
    toolButton2.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)     
 
    toolButton3=QToolButton() 
    toolButton3.setText(self.tr("为什么")) 
    toolButton3.setIcon(QIcon("d:/image/3.png")) 
    toolButton3.setIconSize(QSize(60,60)) 
    toolButton3.setAutoRaise(True) 
    toolButton3.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) 
 
    groupbox1=QGroupBox() 
    vlayout1=QVBoxLayout(groupbox1) 
    vlayout1.setMargin(10) 
    vlayout1.setAlignment(Qt.AlignCenter) 
    vlayout1.addWidget(toolButton1) 
    vlayout1.addWidget(toolButton2) 
    vlayout1.addStretch() 
 
    groupbox2=QGroupBox() 
    vlayout2=QVBoxLayout(groupbox2) 
    vlayout2.setMargin(10) 
    vlayout2.setAlignment(Qt.AlignCenter) 
    vlayout2.addWidget(toolButton3) 
    vlayout2.addStretch() 
 
    groupbox3=QGroupBox() 
 
    toolbox1 = QToolBox() 
    toolbox1.addItem(groupbox1,self.tr("我的好友")) 
    toolbox1.addItem(groupbox2,self.tr("同事")) 
    toolbox1.addItem(groupbox3,self.tr("黑名单")) 
         
    toolbox2 = QToolBox() 
     
    self.addTab(toolbox1, "联系人") 
    self.addTab(toolbox2, "群/讨论组") 
     
app=QApplication(sys.argv) 
myqq=MyQQ() 
myqq.setWindowTitle("QQ2012") 
myqq.show() 
app.exec_() 

分享名称:PythonPyQt4实现QQ抽屉效果-创新互联
浏览地址:http://chengdu.cdxwcx.cn/article/cshhcd.html