dynamic buttons with tkinter
Matthew Dixon Cowles
matt at mondoinfo.com
Sat Jun 29 22:55:22 EDT 2002
More information about the Python-list mailing list
Sat Jun 29 22:55:22 EDT 2002
- Previous message (by thread): Intercepting a process shutdown command under windows?
- Next message (by thread): dynamic buttons with tkinter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, 29 Jun 2002 22:17:17 +0200, Mirko Koenig <koenig at v-i-t.de> wrote: > for file in os.listdir( dir ): > Button( load_dlg_frame, text=file, relief=GROOVE, > command=load).pack() > But how can i find out which button is pressed? Or another > question: How can i pass a event funktion more than 1 parameter (the > event and other things). I can't give any button a new event > function, because it's dynamic, because of the number of files in > the directory. Dear Mirko, For the callback function, give Tkinter an object that has a __call__ method. When you create the object, you can give it the filename and its __call__ method can use the name when the button is clicked. Danny Yoo has a recipe that does just that at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66521 The general concept of giving a function some or all of its arguments in advance of calling it is called "currying". There are other recipes there that do the same thing in a more general way and other information about its uses around the Net. Regards, Matt
- Previous message (by thread): Intercepting a process shutdown command under windows?
- Next message (by thread): dynamic buttons with tkinter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list