<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def open_macros(self, filepath):
 """Loads macros from file and marks grid as changed Parameters filepath: String \tPath to macro file """


        try:
            wx.BeginBusyCursor()
            self.main_window.grid.Disable()

            with open(filepath) as macro_infile:
                # Enter safe mode
                self.main_window.grid.actions.enter_safe_mode()
                post_command_event(self.main_window, self.SafeModeEntryMsg)

                # Mark content as changed
                post_command_event(self.main_window, self.ContentChangedMsg)

                macrocode = macro_infile.read()

                self.grid.code_array.macros += "\n" + macrocode.strip("\n")
                self.grid.main_window.macro_panel.codetext_ctrl.SetText(
                    self.grid.code_array.macros)

        except IOError:
            msg = _("Error opening file {filepath}.").format(filepath=filepath)
            post_command_event(self.main_window, self.StatusBarMsg, text=msg)

            return False

        finally:
            self.main_window.grid.Enable()
            wx.EndBusyCursor()

        # Mark content as changed
        try:
            post_command_event(self.main_window, self.ContentChangedMsg)

        except TypeError:
            # The main window does not exist any more
            pass