Hi,
I’m attempting to bind an event to the Open option in my menu. Despite various attempts, the following code never runs:
item = wxglade_tmp_menu.Append(wx.ID_ANY, "&Open\tCtrl+O", "")
self.Bind(wx.EVT_MENU, self.OnFileOpen, id=item.GetId())
A bit long, but here is the event handler:
def OnFileOpen(self, event):
if self.contentNotSaved:
if wx.MessageBox("Current content has not been saved! Proceed?", "Please confirm",
wx.ICON_QUESTION | wx.YES_NO, self) == wx.NO:
return
with wx.FileDialog(self.Myframe, "Open MXP file", wildcard="MXP files (*.MXP)|*.mxp",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fileDialog:
if fileDialog.ShowModal() == wx.ID_CANCEL:
return
pathname = fileDialog.GetPath()
try:
with open(pathname, 'r') as file:
self.LoadTree(file)
except IOError:
wx.LogError("Cannot open file '%s'." % file)
I’d be extremely grateful for any suggestions as to how I can find out what’s going on with this code,
David.