Python PyQt4实现QQ抽屉效果
程序员文章站
2023-10-18 20:35:45
本文实例为大家分享了python pyqt4实现qq抽屉效果展示的具体代码,供大家参考,具体内容如下
先看截图效果:
主要是使用了qt的qtabwidget、qto...
本文实例为大家分享了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目录下,然后在解释中调用模块,但是不能显示,后来就改用了绝对路径
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。