示例#1
0
文件: wxpyfw.py 项目: gtripoli/wxPyFw
    def __init__(self, window, panel, file):
        
        self.panel = panel
        self.file = file
        self.notebook_files = window.notebook_files
        self.project_tree = window.project_tree
        
        try :
            self.text_editor = CodeEditor(panel, file)
            
            self.text_editor.EmptyUndoBuffer()

            #self.text_editor.Bind(wx.EVT_KEY_DOWN, self.SetModifiedFile)

            # line numbers in the margin
            self.text_editor.SetMarginType(1, wx.stc.STC_MARGIN_NUMBER)
            self.text_editor.SetMarginWidth(1, 25)
            self.text_editor.SetSTCFocus(True)
        except :
            logger.write(sys.exc_value, "ERROR", (self, traceback.extract_stack()))
        else :
            self.notebook_files.Bind(wx.lib.agw.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.CloseFile)
示例#2
0
文件: wxpyfw.py 项目: gtripoli/wxPyFw
class create_text_editor :
    def __init__(self, window, panel, file):
        
        self.panel = panel
        self.file = file
        self.notebook_files = window.notebook_files
        self.project_tree = window.project_tree
        
        try :
            self.text_editor = CodeEditor(panel, file)
            
            self.text_editor.EmptyUndoBuffer()

            #self.text_editor.Bind(wx.EVT_KEY_DOWN, self.SetModifiedFile)

            # line numbers in the margin
            self.text_editor.SetMarginType(1, wx.stc.STC_MARGIN_NUMBER)
            self.text_editor.SetMarginWidth(1, 25)
            self.text_editor.SetSTCFocus(True)
        except :
            logger.write(sys.exc_value, "ERROR", (self, traceback.extract_stack()))
        else :
            self.notebook_files.Bind(wx.lib.agw.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.CloseFile)
            
    def SetModifiedFile(self, event):
        idx = self.notebook_files.GetSelection()
        file = TAB[idx]

        if not file["modified"] :
            file["modified"] = file["object"].text_editor.GetModify()
            if file["object"].text_editor.GetModify() :
                self.notebook_files.SetPageText(idx, "* %s" % file["name"])
                #self.notebook_files.SetPageText(self.notebook_files.GetSelection(), "* %s" % self.notebook_files.GetPageText(self.notebook_files.GetSelection()))
        
        self.text_editor.onKeyPressed(event)
    
    def CloseFile(self, event):
        idx = self.notebook_files.GetSelection()
        file = TAB[idx]
        
        if file["object"].text_editor.GetModify() :
            if(wx.MessageBox("File %s is modified. Save It?" % file["name"], "Save...", wx.YES_NO | wx.CANCEL | wx.YES_DEFAULT | wx.ICON_QUESTION, self.notebook_files)==wx.YES) :
                wx.BeginBusyCursor()
                
                try :
                    file["object"].text_editor.SaveFile(file["path"])
                except :
                    logger.write(sys.exc_value, "ERROR", (self, traceback.extract_stack()))    
                    
                else :
                    info = self.project_tree.GetItemPyData(TAB[idx]["item"])
                    info["idx"] = None
                    
                    self.project_tree.SetItemPyData(TAB[idx]["item"], info)
                    
                    del TAB[idx]

                    self.notebook_files.DeletePage(idx)
                    
                    event.Veto()

                wx.EndBusyCursor()