Maddening accelerator problem: menu items disable

hi there,

i've been writing an application, and of course want to implement all the snazziest features (menu accelerators, file dialogs, anti-lock brakes, u.v. underbody lighting, and a five-year drive train warranty ;).

my application contains several menus. one of them is a menu titled "Edit". Edit contains six menu items (see below), the first three of which have the accelerators "CTRL+x", CTRL+c", and "CTRL+v". these are bound to functions that cut, paste and copy. when i launch the application they appear lovely, and work as intended.

however, when i open a file (using wx.FileDialog attached at the end of this mail) these first three menu items are ghosted/disabled, and so are the actual key bindings to their respective functions.

interesting facts:

1. i have NOT inadvertently duplicated wxIDs, accelerators, or menu names.

2. i am not using menu mnemonics (i.e. the menu item texts are not things
    like "&Cut\tCTRL+x".

3. when i change the accelerators to (for example) "CTRL+k", "CTRL+l" and
   "CTRL+m" my problem vanishes.

4. i have NOT inadvertently disabled these items using, for example,
    self.MenuBar.Enable(ID_CutCM)

some of my code:

   # this appears in a function defined in my application-level wx.frame
   # Edit menu
   editmenu = wx.Menu()
   editmenu.Append(ID_CUTCM, "Cut\tCTRL+x"," Cut item")
   editmenu.Append(ID_COPYCM, "Copy\tCTRL+c"," Copy item")
   editmenu.Append(ID_PASTECM, "Paste\tCTRL+v"," Paste item")
   editmenu.Append(ID_DELCM, "Delete\tCTRL+SHIFT+d"," Delete item")
   editmenu.Append(ID_DUPECM, "Duplicate\tCTRL+d"," Duplicate item")
   editmenu.Append(ID_EDITCM, "Edit\tCTRL+e"," Edit item")

  # some other menus are also defined

   MenuBar = wx.MenuBar()
   MenuBar.Append(filemenu,"&File")
   MenuBar.Append(editmenu,"&Edit")
   MenuBar.Append(analmenu,"&Analysis")
   MenuBar.Append(helpmenu,"&Help")
   self.SetMenuBar(MenuBar) # Adding the MenuBar to the Frame content.

been driving myself out of my gourd.

using wxpython 2.8.3, python 2.4.3 mac universal

help help help!

thanks
alexis

the edit menu items disable after doing this:

   def OpenLibraryDialog(self, Event=None):

     if GLOBAL.RecentDirectory == "":
       WorkingDirectory = os.getcwd()
     else:
       WorkingDirectory = GLOBAL.RecentDirectory

···

##########
     # The OLdlg interface
     OLdlg = wx.FileDialog(
       self,
       message = "Choose a file",
       defaultDir = WorkingDirectory,
       defaultFile = "",
       wildcard = "CM Library file (*.cml)|*.cml",
       style=wx.OPEN | wx.CHANGE_DIR
       )

     if OLdlg.ShowModal() == wx.ID_OK:
       OLfile = OLdlg.GetPaths()
       FileName = self.ReturnFile(OLfile[0])

Are you destroying the FileDialog? Just a guess, maybe it is using the shortcuts and hopefully "returns" them to your app when it is being destroyed.

thank you for the tip werner. as it so happens, i am destroying the dialog. :\

thanks! you rock, that did it.

···

On Fri, 6 Apr 2007, Mike Rooney wrote:

lexy-lou@doyenne.com wrote:

hi there,

i am interested in constraining the tab behavior in an AuiNotebook (for example, disabling the tiny close button on the tab). but i can't find styles for the notebook object itself or the TabCtrl.

The builtin 'dir' is your great friend:

import wx.aui
for x in dir(wx.aui):
  if x.startswith('AUI_NB'):
      print x

Hopefully that is what you need. This can be applied to anything in wxPython. If you don't know what the thing you are looking for starts with, do a dir on the object itself first, in this case dir(wx.aui).

- Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org