problem: Tkinter.Menu() on NT

Fredrik Lundh effbot at telia.com
Mon Mar 6 10:11:27 EST 2000


Sven Drescher <Sven.Drescher at dlr.de> wrote:
> What's wrong with my code? Or is there a possibility to get the index on
an
> other way? I need the index or the name of the menu entry, becaus it's
built
> on the fly with file entries.

use lambda functions:

def test_routine(index):
    print index

for i in range(6):
    submenu.add_command(
        label=str(i),
        command=lambda i=i, cb=test_routine: cb(i)
    )

</F>





More information about the Python-list mailing list