Bonjour à tous,


Je cherche à afficher une image provenant du web dans un QLabel , hors malgré mes recherches sur le web je cale ...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
import sys
 
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtGui import QPixmap, QImage
from PyQt5.QtCore import QUrl
 
class Example(QWidget):
 
 
    def __init__(self):
        super().__init__()
 
        chemin = "XXXXXXXXXXXXXXXXXXXXX"
        image = 'iorek.jpg'
        ima = "http://" + chemin + "/IMG/N0000.jpg"
 
        self.im = QPixmap(image)
        self.label = QLabel()
        self.label.setPixmap(self.im)
 
        self.grid = QGridLayout()
        self.grid.addWidget(self.label,1,1)
        self.setLayout(self.grid)
 
        self.setGeometry(50,50,320,200)
        self.setWindowTitle("PyQT show image")
        self.show()
 
 
if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
Ce bout de code me sert de test, j'ai essayé avec QUrl , mais....
Je précise que je suis débutant et que c'est surtout pour apprendre en m'amusant, merci pour votre aide