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
| #!/usr/bin/python3
# -*- 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("Fenêtre de test")
self.bouton = QtWidgets.QPushButton("bouton", self)
self.bouton.clicked.connect(self.clictest)
posit = QtWidgets.QGridLayout()
posit.addWidget(self.bouton, 0, 0)
self.setLayout(posit)
#========================================================================
def clictest(self, checked=None):
message="Message"
title="Title"
box = QtWidgets.QMessageBox(None)
box.setWindowTitle(title)
box.setText(message)
box.show()
box.raise_()
box.exec_()
#############################################################################
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
fen = Fenetre()
fen.show()
sys.exit(app.exec_()) |
Partager