3eme SI Les interfaces graphiques 2/2 www.mathinfo.
tn
Application 1 (Radio Button) :
Réalisez un programme qui comporte une interface graphique permettant de donner en entrée le signe
du descriminant d'une équation de second degré
pour afficher le nombre de solutions possibles.
Signe descriminant Nombre de solution
Strictement positif 2 solutions
Null Solution double
Strictement negatif 0 solution
Application 2 (ComboBox) :
Modifier l’interface de l’application 1 comme ci-dessous :
3eme SI Les interfaces graphiques 2/2 www.mathinfo.tn
Application 3
Vous allez valider les champs a remplir
le nom et le prénom non vide, l'age doit être choisi depuis
la liste(18<=age<=22), le genre doit être coché
En cliquant sur Afficher :
le formulaire disparait et apparait le texte :
Correction
Interface Qt Designer
S1
S2
S3
Verif
Res
3eme SI Les interfaces graphiques 2/2 www.mathinfo.tn
Objet Type
S1
S2
S3
Verif
Res
Script Python :
from PyQt5 import QtWidgets,uic
def tester():
if f.S1.isChecked() :
msg='2 solutions'
if f.S2.isChecked() :
msg='Solution double'
if f.S3.isChecked() :
msg='0 solution'
return msg
def verifier() :
msg=tester()
f.Res.setText(msg)
app=QtWidgets.QApplication([])
f=uic.loadUi("degres.ui")
f.show()
f.Verif.clicked.connect(verifier)
app.exec()
Application 2
Interface Qt Designer
com
3eme SI Les interfaces graphiques 2/2 www.mathinfo.tn
Objet type
com
Cliquer 2 fois sur l’objet ‘com’ puis ajouter les données suivant :
Script Python
from PyQt5 import QtWidgets,uic
def tester():
if f.com.currentText()=="Strictement positif" :
msg="2 solutions"
if f.com.currentText()=="Null" :
msg="Solution double"
if f.com.currentText()=="Strictement negatif" :
msg="0 solution"
return msg
def verifier() :
msg=tester()
f.Res.setText(msg)
app=QtWidgets.QApplication([])
f=uic.loadUi("degres.ui")
f.show()
f.Verif.clicked.connect(verifier)
app.exec()
3eme SI Les interfaces graphiques 2/2 www.mathinfo.tn
Application 3
Qt Designer
Python
from PyQt5 import QtWidgets, uic
def tester():
genre = ""
age = ""
if f.com.currentText() == "18":
age = " 18 ans "
if f.com.currentText() == "19":
age = " 19 ans "
if f.com.currentText() == "20":
age = " 20 ans "
if f.com.currentText() == "21":
age = " 21 ans "
if f.com.currentText() == "22":
age = " 22 ans "
if f.homme.isChecked():
genre = " homme"
if f.femme.isChecked():
genre = " femme"
msg = f.nom.text() + " " + f.prenom.text() + age + genre
return msg
def verifier():
msg = tester()
QtWidgets.QMessageBox.information(f, "Confirmation", msg) # f.res.setText(msg)
app = QtWidgets.QApplication([])
f = uic.loadUi("application.ui")
f.show()
f.afficher.clicked.connect(verifier)
app.exec()