kc1...@ya... wrote:
> Hi list,
>
> I am having trouble making the menuitem check mark to
> behave properly.
>
> In my resource file, both the checkable and checkd
> options for a particular menuitem has been set to 1.
> Upon startup, I want to change the check mark base on
> some other settings and I have code in the
> on_initialize method to do that. However, no matter
> what I do, the check mark still comes out checked.
>
> I am assuming that I am not doing this properly. The
> code I am using in the on_initialize method:
>
> found=False
> for me in self.menuBar.menus:
> if me.getLabel()=="MyMenuLabel":
> for item in me.items:
> if item.getLabel()=="MyMenuItem":
> item.checked = 0 (let say)
> found=True
> break
> if found:
> break
>
> The above code *doesn't* work. The check mark value
> is affected but the display is not.
>
> What's the proper way to do this?
>
> Thanks,
>
> --
> John Henry
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
I had a similar problem. Alex Tweedy answered as follows:
Menu items are not components, so you can't enable / disable them this way.
You do this by
self.menuBar.setEnabled('main_menuAdd_Info', True)
assuming 'menuCommandsAutoRefresh' is the name of the menu item.
You can also do getEnabled, or getChecked/setChecked, etc.
Also, I have found that you cannot (or I cannot) change the checked
state from a script called from the item itself. I can change it outside
of the item script.
|