Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
qradiobutton_pyqt4 [2010/09/24 18:44] tyrtamos |
qradiobutton_pyqt4 [2010/09/24 20:06] tyrtamos |
||
---|---|---|---|
Ligne 36: | Ligne 36: | ||
def __init__(self, | def __init__(self, | ||
super(Fenetre, | super(Fenetre, | ||
+ | self.setWindowTitle(" | ||
# créer les 3 radioboutons | # créer les 3 radioboutons | ||
- | self.radioButton_1 = QtGui.QRadioButton(self) | + | |
+ | | ||
self.radioButton_1.setText(u" | self.radioButton_1.setText(u" | ||
- | self.radioButton_2 = QtGui.QRadioButton(self) | + | self.radioButton_2 = QtGui.QRadioButton(self.groupBox) |
self.radioButton_2.setText(u" | self.radioButton_2.setText(u" | ||
- | self.radioButton_3 = QtGui.QRadioButton(self) | + | self.radioButton_3 = QtGui.QRadioButton(self.groupBox) |
self.radioButton_3.setText(u" | self.radioButton_3.setText(u" | ||
| | ||
Ligne 55: | Ligne 57: | ||
# création d'une ligne d' | # création d'une ligne d' | ||
self.lineEdit = QtGui.QLineEdit(self) | self.lineEdit = QtGui.QLineEdit(self) | ||
- | | + | |
# positionnement des widgets dans la fenêtre | # positionnement des widgets dans la fenêtre | ||
- | posit = QtGui.QVBoxLayout() | + | posit = QtGui.QGridLayout() |
- | posit.addWidget(self.radioButton_1) | + | posit.addWidget(self.groupBox, |
- | posit.addWidget(self.radioButton_2) | + | posit.addWidget(self.radioButton_1, 0, 0) |
- | posit.addWidget(self.radioButton_3) | + | posit.addWidget(self.radioButton_2, 0, 1) |
- | posit.addWidget(self.lineEdit) | + | posit.addWidget(self.radioButton_3, 0, 2) |
+ | posit.addWidget(self.lineEdit, 1, 0, 1, 3) | ||
self.setLayout(posit) | self.setLayout(posit) | ||
def change(self): | def change(self): | ||
""" | """ | ||
- | if self.radioButton_1.isChecked(): | + | if self.radioButton_1.isChecked(): |
- | | + | elif self.radioButton_2.isChecked(): |
- | elif self.radioButton_2.isChecked(): | + | elif self.radioButton_3.isChecked(): |
- | | + | else: v = 1 |
- | elif self.radioButton_3.isChecked(): | + | |
- | | + | |
- | else: | + | |
- | | + | |
self.lineEdit.setText(unicode(v)) | self.lineEdit.setText(unicode(v)) | ||