コード例 #1
0
    def create_control(self, parent):
        """ Creates the toolkit-specific control that represents the
            editor. 'parent' is the toolkit-specific control that is
            the editor's parent.
        """
        ed = PythonEditor(parent, show_line_numbers=False)

        # FIXME: Implement toolkit specific Python editor subclass
        import wx
        styles = [
            wx.stc.STC_STYLE_DEFAULT,
            wx.stc.STC_STYLE_CONTROLCHAR,
            wx.stc.STC_STYLE_BRACELIGHT,
            wx.stc.STC_STYLE_BRACEBAD,
            wx.stc.STC_P_DEFAULT,
            wx.stc.STC_P_COMMENTLINE,
            wx.stc.STC_P_NUMBER,
            wx.stc.STC_P_STRING,
            wx.stc.STC_P_CHARACTER,
            wx.stc.STC_P_WORD,
            wx.stc.STC_P_TRIPLE,
            wx.stc.STC_P_TRIPLEDOUBLE,
            wx.stc.STC_P_CLASSNAME,
            wx.stc.STC_P_DEFNAME,
            wx.stc.STC_P_OPERATOR,
            wx.stc.STC_P_IDENTIFIER,
            wx.stc.STC_P_COMMENTBLOCK,
            wx.stc.STC_P_STRINGEOL
        ]

        for style in styles:
            ed.control.StyleSetFaceName(style, "monospace")
            ed.control.StyleSetSize(style, 10)

        path = self.obj.path
        if exists(path):
            ed.path = path
            ed.load()

        return ed.control