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

首頁 > 編程 > Python > 正文

python實現360皮膚按鈕控件示例

2020-02-23 05:11:20
字體:
來源:轉載
供稿:網友

代碼如下:
#!/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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 古浪县| 和平区| 保定市| 武隆县| 南开区| 阿鲁科尔沁旗| 广元市| 德州市| 镇宁| 贞丰县| 且末县| 财经| 清水河县| 霞浦县| 永新县| 仁怀市| 靖州| 瑞丽市| 盐山县| 甘肃省| 哈巴河县| 灌云县| 庄河市| 常山县| 拜泉县| 将乐县| 石城县| 辰溪县| 缙云县| 恩施市| 陕西省| 怀仁县| 雷波县| 施甸县| 灵川县| 临武县| 土默特左旗| 泰安市| 巴马| 邢台市| 安远县|