1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-16 11:45:04 +02:00

Translate: Part 2

This commit is contained in:
DevHugo
2018-09-05 10:34:20 +02:00
committed by GitHub
parent 93499a0946
commit b955d9386b

View File

@@ -44,8 +44,8 @@ if __name__ == '__main__':
``` ```
In order to get some of the more advanced features in **pyqt** we need to start looking at building additional elements. Pour obtenir certaines des fonctionnalités les plus avancées de **pyqt** nous devons commencer par chercher à construire des éléments supplémentaires.
Here we show how to introduce a dialog popup box, useful for asking the user to confirm a decision or to provide information. Ici nous voyons comment introduire une boîte de dialogue popup, utile pour demander une confirmation à un utilisateur ou fournir des informations.
```Python ```Python
import sys import sys
@@ -56,27 +56,27 @@ from PyQt4.QtCore import *
def window(): def window():
app = QApplication(sys.argv) app = QApplication(sys.argv)
w = QWidget() w = QWidget()
# Create a button and attach to widget w # Creation d'un bouton attaché au widget w
b = QPushButton(w) b = QPushButton(w)
b.setText("Press me") b.setText("Press me")
b.move(50, 50) b.move(50, 50)
# Tell b to call this function when clicked # Dire à b d'appeler cette fonction quand il est cliqué
# notice the lack of "()" on the function call # remarquez l'absence de "()" sur l'appel de la fonction
b.clicked.connect(showdialog) b.clicked.connect(showdialog)
w.setWindowTitle("PyQt Dialog") w.setWindowTitle("PyQt Dialog")
w.show() w.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
# This function should create a dialog window with a button # Cette fonction devrait créer une fenêtre de dialogue avec un bouton
# that waits to be clicked and then exits the program # qui attend d'être cliqué puis quitte le programme
def showdialog(): def showdialog():
d = QDialog() d = QDialog()
b1 = QPushButton("ok", d) b1 = QPushButton("ok", d)
b1.move(50, 50) b1.move(50, 50)
d.setWindowTitle("Dialog") d.setWindowTitle("Dialog")
# This modality tells the popup to block the parent whilst it's active # Cette "Modality" dit au popup de bloquer le parent pendant qu'il est actif
d.setWindowModality(Qt.ApplicationModal) d.setWindowModality(Qt.ApplicationModal)
# On click I'd like the entire process to end # En cliquant je voudrais que tout le processus se termine
b1.clicked.connect(sys.exit) b1.clicked.connect(sys.exit)
d.exec_() d.exec_()