PySideで何を作る3

#!/usr/bin/python

import sys
from PySide.QtGui import *

class SampleWin(QWidget):
  
  def __init__(self):
    QWidget.__init__(self)
    self.setWindowTitle("Icon2")
    self.setGeometry(300,300,300,300)
    QToolTip.setFont(QFont("Decorative",8,QFont.Bold))
    self.setToolTip("Our Main Window")


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

    myIcon2 = QIcon('py.png')
    myLabel2 = QLabel('sample',self)
    pixmap2 = myIcon2.pixmap(50,50,QIcon.Disabled,QIcon.Off)
    myLabel2.setPixmap(pixmap2)
    myLabel2.move(50,0)
    myLabel2.setToolTip("Disabled Icon")

    myIcon3 = QIcon('py.png')
    myLabel3 = QLabel('sample',self)
    pixmap3 = myIcon3.pixmap(50,50,QIcon.Selected,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])

Tooltipについてでした。はい。カーソルを合わせると説明が出てくると。


f:id:reonreon3reon:20140317183535p:plain

広告を非表示にする