コード例 #1
0
ファイル: editorContainer.py プロジェクト: tinyshrimp/graver
 def __onDocumentOpened(self, sender, evt):
     document = evt
     if document is None:
         return
     
     docName =  document.getName()
     if docName is None:
         return
     
     editor = self.__getFileEditor(docName)
     if editor is None:
         raise Exception('Cannot get the editor for file.\n Filename: %s' % docName)
     
     document.setEditor(editor)
     
     pageCaption = ''
     if '' == docName:
         pageCaption = 'Unsaved Document'
     else:
         pageCaption = docName
         
     if editor.openFile(document.getFullPath()):
         if self._auiNotebook.AddPage(document.getEditor(), pageCaption, True):
             self.__getOpenedDocuments()[document.getEditor()] = document
             Application.getDocumentManager().selectDocument(document.getFullPath())
     else:
         editor.close()
         dlg = wx.MessageDialog(None, 'Cannot open file: %s' % document.getFullPath(),
                                'Error', wx.OK | wx.ICON_ERROR)
         dlg.ShowModal()
         dlg.Destroy()
         document.close()
コード例 #2
0
ファイル: actions.py プロジェクト: tinyshrimp/graver
 def execute(self, evt):
     wildcard = "All files (*.*)|*"
     dlg = wx.FileDialog(
         None,
         message="Open File",
         defaultDir="",
         defaultFile="",
         wildcard=wildcard,
         style=wx.OPEN | wx.CHANGE_DIR | wx.MULTIPLE,
     )
     if dlg.ShowModal() == wx.ID_OK:
         files = dlg.GetPaths()
         for file in files:
             Application.getDocumentManager().openDocument(file)
コード例 #3
0
ファイル: actions.py プロジェクト: tinyshrimp/graver
 def execute(self, evt):
     document = Application.getDocumentManager().getCurrentDocument()
     if document is None:
         return
     
     editor = document.getEditor()
     if editor is None:
         return
     
     editor.cut()
コード例 #4
0
ファイル: actions.py プロジェクト: tinyshrimp/graver
    def execute(self, evt):
        while 0 < len(Application.getDocumentManager().getDocuments()):
            document = Application.getDocumentManager().getCurrentDocument()
            if document is None:
                continue

            if document.isContentChanged():
                if (
                    wx.MessageDialog(
                        None,
                        "Do you want to save file: %s?" % document.getName(),
                        "Warning",
                        wx.YES | wx.NO | wx.ICON_WARNING,
                    ).ShowModal()
                    == wx.ID_YES
                ):
                    saveAction = Application.getActionManager().getAction("DocumentActions.Save")
                    if saveAction is not None:
                        saveAction.execute(None)
            document.close()
コード例 #5
0
ファイル: actions.py プロジェクト: tinyshrimp/graver
    def execute(self, evt):
        document = Application.getDocumentManager().getCurrentDocument()
        if document is None:
            return

        wildcard = "All files (*.*)|*"
        dlg = wx.FileDialog(
            None,
            message="Save file as ...",
            defaultDir=os.getcwd(),
            defaultFile="",
            wildcard=wildcard,
            style=wx.SAVE | wx.CHANGE_DIR,
        )
        if dlg.ShowModal() == wx.ID_OK:
            document.rename(dlg.GetPath())
            document.save()
コード例 #6
0
ファイル: actions.py プロジェクト: tinyshrimp/graver
 def execute(self, evt):
     Application.getDocumentManager().openDocument("")
コード例 #7
0
ファイル: editorContainer.py プロジェクト: tinyshrimp/graver
 def __onPageChanged(self, evt):
     index = self._auiNotebook.GetSelection()
     editor = self._auiNotebook.GetPage(index)
     if self.__getOpenedDocuments().has_key(editor):
         document = self.__getOpenedDocuments()[editor]
         Application.getDocumentManager().selectDocument(document.getFullPath())
コード例 #8
0
ファイル: editorContainer.py プロジェクト: tinyshrimp/graver
 def __init__(self, parent):
     Pane.__init__(self, parent, 'EditorContainer', '', pos=wx.CENTER, showCaption=False)
     
     self._openedDocuments = None
     
     Application.getDocumentManager().getDocumentOpenedEventHandler().add(self.__onDocumentOpened)
     Application.getDocumentManager().getDocumentClosedEventHandler().add(self.__onDocumentClosed)
     Application.getDocumentManager().getDocumentSavedEventHandler().add(self.__onDocumentSaved)
     Application.getDocumentManager().getDocumentChangedEventHandler().add(self.__onDocumentChanged)
     Application.getDocumentManager().getDocumentRenamedEventHandler().add(self.__onDocumentRenamed)
     Application.getDocumentManager().getSelectedDocumentChangedEventHandler().add(self.__selectDocument)
     
     self.__initializeComponent()