[Python] Checkbutton
Résolu
Utilisateur anonyme
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour
J'ai créé des checkbuttons et je voudrais savoir quand ils sont cochés ou non.
J'ai déjà une partie de code qui fait ça et ça marche très bien. J'ai voulu refaire la même chose et là ça ne marche plus.
Voilà mon code :
Le terme self.param_and_val.keys() est une liste de paramètres de la forme : ['ahc', 'iqfh', 'vpts', 'ze', 'mbe', 'is', 'cbepar', 'tbvl', 'zci', 'mbc', 'fbc', 'vptci', 'vgb', 'rci0', 'zetact', 'rth', 'zetaci', 'cjs0', 'vdcx', 'zcx', 'f1vg', 'zs', 'zetarbi', 'cje0', 'zetare', 'rcx', 'gte', 'cjcx0', 'vge', 'rbi0', 'tr', 'vpt', 'vgc', 'vef', 're', 'zetabet', 'cbcpar', 'mcf', 'zetarbx', 'cjci0', 'vces', 'msc', 'ibes', 'alt0', 'aje', 'tnom', 'npn', 'dt0h', 'tfh', 'iscs', 'vr0c', 'zetarcx', 'pnp', 'thcs', 'kt0', 'ires', 'ibcs', 'vptcx', 'tef0', 'af', 'aleav', 'alces', 'mcr', 'kf', 'vlim', 'vr0e', 'vds', 'f2vg', 'fgeo', 'alvs', 'level', 'cth', 'kavl', 'rbx', 't0', 'iqr', 'vde', 'mre', 'iqf', 'eavl', 'alkav', 'vdci', 'vgs']
Et voici la fonction appelée quand on coche un bouton :
Quand j'affiche self.param_checked, ils sont tous à 0, comme si aucun n'avait été coché. Si quelqu'un voit où est mon erreur...
Merci
J'ai créé des checkbuttons et je voudrais savoir quand ils sont cochés ou non.
J'ai déjà une partie de code qui fait ça et ça marche très bien. J'ai voulu refaire la même chose et là ça ne marche plus.
Voilà mon code :
r = 0 c = 0 for m in self.param_and_val.keys() : if (r > 30) : r = 0 c += 3 self.check_p[m] = [] value = Tkinter.IntVar() check = Tkinter.Checkbutton(group_model_param.interior(), text = m, variable = value, command = self.Checkbutton_param) self.check_p[m]= value val_param = Tkinter.Entry(group_model_param.interior()) val_param.insert(Tkinter.INSERT, self.param_and_val[m]) check.grid(column = c, row = r, sticky = 'NW') val_param.grid(column = c + 2, row = r, sticky = 'NSEW') r += 1
Le terme self.param_and_val.keys() est une liste de paramètres de la forme : ['ahc', 'iqfh', 'vpts', 'ze', 'mbe', 'is', 'cbepar', 'tbvl', 'zci', 'mbc', 'fbc', 'vptci', 'vgb', 'rci0', 'zetact', 'rth', 'zetaci', 'cjs0', 'vdcx', 'zcx', 'f1vg', 'zs', 'zetarbi', 'cje0', 'zetare', 'rcx', 'gte', 'cjcx0', 'vge', 'rbi0', 'tr', 'vpt', 'vgc', 'vef', 're', 'zetabet', 'cbcpar', 'mcf', 'zetarbx', 'cjci0', 'vces', 'msc', 'ibes', 'alt0', 'aje', 'tnom', 'npn', 'dt0h', 'tfh', 'iscs', 'vr0c', 'zetarcx', 'pnp', 'thcs', 'kt0', 'ires', 'ibcs', 'vptcx', 'tef0', 'af', 'aleav', 'alces', 'mcr', 'kf', 'vlim', 'vr0e', 'vds', 'f2vg', 'fgeo', 'alvs', 'level', 'cth', 'kavl', 'rbx', 't0', 'iqr', 'vde', 'mre', 'iqf', 'eavl', 'alkav', 'vdci', 'vgs']
Et voici la fonction appelée quand on coche un bouton :
def Checkbutton_param(self) : for (param, checkbutton) in self.check_p.items() : self.param_checked[param] = checkbutton.get()
Quand j'affiche self.param_checked, ils sont tous à 0, comme si aucun n'avait été coché. Si quelqu'un voit où est mon erreur...
Merci
A voir également:
- [Python] Checkbutton
- Citizen code python avis - Accueil - Outils
- Python est introuvable. exúcutez sans argument pour procúder ó l ✓ - Forum Python
- Mot secret python pix ✓ - Forum Python
- Python par la pratique : 101 exercices corrigés pdf - Forum Python
- Exercice python - Forum Python