コード例 #1
0
    def __init__(self,
                 parent,
                 id,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 name="plaintext"):
        """ Standard __init__ function."""
        stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style, name)
        CellCtrlBase.__init__(self, parent, id, pos, size, style, name)
        self.oldlineno = 1  # used by OnModified. Is there a way to
        # declare this inside the method? Like a
        # C++ static variable
        self.oldpos = (0, 0)
        self.SetUseHorizontalScrollBar(0)
        self.SetLexer(stc.STC_LEX_XML)
        self.StyleSetSpec(stc.STC_H_TAG, "fore:#0000FF")
        self.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "back:#E0C0C0")

        #self.SetKeyWords(0,' '.join(['para', 'title', 'section', 'code',
        #                             'ipython-figure', 'ipython-block',
        #                             'ipython-inlineequation']))

        stc.EVT_STC_MODIFIED(self, id, self.OnModified)
        stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
コード例 #2
0
 def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
              size=wx.DefaultSize, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
     """Create EditWindow instance."""
     stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style)
     self.__config()
     stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
     dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease')
     dispatcher.connect(receiver=self._fontsizer, signal='FontDecrease')
     dispatcher.connect(receiver=self._fontsizer, signal='FontDefault')
コード例 #3
0
    def __init__(self,
                 view,
                 parent,
                 id=-1,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.CLIP_CHILDREN):
        """Create Shell instance."""
        editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
        CellCtrlBase.__init__(self, parent, id, pos, size, style)
        self.view = view
        #self.document = view.doc
        #self.log = self.document.log
        self.oldlineno = 1  # used by OnModified. Is there a way to
        # declare this inside the method? Like a
        # C++ static variable
        self.oldpos = (0, 0)

        self.wrap()

        # Find out for which keycodes the interpreter will autocomplete.
        #self.autoCompleteKeys = self.document.log.interp.getAutoCompleteKeys()
        #TODO: fix this. IPython must tell us which keys go here
        self.autoCompleteKeys = []

        # Keep track of the last non-continuation prompt positions.
        #self.promptPosStart = 0
        self.promptPosEnd = 0
        # Keep track of multi-line commands.
        self.more = False
        # Create the command history.  Commands are added into the
        # front of the list (ie. at index 0) as they are entered.
        # self.historyIndex is the current position in the history; it
        # gets incremented as you retrieve the previous command,
        # decremented as you retrieve the next, and reset when you hit
        # Enter.  self.historyIndex == -1 means you're on the current
        # command, not in the history.
        #self.history = []
        #self.historyIndex = -1
        # Assign handlers for keyboard events.
        wx.EVT_CHAR(self, self.OnChar)
        #This is unnecessary. The method is called by CellCtrlBase.KeyDown
        #wx.EVT_KEY_DOWN(self, self.OnKeyDown)
        # Assign handler for idle time.
        self.waiting = False
        wx.EVT_IDLE(self, self.OnIdle)
        stc.EVT_STC_MODIFIED(self, id, self.OnModified)
        stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
コード例 #4
0
    def __init__(self,
                 parent,
                 id=-1,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
        """Create EditWindow instance."""
        stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style)
        self.__config()
        stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
        dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease')
        dispatcher.connect(receiver=self._fontsizer, signal='FontDecrease')
        dispatcher.connect(receiver=self._fontsizer, signal='FontDefault')

        #seb:    http://wiki.wxpython.org/index.cgi/StyledTextCtrl_Log_Window_Demo
        self._styles = [None] * 32
        self._free = 1
コード例 #5
0
    def __init__(self,
                 parent,
                 id,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 name="text"):
        """ Standard __init__ function."""
        stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style, name)
        CellCtrlBase.__init__(self, parent, id, pos, size, style, name)
        self.oldlineno = 1  # used by OnModified. Is there a way to
        # declare this inside the method? Like a
        # C++ static variable
        self.oldpos = (0, 0)
        self.SetUseHorizontalScrollBar(0)

        stc.EVT_STC_MODIFIED(self, id, self.OnModified)
        stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
コード例 #6
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        factory = self.factory
        self._editor = editor = PythonEditor(
            parent, show_line_numbers=factory.show_line_numbers)
        self.control = control = editor.control

        # There are a number of events which aren't well documented that look
        # to be useful in future implmentations, below are a subset of the
        # events that look interesting:
        #    EVT_STC_AUTOCOMP_SELECTION
        #    EVT_STC_HOTSPOT_CLICK
        #    EVT_STC_HOTSPOT_DCLICK
        #    EVT_STC_DOUBLECLICK
        #    EVT_STC_MARGINCLICK

        control.SetSize(wx.Size(300, 124))

        # Clear out the goofy hotkeys for zooming text
        control.CmdKeyClear(ord('B'), stc.STC_SCMOD_CTRL)
        control.CmdKeyClear(ord('N'), stc.STC_SCMOD_CTRL)

        # Set up the events
        wx.EVT_KILL_FOCUS(control, self.wx_update_object)
        stc.EVT_STC_CALLTIP_CLICK(control, control.GetId(),
                                  self._calltip_clicked)

        if factory.auto_scroll and (factory.selected_line != ''):
            wx.EVT_SIZE(control, self._update_selected_line)

        if factory.auto_set:
            editor.on_trait_change(self.update_object,
                                   'changed',
                                   dispatch='ui')

        if factory.key_bindings is not None:
            editor.on_trait_change(self.key_pressed,
                                   'key_pressed',
                                   dispatch='ui')

        if self.readonly:
            control.SetReadOnly(True)

        # Set up the lexer
        control.SetLexer(stc.STC_LEX_CONTAINER)
        control.Bind(stc.EVT_STC_STYLENEEDED, self._style_needed)
        try:
            self.lexer = getattr(stc, 'STC_LEX_' + self.factory.lexer.upper())
        except AttributeError:
            self.lexer = stc.STC_LEX_NULL

        # Define the markers we use:
        control.MarkerDefine(MARK_MARKER,
                             stc.STC_MARK_BACKGROUND,
                             background=factory.mark_color_)
        control.MarkerDefine(SEARCH_MARKER,
                             stc.STC_MARK_BACKGROUND,
                             background=factory.search_color_)
        control.MarkerDefine(SELECTED_MARKER,
                             stc.STC_MARK_BACKGROUND,
                             background=factory.selected_color_)

        # Make sure the editor has been initialized:
        self.update_editor()

        # Set up any event listeners:
        self.sync_value(factory.mark_lines, 'mark_lines', 'from', is_list=True)
        self.sync_value(factory.selected_line, 'selected_line', 'from')
        self.sync_value(factory.selected_text, 'selected_text', 'to')
        self.sync_value(factory.line, 'line')
        self.sync_value(factory.column, 'column')
        self.sync_value(factory.calltip_clicked, 'calltip_clicked')

        self.sync_value(factory.dim_lines, 'dim_lines', 'from', is_list=True)
        if self.factory.dim_color == '':
            self.dim_color = 'dark grey'
        else:
            self.sync_value(factory.dim_color, 'dim_color', 'from')

        self.sync_value(factory.squiggle_lines,
                        'squiggle_lines',
                        'from',
                        is_list=True)
        if factory.squiggle_color == '':
            self.squiggle_color = 'red'
        else:
            self.sync_value(factory.squiggle_color, 'squiggle_color', 'from')

        # Check if we need to monitor the line or column position being
        # changed:
        if (factory.line != '') or (factory.column != '') or \
                (factory.selected_text != ''):
            stc.EVT_STC_UPDATEUI(control, control.GetId(),
                                 self._position_changed)
        self.set_tooltip()
コード例 #7
0
ファイル: stc.py プロジェクト: italomaia/spe
    def __init__(self, parent, id=-1,namespace={},path=None,config=None,
            ignore=None,menu=None):
        wx_stc.StyledTextCtrl.__init__(self, parent, id,
                                  style = wx.FULL_REPAINT_ON_RESIZE|wx.NO_BORDER)
        #PASSING VALUES
        self.namespace=namespace
        self.config=config
        self.ignore=ignore
        if path and path not in sys.path: sys.path.append(path)

        #INITIALIZE
        self.calltip    = 0 #calltip counter
        self.menu       = menu
        self.SetLexer(wx_stc.STC_LEX_PYTHON)

        #KEYBOARD SHORTCUTS (what are they doing here?)
        self.CmdKeyAssign(ord('B'), wx_stc.STC_SCMOD_CTRL, wx_stc.STC_CMD_ZOOMIN)
        self.CmdKeyAssign(ord('N'), wx_stc.STC_SCMOD_CTRL, wx_stc.STC_CMD_ZOOMOUT)
        
        #KEYPAD DEFINITIONS
        self.CmdKeyAssign(wx.WXK_NUMPAD_UP, 0, wx_stc.STC_CMD_LINEUP)
        self.CmdKeyAssign(wx.WXK_NUMPAD_DOWN, 0, wx_stc.STC_CMD_LINEDOWN)
        self.CmdKeyAssign(wx.WXK_NUMPAD_LEFT, 0, wx_stc.STC_CMD_CHARLEFT)
        self.CmdKeyAssign(wx.WXK_NUMPAD_RIGHT, 0, wx_stc.STC_CMD_CHARRIGHT)
        self.CmdKeyAssign(wx.WXK_NUMPAD_HOME, 0, wx_stc.STC_CMD_HOME)
        self.CmdKeyAssign(wx.WXK_NUMPAD_END, 0, wx_stc.STC_CMD_LINEEND)
        self.CmdKeyAssign(wx.WXK_NUMPAD_HOME, wx_stc.STC_SCMOD_CTRL, wx_stc.STC_CMD_DOCUMENTSTART)
        self.CmdKeyAssign(wx.WXK_NUMPAD_END, wx_stc.STC_SCMOD_CTRL, wx_stc.STC_CMD_DOCUMENTEND)
        self.CmdKeyAssign(wx.WXK_NUMPAD_PAGEUP, 0, wx_stc.STC_CMD_PAGEUP)
        self.CmdKeyAssign(wx.WXK_NUMPAD_PAGEDOWN, 0, wx_stc.STC_CMD_PAGEDOWN)
        self.CmdKeyAssign(wx.WXK_NUMPAD_INSERT, 0, wx_stc.STC_CMD_EDITTOGGLEOVERTYPE)
        self.CmdKeyAssign(wx.WXK_NUMPAD_DELETE, 0, wx_stc.STC_CMD_CLEAR)

        #PYTHON
        self.SetLexer(wx_stc.STC_LEX_PYTHON)
        keywords=keyword.kwlist
        keywords.extend(['None','as','True','False'])
        self.SetKeyWords(0, " ".join(keywords))

        #GENERAL
        self.AutoCompSetIgnoreCase(False)

        #FOLDING
        self.SetProperty("fold", "1")
        self.SetProperty("tab.timmy.whinge.level", "1")
        self.SetProperty("fold.comment.python", "0")
        self.SetProperty("fold.quotes.python", "0")

        #USER SETTINGS
        if self.config:
            self.update()
        else:
            self.SetViewWhiteSpace(0)
            self.SetTabWidth(4)
            self.SetIndentationGuides(1)
            self.SetUseTabs(0)
            self.SetEdgeMode(wx_stc.STC_EDGE_LINE)
            self.SetEdgeColumn(79)
            self.getDefaultFaces()
            self.SetWordChars(WORDCHARS)
        self.SetStyles()

        self.SetBackSpaceUnIndents(1)
##        self.SetTabIndents(0)
##        self.SetIndent(1)
        self.SetEdgeColumn(79)
        self.SetEdgeColour(wx.Colour(200,200,200))

        #MARGINS
        self.SetMargins(0,0)
        #margin 1 for line numbers
        self.SetMarginType(1, wx_stc.STC_MARGIN_NUMBER)
        if self.getint('ViewLineNumbers'):
            self.SetMarginWidth(1, 50)
        else:
            self.SetMarginWidth(1, 0)
        #margin 2 for markers
        self.SetMarginType(2, wx_stc.STC_MARGIN_SYMBOL)
        self.SetMarginMask(2, wx_stc.STC_MASK_FOLDERS)
        self.SetMarginSensitive(2, True)
        self.SetMarginWidth(2, 12)
        if 0: # simple folder marks, like the old version
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDER, wx_stc.STC_MARK_ARROW, "navy", "navy")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDEROPEN, wx_stc.STC_MARK_ARROWDOWN, "navy", "navy")
            # Set these to an invisible mark
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDEROPENMID, wx_stc.STC_MARK_BACKGROUND, "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDERMIDTAIL, wx_stc.STC_MARK_BACKGROUND, "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDERSUB, wx_stc.STC_MARK_BACKGROUND, "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDERTAIL, wx_stc.STC_MARK_BACKGROUND, "white", "black")

        else: # more involved "outlining" folder marks
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDEREND,     wx_stc.STC_MARK_BOXPLUSCONNECTED,  "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDEROPENMID, wx_stc.STC_MARK_BOXMINUSCONNECTED, "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDERMIDTAIL, wx_stc.STC_MARK_TCORNER,  "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDERTAIL,    wx_stc.STC_MARK_LCORNER,  "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDERSUB,     wx_stc.STC_MARK_VLINE,    "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDER,        wx_stc.STC_MARK_BOXPLUS,  "white", "black")
            self.MarkerDefine(wx_stc.STC_MARKNUM_FOLDEROPEN,    wx_stc.STC_MARK_BOXMINUS, "white", "black")
        wx_stc.EVT_STC_UPDATEUI(self,    id, self.OnUpdateUI)
        wx_stc.EVT_STC_MARGINCLICK(self, id, self.OnMarginClick)

        # STYLES
        # Make some styles,  The lexer defines what each style is used for, we
        # just have to define what each style looks like.  This set is adapted from
        # Scintilla sample property files.
        # Default style
        self.StyleSetSpec(wx_stc.STC_STYLE_DEFAULT,
                          "face:%(mono)s,size:%(size)d" % \
                          self.faces)
        self.StyleSetBackground(wx_stc.STC_STYLE_BRACELIGHT,"#AAAAFF")

        self.SetCaretForeground("BLACK")
        self.SetSelBackground(1,'DARK TURQUOISE')

        #EVENTS
        self.Bind(wx_stc.EVT_STC_UPDATEUI, self.OnUpdateUI)
        self.Bind(wx_stc.EVT_STC_MARGINCLICK, self.OnMarginClick)
        self.Bind(wx.EVT_CHAR, self.OnChar)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMiddleDown)
        if wx.Platform=='__WXMAC__':
            self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        if self.menu:
            self.UsePopUp(False)
            if wx.Platform=='__WXMAC__':
                self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick)
            else:
                self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
コード例 #8
0
ファイル: python_stc.py プロジェクト: sjl421/code-2
    def __init__(self, parent, ID):
        stc.StyledTextCtrl.__init__(self,
                                    parent,
                                    ID,
                                    style=wx.NO_FULL_REPAINT_ON_RESIZE)

        self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
        self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)

        self.SetLexer(stc.STC_LEX_PYTHON)
        self.SetKeyWords(0, " ".join(keyword.kwlist))

        self.SetProperty("fold", "1")
        self.SetProperty("tab.timmy.whinge.level", "1")
        self.SetMargins(0, 0)

        self.SetViewWhiteSpace(False)
        #self.SetBufferedDraw(False)

        self.SetEdgeMode(stc.STC_EDGE_BACKGROUND)
        self.SetEdgeColumn(78)

        # Setup a margin to hold fold markers
        ###  WHAT IS THIS VALUE?  WHAT ARE THE OTHER FLAGS?  DOES IT MATTER?
        self.SetFoldFlags(16)
        #mic
        #self.SetMarginType(2, stc.STC_MARGIN_SYMBOL)
        #self.SetMarginMask(2, stc.STC_MASK_FOLDERS)
        #self.SetMarginSensitive(2, True)
        #self.SetMarginWidth(2, 12)
        # line numbers in the margin
        self.SetMarginType(1, stc.STC_MARGIN_NUMBER)
        self.SetMarginWidth(1, 25)

        if 0:  # simple folder marks, like the old version
            self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_ARROW,
                              "navy", "navy")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN,
                              stc.STC_MARK_ARROWDOWN, "navy", "navy")
            # Set these to an invisible mark
            self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID,
                              stc.STC_MARK_BACKGROUND, "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL,
                              stc.STC_MARK_BACKGROUND, "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB,
                              stc.STC_MARK_BACKGROUND, "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL,
                              stc.STC_MARK_BACKGROUND, "white", "black")

        elif 0:  # more involved "outlining" folder marks
            self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND,
                              stc.STC_MARK_BOXPLUSCONNECTED, "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID,
                              stc.STC_MARK_BOXMINUSCONNECTED, "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL,
                              stc.STC_MARK_TCORNER, "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNER,
                              "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE,
                              "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_BOXPLUS,
                              "white", "black")
            self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN,
                              stc.STC_MARK_BOXMINUS, "white", "black")

        stc.EVT_STC_UPDATEUI(self, ID, self.OnUpdateUI)
        stc.EVT_STC_MARGINCLICK(self, ID, self.OnMarginClick)

        # Make some styles,  The lexer defines what each style is used for, we
        # just have to define what each style looks like.  This set is adapted
        # from Scintilla sample property files.

        self.StyleClearAll()

        # Global default styles for all languages
        self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
                          "face:%(helv)s,size:%(size)d" % faces)
        self.StyleSetSpec(stc.STC_STYLE_LINENUMBER,
                          "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces)
        self.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR, "face:%(other)s" % faces)
        self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT,
                          "fore:#FFFFFF,back:#0000FF,bold")
        self.StyleSetSpec(stc.STC_STYLE_BRACEBAD,
                          "fore:#000000,back:#FF0000,bold")

        # Python styles
        # White space
        self.StyleSetSpec(stc.STC_P_DEFAULT,
                          "fore:#808080,face:%(helv)s,size:%(size)d" % faces)
        # Comment
        self.StyleSetSpec(stc.STC_P_COMMENTLINE,
                          "fore:#007F00,face:%(other)s,size:%(size)d" % faces)
        # Number
        self.StyleSetSpec(stc.STC_P_NUMBER,
                          "fore:#007F7F,size:%(size)d" % faces)
        # String
        self.StyleSetSpec(
            stc.STC_P_STRING,
            "fore:#7F007F,italic,face:%(times)s,size:%(size)d" % faces)
        # Single quoted string
        self.StyleSetSpec(
            stc.STC_P_CHARACTER,
            "fore:#7F007F,italic,face:%(times)s,size:%(size)d" % faces)
        # Keyword
        self.StyleSetSpec(stc.STC_P_WORD,
                          "fore:#00007F,bold,size:%(size)d" % faces)
        # Triple quotes
        self.StyleSetSpec(stc.STC_P_TRIPLE,
                          "fore:#7F0000,size:%(size)d" % faces)
        # Triple double quotes
        self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE,
                          "fore:#7F0000,size:%(size)d" % faces)
        # Class name definition
        self.StyleSetSpec(stc.STC_P_CLASSNAME,
                          "fore:#0000FF,bold,underline,size:%(size)d" % faces)
        # Function or method name definition
        self.StyleSetSpec(stc.STC_P_DEFNAME,
                          "fore:#007F7F,bold,size:%(size)d" % faces)
        # Operators
        self.StyleSetSpec(stc.STC_P_OPERATOR, "bold,size:%(size)d" % faces)
        # Identifiers
        self.StyleSetSpec(stc.STC_P_IDENTIFIER,
                          "fore:#808080,face:%(helv)s,size:%(size)d" % faces)
        # Comment-blocks
        self.StyleSetSpec(stc.STC_P_COMMENTBLOCK,
                          "fore:#7F7F7F,size:%(size)d" % faces)
        # End of line where string is not closed
        self.StyleSetSpec(
            stc.STC_P_STRINGEOL,
            "fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" %
            faces)

        self.SetCaretForeground("BLUE")

        wx.EVT_KEY_DOWN(self, self.OnKeyPressed)
コード例 #9
0
    def __init__(self, aParent, aResource):
        stc.StyledTextCtrl.__init__(
            self,
            aParent,
            widget.makeNewId(aResource.id),
            #aResource.text,
            aResource.position,
            aResource.size,
            #style = wxTE_PROCESS_ENTER | borderStyle | wxCLIP_SIBLINGS,
            #style = borderStyle | wx.CLIP_SIBLINGS,
            style=wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS,
            name=aResource.name)

        widget.Widget.__init__(self, aParent, aResource)

        # POB 2002-05-04
        # Borrowed stuff from PyCrust just to get this working.
        self.SetMarginType(LINE_NUMBER_MARGIN, stc.STC_MARGIN_NUMBER)
        self.SetMarginWidth(LINE_NUMBER_MARGIN, LINE_NUMBER_MARGIN_WIDTH)
        self.SetLexer(stc.STC_LEX_PYTHON)
        self.SetKeyWords(0, ' '.join(keyword.kwlist))
        self._setStyles(faces)
        self.SetViewWhiteSpace(0)
        self.SetTabWidth(4)
        self.SetUseTabs(0)
        self.CallTipSetBackground(wx.Colour(255, 255, 232))
        self.SetBackSpaceUnIndents(1)

        stc.EVT_STC_UPDATEUI(self, self.GetId(), self.OnUpdateUI)

        # KEA 2002-12-16
        # code folding code taken from
        # wxStyledTextCtrl_2.py
        self.SetProperty("fold", "1")
        # Setup a margin to hold fold markers
        self.SetFoldFlags(
            16
        )  ###  WHAT IS THIS VALUE?  WHAT ARE THE OTHER FLAGS?  DOES IT MATTER?
        self.SetMarginType(CODE_FOLDING_MARGIN, stc.STC_MARGIN_SYMBOL)
        self.SetMarginMask(CODE_FOLDING_MARGIN, stc.STC_MASK_FOLDERS)
        self.SetMarginSensitive(CODE_FOLDING_MARGIN, 1)
        self.SetMarginWidth(CODE_FOLDING_MARGIN, CODE_FOLDING_MARGIN_WIDTH)
        # initially code folding should be off
        self.SetMarginWidth(CODE_FOLDING_MARGIN, 0)

        self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND,
                          stc.STC_MARK_BOXPLUSCONNECTED, "white", "black")
        self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID,
                          stc.STC_MARK_BOXMINUSCONNECTED, "white", "black")
        self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNER,
                          "white", "black")
        self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNER,
                          "white", "black")
        self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE,
                          "white", "black")
        self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_BOXPLUS,
                          "white", "black")
        self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_BOXMINUS,
                          "white", "black")

        # KEA 2004-05-20
        # get rid of the annoying text drag and drop
        #stc.EVT_STC_START_DRAG(self, self.GetId(), self.OnStartDrag)

        stc.EVT_STC_MARGINCLICK(self, self.GetId(), self.OnMarginClick)

        if not aResource.editable:
            self._setEditable(False)

        #adapter = CodeEditorEventBinding(self)
        #adapter.bindEvents()
        self._bindEvents(event.WIDGET_EVENTS +
                         (event.KeyPressEvent, event.KeyDownEvent,
                          event.KeyUpEvent))