Salut,
Juste pour confirmation, il n'y a pas de bouton push-pull dans les widgets Tkinter? C'est à dire un bouton qui reste enfoncé après un click et qui nécessite un second click pour remonter.
A+
Pfeuh
Version imprimable
Salut,
Juste pour confirmation, il n'y a pas de bouton push-pull dans les widgets Tkinter? C'est à dire un bouton qui reste enfoncé après un click et qui nécessite un second click pour remonter.
A+
Pfeuh
Finalement, j'ai réussi à me débrouiller avec un Checkbutton, je me demande même si ce n'est pas prévu pour ça... :?
A+Code:
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 from Tkinter import * class PPBUTTON(Checkbutton): num = 0 def __init__(self, container=None , **kwds): if not "width" in kwds.keys(): kwds["width"] = 10 if not "command" in kwds.keys(): kwds["command"] = self.switchState if not "indicatoron" in kwds.keys(): kwds["indicatoron"] = 0 if not "variable" in kwds.keys(): self.bool_var = IntVar() kwds["variable"] = self.bool_var else: self.bool_var = kwds["variable"] Checkbutton.__init__(self,container, **kwds) self.note() def switchState(self): self.note() def note(self): print "%s:%u"%(self.cget("text"),self.bool_var.get()) root = Tk() for label in ["Readable", "Writable","Executable"]: PPBUTTON(root, text=label).grid() root.mainloop()
Pfeuh