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
| #!/usr/bin/python
# -*- coding: utf-8 -*-
# Python 3 PyQt5
import sys
from PyQt5 import QtWidgets, QtCore
# from PyQt4 import QtGui, QtCore
#############################################################################
class Fenetre(QtWidgets.QWidget):
#========================================================================
def __init__(self, parent=None):
super(Fenetre, self).__init__(parent)
self.resize(400,400)
self.panneau = QtWidgets.QFrame(self)
self.panneau.setFixedHeight(200)
self.bouton1 = QtWidgets.QPushButton("bouton 1", self.panneau)
self.bouton1.setGeometry(0,0,100,30)
self.bouton1.clicked.connect(self.clictest1)
self.bouton2 = QtWidgets.QPushButton("bouton 2", self.panneau)
self.bouton2.setGeometry(0,100,100,30)
self.bouton2.clicked.connect(self.clictest2)
self.graphe = QtWidgets.QLabel(self)
self.graphe.setStyleSheet("background-color:yellow") # pour distinguer la partie graphique
posit = QtWidgets.QGridLayout()
posit.addWidget(self.panneau, 0, 0)
posit.addWidget(self.graphe, 1, 0)
self.setLayout(posit)
#========================================================================
@QtCore.pyqtSlot()
def clictest1(self):
print("clic bouton1")
#========================================================================
@QtCore.pyqtSlot()
def clictest2(self):
print("clic bouton2")
#############################################################################
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
fen = Fenetre()
fen.setAttribute(QtCore.Qt.WA_DeleteOnClose)
fen.show()
sys.exit(app.exec_()) |
Partager