Python PyQt4实现QQ抽屉效果
本文实例为大家分享了Python PyQt4实现QQ抽屉效果展示的具体代码,供大家参考,具体内容如下
先看截图效果:
主要是使用了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_()
问题记录
1.脚本中使用中文处,提示错误:
SyntaxError:<unicode error> 'utf8' codec can't decode byte 0xc4 in position 0: invalid continuation byte
需要将*.py文件保存成utf-8, 我用的是gvim,一直没搞明白vim的编码设置,所以我用了种比较笨的方法,用记事本打开,另存为utf-8格式
2.一开始,我把头像目录image放在\Python32\Lib\site-packages目录下,然后在解释中调用模块,但是不能显示,后来就改用了绝对路径
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16