A
Adonis
I wish to create a popup menu from a list, when it is created they all show
the same label from the list:
Months = [0, 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',
'December']
def _Menu_Click(self, month):
print month
menu = Menu(fraMain, tearoff=0)
for Month in Months[1:]:
menu.add_command(label=Month, command=lambda : _Menu_Click(Month))
When the menu calls _Menu_Click(...) it always prints 'December'
Now my understanding is the when an object is created and it is replicated,
whichever of the modified replications affects all of the objects, being
that they are just mere references to the original (my wording might be off,
correct me if I am wrong). How do I avoid this for what I am trying to
achieve?
Any help is greatly appreciated.
Adonis
the same label from the list:
Months = [0, 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',
'December']
def _Menu_Click(self, month):
print month
menu = Menu(fraMain, tearoff=0)
for Month in Months[1:]:
menu.add_command(label=Month, command=lambda : _Menu_Click(Month))
When the menu calls _Menu_Click(...) it always prints 'December'
Now my understanding is the when an object is created and it is replicated,
whichever of the modified replications affects all of the objects, being
that they are just mere references to the original (my wording might be off,
correct me if I am wrong). How do I avoid this for what I am trying to
achieve?
Any help is greatly appreciated.
Adonis