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
| #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt5 import (QtWidgets, QtCore)
#############################################################################
class Fenetre(QtWidgets.QWidget):
#========================================================================
def __init__(self, parent=None):
super().__init__(parent)
self.resize(300, 200)
self.setWindowTitle("Exemple de fenêtre")
self.bouton1 = QtWidgets.QPushButton("bouton 1", self)
self.bouton1.clicked.connect(self.clictest1)
self.bouton2 = QtWidgets.QPushButton("bouton 2", self)
self.bouton2.clicked.connect(self.clictest2)
posit = QtWidgets.QGridLayout()
posit.addWidget(self.bouton1, 0, 0)
posit.addWidget(self.bouton2, 1, 0)
self.setLayout(posit)
#========================================================================
def clictest1(self):
QtWidgets.QMessageBox.information(self,
"Information",
"Click bouton 1!")
#========================================================================
def clictest2(self):
QtWidgets.QMessageBox.information(self,
"Information",
"Click bouton 2!")
#############################################################################
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
fen = Fenetre()
fen.show()
sys.exit(app.exec_()) |
Partager