def getWindow(self, attachTo, filePath=None): window = wx.Panel() fileExtension = filePath.split('.')[-1] if fileExtension == 'md': window = CreatingPandocPanel(attachTo, filePath=filePath) # window.markdownSourcePanel.stc.LoadFile(path=filePath) window.markdownSourcePanel.stc.SetFileName(filePath) window.markdownSourcePanel.stc.SetModTime( os.path.getmtime(filePath)) # mainStc.SetText(FileOperations().readFile(filePath=fileWithImage[0])) window.markdownSourcePanel.stc.ConfigureLexer(fileExtension) window.markdownSourcePanel.stc.SetModified(False) # imageName = self.iconManager.getFileImageNameByExtension(fileExtension) # (name, captionName) = self.getTitleString(stc=mainStc, path=fileWithImage[0]) window.markdownSourcePanel.stc.SetSavePoint() else: window = MainStc(attachTo, text=FileOperations().readFile(filePath=filePath)) window.SetFileName(filePath) window.SetModTime(os.path.getmtime(filePath)) # mainStc.SetText(FileOperations().readFile(filePath=fileWithImage[0])) window.ConfigureLexer(fileExtension) window.SetModified(False) # imageName = self.iconManager.getFileImageNameByExtension(fileExtension) # (name, captionName) = self.getTitleString(stc=mainStc, path=fileWithImage[0]) window.SetSavePoint() return window
def OpenFiles(self, files): """Open the list of files in Editra for editing @param files: list of file names """ to_open = list() for fname in files: try: res = os.stat(fname)[0] if stat.S_ISREG(res) or stat.S_ISDIR(res): to_open.append(fname) except (IOError, OSError) as msg: logger.debug("[filebrowser][err] %s" % str(msg)) # TODO : Need to work on it. if hasattr(self.GetTopLevelParent(), '_mgr'): for path in to_open: mainStc = MainStc(self) mainStc.SetSavePoint() fileName = os.path.split(path)[-1] file_ext = fileName.split('.')[-1] mainStc.SetFileName(path) mainStc.SetText(FileOperations().readFile(filePath=path)) mainStc.ConfigureLexer(file_ext) # imageName=self.iconsDictIndex[extensionName] self.GetTopLevelParent()._mgr.addTabByWindow( window=mainStc, captionName=fileName, tabDirection=5)
def __init__(self, parent=None, *args, text=None, **kw): wx.Panel.__init__(self, parent, id=-1) self.parent = parent self.parent = parent vBox = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL) #################################################################### self.stc = MainStc(self, text=text) sizer.Add(self.stc, 1, wx.EXPAND) #################################################################### sizer.Add(vBox, 1, wx.EXPAND, 0) self.SetSizer(sizer)
def __init__(self, parent=None, *args, text=None, **kw): wx.Panel.__init__(self, parent, id=-1) pub.subscribe(self.setPage, 'setPage') self.parent = parent self.parent = parent vBox = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL) #################################################################### htmlsrc = self.GetParent().getHtmlFromMarkdown(text) self.stc = MainStc(self, text=htmlsrc) sizer.Add(self.stc, 1, wx.EXPAND) #################################################################### sizer.Add(vBox, 1, wx.EXPAND, 0) self.SetSizer(sizer)