Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
template.py61 linesDownload Raw Back to editor
1import os2 3import pywin.framework.window4import win32api5import win32ui6from pywin.mfc import docview7 8from . import frame9 10ParentEditorTemplate = docview.DocTemplate11 12 13class EditorTemplateBase(ParentEditorTemplate):14    def __init__(15        self, res=win32ui.IDR_TEXTTYPE, makeDoc=None, makeFrame=None, makeView=None16    ):17        if makeFrame is None:18            makeFrame = frame.EditorFrame19        ParentEditorTemplate.__init__(self, res, makeDoc, makeFrame, makeView)20 21    def _CreateDocTemplate(self, resourceId):22        assert 0, "You must override this"23 24    def CreateWin32uiDocument(self):25        assert 0, "You must override this"26 27    def GetFileExtensions(self):28        return ".txt", ".py"29 30    def MatchDocType(self, fileName, fileType):31        doc = self.FindOpenDocument(fileName)32        if doc:33            return doc34        ext = os.path.splitext(fileName)[1].lower()35        if ext in self.GetFileExtensions():36            return win32ui.CDocTemplate_Confidence_yesAttemptNative37        return win32ui.CDocTemplate_Confidence_maybeAttemptForeign38 39    def InitialUpdateFrame(self, frame, doc, makeVisible=1):40        self._obj_.InitialUpdateFrame(frame, doc, makeVisible)  # call default handler.41        doc._UpdateUIForState()42 43    def GetPythonPropertyPages(self):44        """Returns a list of property pages"""45        from . import configui46 47        return [configui.EditorPropertyPage(), configui.EditorWhitespacePropertyPage()]48 49    def OpenDocumentFile(self, filename, bMakeVisible=1):50        if filename is not None:51            try:52                path = os.path.split(filename)[0]53                # 				print "The editor is translating", `filename`,"to",54                filename = win32api.FindFiles(filename)[0][8]55                filename = os.path.join(path, filename)56            # 				print `filename`57            except (win32api.error, IndexError) as details:58                pass59        # 				print "Couldnt get the full filename!", details60        return self._obj_.OpenDocumentFile(filename, bMakeVisible)61 
codekingpro/portable-devtools · Team Ai