1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#!/usr/bin/python
# -*- coding: Utf-8 -*-
#les librairies :
import sys
from PyQt4 import QtGui, QtCore
#ma classe image
class MonImage(QtGui.QWidget):
def _init_(self,imgfile,posX,posY,ll,hh):
QtGui.QWidget.__init__(self)
self.objImage = QtGui.QImage(imgfile)
self.cadre = QtGui.QLabel(self)
self.cadre.setGeometry(posX,posY,ll,hh)
#pour afficher mes images
def AfficheImage(self,val):
self.cadre.setPixmap(QtGui.QPixmap.fromImage(self.objImage))
if val == True:
self.cadre.setVisible(True)
else :
self.cadre.setVisible(False)
# ma fenetre principale
class MainWindow(QtGui.QMainWindow):
def __init__(self,parent=None):
#creation de la fenetre
QtGui.QMainWindow.__init__(self,parent)
image1 = MonImage(self,"images/foto1.jpg",50,50,400,200)
image1.AfficheImage(True)
#creation d'un objet application
app=QtGui.QApplication(sys.argv)
#creation de la fenetre principale
main=MainWindow()
#affichage de la fenetre
main.showFullScreen()
#ferme l'application (équivalent au mainloop)
sys.exit(app.exec_()) |
Partager