Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > pmw menu item's 'command' attribute

Thread Tools

pmw menu item's 'command' attribute

Tina Li
Posts: n/a

I'm new to Python and pmw, and I might be missing something obvious,
but...say I created a cascade menu 'Size' and am adding menu items:

for size in ('tiny', 'small', 'average', 'big', 'huge'):
self.menuBar.addmenuitem('Size', 'command', 'Set size to ' +
command = lambda:'change size ' + size),
label = size)

where cmd is a class executing the command string being passed in. The
labels show up correctly, but when I click on any of the size items, the
command is always

change size huge

So it seems that when the lambda function is assigned to 'command' as a
function reference, the argument string isn't evaluated right away. When, the variable 'size' is then looked up, which stays at 'huge' in the

I don't know if I've understood things correctly. In any case, is there a
way to make it do what it's supposed to do (i.e. the commands correspond to
the their individual size label)?

Thanks in advance!


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
pmw MenuBar: delete all menu items of a menu Tina Li Python 0 09-18-2003 09:57 PM
Pmw BLT problems Sriram Chadalavada Python 1 08-19-2003 04:53 PM
Pmw BLT problems - addendum Sriram Chadalavada Python 0 08-18-2003 08:47 PM
PMW 0.8.5 vs Python 2.3 Robin Becker Python 2 08-10-2003 08:40 AM
Using PMW? ken Python 0 07-14-2003 01:33 AM