GetEventObject() / wx.Menuitem woes.

Samwyse <samwyse@gmail.com> Wrote:
Mike Driscoll)

Tim Roberts Wrote:
FT wrote:

    The menu text is the HotKey text and there is a built in function for
that as you will see when you go down to the OnMenu handler Call.

Dude, you really need to take a few minutes to establish a source code
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Tim, my name is Bruce,
But the mistake was made when converting to DIgest mode and the Subject I
copied from had shortened the actual title.

    I was trying to give an example of how to get the menu text item out

for

the person and his containers using the object method GetEventObject
I do not even know what you were trying to say...

I suspect he was talking about the block of comments that look like this:
#LAST MODIFIED SUNDAY, AUGUST 10 2008
#ADDED MENUITEMS LIST FOR ID SEARCH.
#MODIFIED WEDNESDAY, JULY 23 2008
#CREATED TUPLES FOR ALL MENU ITEMS!
#ADDED MENUBAR_SETTINGS TO FIND SETTINGS PARMS.

A good source code control keeps track of all of that for you without
cluttering your source code with comments. Plus, it lets you easily
compare any previous version of the file to any other version. I tend
to use RCS myself, as it's shipped with most Unixes, but it *is* more
for lone developers.

Thanks, I was not sure which part of my code he was addressing and the use
of other tracking methods I may try in the future. But, since I rely on a
screen reader and any method of tracking that uses graphics of any kind
makes it more difficult, and sometimes actually locks up my computer. My
tracking is number each file like editor1...editor9.py and will have to use
it until I find a screen reader friendly tracker.
    Anyway, I should have not placed all the code in there, but that list of
comments showed my changes based on other suggestions on this list,
including making Tubles for the menu items and a class for the menu pass
through parms/handlers.
Now:
    I tried the other suggestions except the lambda function and will try
that next for my program. For having a way to get to data of any form is
neat to have.
    I actually took out my menuItems list and used the GetMenuBar() method,
the only change needed in that was to add in my fetch of the text was to
place a replace statement inside of any handler to strip off the hotkey
command (&) For I needed the list to strip it using a built
method, so why not creat my own? So I did.
Change:
#LAST MODIFIED TUESDAY, AUGUST 12 2008
#ADDED THE self.GetMenuBar().FindItemById( IN ONMENU
#ADDED THE REPLACE METHOD SINCE IT HAS NO STRIP FUNCTION FOR HOT KEY CODE!
#Events:
                wx.EVT_MENU(self, o.id4item, o.handler4item)
                wx.EVT_MENU_HIGHLIGHT(self, o.id4item, self.OnMenu)
#Handler:
    def OnMenu(self, event):
        "SAY MENU ITEM NAME HIGHLIGHTED!"
        event.Skip()
        item = self.GetMenuBar().FindItemById( event.GetId())
        text = item.GetText()
        text = text.replace( "&", "")
        TTS2[ self.ttsp].Speak( " Menu item selected: %s " % text)

Note:
    Any other handlers that use this text as a key or value it now can be
used after stripping off the hotkey codes...
Next I can try the lambda function for passing in the dict.. when I need
such an event.

        Bruce

···

Subject: [wxpython-users] Re: GetEventObject() / wx.Menuitem woes.