File open event handler

def OnOpen(self, event):
        """File open event handler"""

        # If changes have taken place save of old grid
        if undo.stack().haschanged():
            save_choice = self.interfaces.get_save_request_from_user()

            if save_choice is None:
                # Cancelled close operation
                return

            elif save_choice:
                # User wants to save content
                post_command_event(self.main_window, self.main_window.SaveMsg)

        # Get filepath from user
        f2w = get_filetypes2wildcards(
            ["pys", "pysu", "xls", "xlsx", "ods", "all"])
        filetypes = f2w.keys()
        wildcards = f2w.values()
        wildcard = "|".join(wildcards)

        message = _("Choose file to open.")
        style = wx.OPEN

        default_filetype = config["default_open_filetype"]
        try:
            default_filterindex = filetypes.index(default_filetype)
        except ValueError:
            # Be graceful if the user has entered an unkown filetype
            default_filterindex = 0

        get_fp_fidx = self.interfaces.get_filepath_findex_from_user
        filepath, filterindex = get_fp_fidx(wildcard, message, style,
                                            filterindex=default_filterindex)

        if filepath is None:
            return

        filetype = filetypes[filterindex]

        # Change the main window filepath state

        self.main_window.filepath = filepath

        # Load file into grid
        post_command_event(self.main_window,
                           self.main_window.GridActionOpenMsg,
                           attr={"filepath": filepath, "filetype": filetype})

        # Set Window title to new filepath

        title_text = filepath.split("/")[-1] + " - pyspread"
        post_command_event(self.main_window,
                           self.main_window.TitleMsg, text=title_text)

        self.main_window.grid.ForceRefresh()

        if is_gtk():
            try:
                wx.Yield()
            except:
                pass

        # Update savepoint and clear the undo stack
        undo.stack().clear()
        undo.stack().savepoint()

        # Update content changed state
        try:
            post_command_event(self.main_window, self.ContentChangedMsg)
        except TypeError:
            # The main window does not exist any more
            pass