wxpython - python: Right Click on list menu not showing item selected -


In my ongoing effort to learn more about Python, I am trying to add a right click event to my MP3 Manager program. What currently works is that it shows the menu and all the options which is not working, the selected function is not being executed from the menu because I think it should be. This code is taken from 'how' on most other sites.

Click here menu option is OK

  menu_title = ["Remove selection from list", for title in the menu by title: menu_title_by_id [wxNewId ()] = Title   

"Delete selection from system", "Select Selection", "Copy Selection", "Print Selection"] menu_title_by_id = {} The code to be run when the right click event is < / P>

  def WriteClickBab (self, incident): # what was the record self.list_item_clicked = right_click_context = event.GetText () ### 2 launcher wxMenu creates ### menu = wxMenu () For (ID, Title) in menu_title_by_id.items () :) ### 3. Attach the launcher pack with the menu. ### Menu.Pandend (ID, Title) ### 4. On the menu menus are registered with the launcher with EVTENUUUUU. ### EVT_MENU (menu, id, self select menu CB) ### 5. Launcher shows a menu with the call to the popup menu, which applies to the component of the source, passes the gatepoint of the event. ###self.MainPanel.PopupMenu (menu, event.GetPoint ()) menu.Destroy () #em leak Delete to avoid DEF MenuselectionCb (self, event): #Some operations = menu_tit_b_id [event.GetId () ] "Self.list_item_clicked print" display "% (operation) s" '% vars ()   

on target "% (target) s" when I right-click and then in the menu Select one of the options from the output is

  "About Data> Selecting" But on "print selection";   

What I'm getting

  "Select Print" on "."   

How do I obtain data from the items selected as part of my rights click program?

Maybe you replace event.GetString () instead of event GETText ()

should be used

Your code looks old, binding for events should be done in this way:

  Menu.bund (wx.EVT_MENU, auto menu selection, Cb, id = id)   

In addition, if you bind all the IDs on one function, For one time you can tie:

  menu.bund (wx.EVT_MENU, self.MenuSelectionCb)    

Comments