复制代码 代码如下:
#!/usr/bin/python
#-*-coding:utf-8-*-
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.Qt import *
class ChangeSkinWidget(QWidget):
def __init__(self,parent = None):
super(ChangeSkinWidget,self).__init__(parent)
self.setFixedSize(140, 160)
self.mouse_press = False
self.mouse_enter = False
#self.pixmap = QPixmap()
self.pixmap_name = ""
self.skin_label = QLabel() #显示皮肤
self.skin_name_label = QLabel() #显示皮肤名称
self.download_count_label = QLabel() #显示下载次数
self.use_skin_button = QPushButton() #使用此皮肤按钮
self.setCursor(Qt.PointingHandCursor)
self.use_skin_button.setStyleSheet("border-radius:3px border:1px solid rgb(180, 190, 200) color:rgb(70, 70, 70) background:transparent")
self.skin_label.setScaledContents(True)
self.skin_label.setFixedSize(100, 65)
self.use_skin_button.setFixedSize(85, 25)
self.background_layout = QVBoxLayout()
self.background_layout.addWidget(self.skin_label, 0, Qt.AlignCenter)
self.background_layout.addWidget(self.skin_name_label, 0, Qt.AlignCenter)
self.background_layout.addWidget(self.download_count_label, 0, Qt.AlignCenter)
self.background_layout.addWidget(self.use_skin_button, 0, Qt.AlignCenter)
self.background_layout.setSpacing(5)
self.background_layout.setContentsMargins(0, 10, 0, 10)
self.setLayout(self.background_layout)
self.skin.connect(self.changeSkin)
self.translateLanguage()
skin = pyqtSignal()
def changeSkin(self, pixmap_name, skin_name, download_count):
self.background_name = pixmap_name + "_big.png"
self.pixmap_name = self.background_name
#更改皮肤背景
#self.pixmap()
self.skin_label.setPixmap(QPixmap(self.background_name))
#更改皮肤名称
self.skin_name_label.setText(skin_name)
#更改下载次数
self.download_count_label.setText(u"download count:" + download_count)
def translateLanguage(self):
self.use_skin_button.setText(u"use skin")
def paintEvent(self,event):
if(self.mouse_enter):
#绘制边框
painter = QPainter(self)
pen = QPen(QColor(210, 225, 230))
painter.setPen(pen)
painter.drawRoundRect(0,0,self.width()-1, self.height()-1, 5, 5)
def mousePressEvent(self,event):
#只能是鼠标左键移动和改变大小
if(event.button() == Qt.LeftButton):
self.mouse_press = True
self.emit(SIGNAL("skin"),self.pixmap_name)
def mouseReleaseEvent(self,event):
self.mouse_press = False
def enterEvent(self,event):
self.mouse_enter = True
self.update()
def leaveEvent(self,event):
self.mouse_enter = False
self.update()
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
skin = ChangeSkinWidget()
skin.show()
sys.exit(app.exec_())
360,皮肤,按钮控件
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]