コード例 #1
0
    def New(self):
        """Add a new file into the current page."""

        # Ask for the new file name
        filename = filedialogs.SaveAsAnnotationFile()
        if filename is None:
            return

        # Add the newly created file in the file manager and that's it!
        evt = FileWanderEvent(filename=filename, status=False)
        evt.SetEventObject(self)
        wx.PostEvent(self.GetTopLevelParent(), evt)
コード例 #2
0
    def SaveAs(self):
        """Save as... the selected file."""

        if self._selection is None:
            ShowInformation(self,
                            self._prefsIO, "No file selected!\n"
                            "Click on a tier to select a file...",
                            style=wx.ICON_INFORMATION)
            return

        found = -1
        for i in range(self._filetrs.GetSize()):
            p = self._filetrs.GetObject(i)
            if p == self._selection:
                found = i
                break

        if found > -1:
            f = self._filetrs.GetFilename(i)
            p = self._filetrs.GetObject(i)

            # Ask for the new file name
            filename = filedialogs.SaveAsAnnotationFile()

            if filename is None:
                return

            # do not erase the file if it is already existing!
            if os.path.exists(filename) and f != filename:
                ShowInformation(
                    self,
                    self._prefsIO,
                    "File not saved: this file name is already existing!",
                    style=wx.ICON_INFORMATION)
            elif f == filename:
                p.Save()
            else:
                p.SaveAs(filename)
                # Add the newly created file in the file manager
                evt = FileWanderEvent(filename=filename, status=True)
                evt.SetEventObject(self)
                wx.PostEvent(self.GetTopLevelParent(), evt)

                evt = FileWanderEvent(filename=filename, status=True)
                evt.SetEventObject(self)
                wx.PostEvent(self.GetParent().GetParent().GetParent(), evt)