2.6 Adding File Menu Functionality

The next task is to interact with the user to implement the menu functionality. Dialogs are used to get immediate input from the user. Dialogs are application modal, i.e. you can not use any other windows in the current application until the dialogue is closed.
    def OnFileitems0Menu(self, event):
        dlg = wxFileDialog(self, "Choose a file", ".", "", "*.*", wxOPEN)
        try:
            if dlg.ShowModal() == wxID_OK:
                filename = dlg.GetPath()
                # Your code
        finally:
            dlg.Destroy()
        pass
    def OnFileitems0Menu(self, event):
        dlg = wxFileDialog(self, "Choose a file", ".", "", "*.*", wxOPEN)
        try:
            if dlg.ShowModal() == wxID_OK:
                filename = dlg.GetPath()
                self.txtEditor.LoadFile(filename) 
                self.FileName=filename         
        finally:
            dlg.Destroy()
    def OnFileitems2Menu(self, event):
        dlg = wxFileDialog(self, "Save File As", ".", "", "*.*", wxSAVE)
        try:
            if dlg.ShowModal() == wxID_OK:
                filename = dlg.GetPath()
                self.txtEditor.SaveFile(filename) 
                self.FileName=filename         
        finally:
            dlg.Destroy()
    def OnFileitems3Menu(self, event):

        self.FileName = None
        self.txtEditor.Clear()
    def OnFileitems4Menu(self, event):
        self.Close()
    def __init__(self, parent): 
        self._init_ctrls(parent)
        self.FileName=None
    def OnFileitems1Menu(self, event):
        if self.FileName == None:
            return self.OnFileitems2Menu(event)
        else:
            self.txtEditor.SaveFile(self.FileName)
We have now implemented the functionality of the editor. We can edit files, save them. Your editor should look like this: