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])