Bonjour
Mon QLabel et QLineEdit ne s'affichent pas
Quelqu'un a-t-il la solution?
merci
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
 
 
class Stock(QMainWindow):
 
    def __init__(self):
        super().__init__() 
        app = QApplication(sys.argv)
        self.initUI() 
        sys.exit(app.exec_())
 
    def initUI(self):    
        # dimension de la fenêtre principale
        self.setGeometry(200, 200, 800, 400)           
 
        # définition de la fenêtre principale
        self.setWindowTitle('Gestion stock pièces maintenance')   
        self.setWindowIcon(QIcon('Corplex.png'))
        self.menuUI()
        self.miseEnPlaceWidgets()
        self.show()       
 
 
    def menuUI(self):# construction des menus
        # action menu : Exit application
        exitAction = QAction(QIcon('close.png'),'&Quitter', self)        
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Quitter application')
        exitAction.triggered.connect(qApp.quit)
        # activation de la barre de status
        self.statusBar()
        # création de la barre de menu
        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&Fichier')
        fileMenu.addAction(exitAction)
        # création de la toolBar        
        toolbar = self.addToolBar('Fichier')        
        toolbar.addAction(exitAction)
 
    def miseEnPlaceWidgets(self):
        self.labelId = QLabel("ID: ")        
        self.editID = QLineEdit()
 
 
        hbox = QHBoxLayout()        
        hbox.addWidget(self.labelId)       
        hbox.addWidget(self.editID)
        self.setLayout(hbox)
 
 
 
 
 
if __name__ == '__main__':   
 
    ex = Stock()