PySideで何を作る2

#!/usr/bin/python

import sys
from PySide.QtGui import QApplication,QIcon,QWidget,QLabel

class SampleWin(QWidget):
  
  def __init__(self):
    QWidget.__init__(self)
    self.setWindowTitle("Icon2")
    self.setGeometry(300,300,300,300)

  def setIcon(self):
    myIcon1 = QIcon('py.png')
    myLabel1 = QLabel('sample',self)
    pixmap1 = myIcon1.pixmap(50,50,QIcon.Active,QIcon.On)
    myLabel1.setPixmap(pixmap1)

    myIcon2 = QIcon('py.png')
    myLabel2 = QLabel('sample',self)
    pixmap2 = myIcon2.pixmap(50,50,QIcon.Active,QIcon.Off)
    myLabel2.setPixmap(pixmap2)

    myIcon3 = QIcon('py.png')
    myLabel3 = QLabel('sample',self)
    pixmap3 = myIcon3.pixmap(50,50,QIcon.Active,QIcon.On)
    myLabel3.setPixmap(pixmap3)
    myLabel3.move(100,0)

if __name__ == '__main__':

  try:
    myApp = QApplication(sys.argv)
    myWindow = SampleWin()
    myWindow.setIcon()
    myWindow.show()
    myApp.exec_()
    sys.exit(0)

  except NameError:
    print(sys.exc_info()[1])
  except SystemExit:
    print("Closing Window")
  except Exception:
    print(sys.exc_info()[1])

f:id:reonreon3reon:20140317181935p:plain

的な?

QIcon.Active

Display the pixmap when the functionality represented by the icon is available and the user is interacting with the icon, for example, moving the mouse over it or clicking it.

QIcon.Off

Display the pixmap when the widget is in an "off" state

QIcon.On

Display the pixmap when the widget is in an "on" state

pixmap func

The syntax of the pixmap function isPySide.QtGui.QIcon.pixmap(width, height[, mode=Normal[, state=Off]]). The parameters width and height represents the icon size. The modes can be any of the following four modes depending on the action:

広告を非表示にする