def createLogPane_(self, parent):
        """"""
        pane = wx.Notebook(parent, -1, size=(810, 210), style=wx.BK_DEFAULT)

        self.log = stc.StyledTextCtrl(pane, -1)
        self.log.SetName("Log")
        self.log.SetUseHorizontalScrollBar(False)
        self.log.SetMarginWidth(1, 0)
        self.log.SetWrapMode(1)  # Turns on word wrap
        self.log.StyleClearAll()
        self.log.StyleSetSpec(1, "fore:BLACK")
        self.log.StyleSetSpec(2, "fore:RED")

        self.errLog = stc.StyledTextCtrl(pane, -1)
        self.errLog.SetName("Errors")
        self.errLog.SetUseHorizontalScrollBar(False)
        self.errLog.SetMarginWidth(1, 0)
        self.errLog.SetWrapMode(1)  # Turns on word wrap

        self.errLog.StyleClearAll()
        self.errLog.StyleSetSpec(1, "fore:BLACK")
        self.errLog.StyleSetSpec(2, "fore:RED")

        crust = wx.py.crust.Crust(pane, -1)
        self.log.Hide()
        self.errLog.Hide()

        #pane.AddPage(self.log, "Log")
        #pane.AddPage(self.errLog, "Errors")
        pane.AddPage(crust, "Crust")

        #pane.GetPage(0).Enable( False)

        self.logAndMore = pane
        return self.logAndMore
Beispiel #2
0
    def makePanel(self, obj=None):
        panel = wx.Panel(self, -1)
        panel.isLoad = False
        if self.needToParse:
            if obj == "Intro":
                if BUILD_RST:
                    create_api_doc_index()
                panel.win = stc.StyledTextCtrl(panel, -1, size=(600, 480), style=wx.BORDER_SUNKEN)
                panel.win.SetUseHorizontalScrollBar(False)
                panel.win.SetUseVerticalScrollBar(False)
                panel.win.SetText(_INTRO_TEXT)
            elif "Example" in obj:
                panel.win = stc.StyledTextCtrl(panel, -1, size=(600, 480), style=wx.BORDER_SUNKEN)
                panel.win.SetUseHorizontalScrollBar(False)
                panel.win.SetUseVerticalScrollBar(False)
                if "1" in obj:
                    panel.win.SetText(_EXAMPLE_1)
                elif "2" in obj:
                    panel.win.SetText(_EXAMPLE_2)
            else:
                var = eval(obj)
                if isinstance(var, str):
                    panel.win = stc.StyledTextCtrl(panel, -1, size=(600, 480), style=wx.BORDER_SUNKEN)
                    panel.win.SetUseHorizontalScrollBar(False)
                    panel.win.SetUseVerticalScrollBar(False)
                    if "Interface_API" in var:
                        if BUILD_RST:
                            create_interface_api_index()
                        for word in _KEYWORDS_LIST:
                            lines = eval(word).__doc__.splitlines()
                            line = "%s : %s\n" % (word, lines[1].replace('"', '').strip())
                            var += line
                        var += _COLOUR_TEXT
                        var += _COLOURS
                    else:
                        if BUILD_RST:
                            create_base_module_index()
                    panel.win.SetText(var)
                else:
                    text = var.__doc__
                    if BUILD_RST:
                        create_api_doc_page(obj, text)
                    panel.win = stc.StyledTextCtrl(panel, -1, size=(600, 480), style=wx.BORDER_SUNKEN)
                    panel.win.SetUseHorizontalScrollBar(False)
                    panel.win.SetUseVerticalScrollBar(False)
                    panel.win.SetText(text.replace(">>> ", ""))

            panel.win.SaveFile(CeciliaLib.ensureNFD(os.path.join(DOC_PATH, obj)))
        return panel
Beispiel #3
0
    def new_lua_window(self, parent):
        # Creating a rich text window for code display and/or editing
        lua_interpreter = stc.StyledTextCtrl(parent, 0, wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        # Setting up the language to be edited/displayed
        lua_interpreter.SetLexer(stc.STC_LEX_LUA)

        # List of lua keywords
        keywords = [
            'and', 'break', 'do', 'else', 'elseif', 'false', 'for', 'function',
            'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return',
            'true', 'until', 'while'
        ]

        # Setting the reserved keywords list for this language
        lua_interpreter.SetKeyWords(0, " ".join(keywords))

        # Adding a feature to be albe to zoom in and out for better reading
        lua_interpreter.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL,
                                     stc.STC_CMD_ZOOMIN)
        lua_interpreter.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL,
                                     stc.STC_CMD_ZOOMOUT)

        # Setting the color for reserved words
        lua_interpreter.StyleSetSpec(stc.STC_P_WORD,
                                     "fore:#00007F,bold,size:%(size)d" % faces)

        # Giving back the new generated control
        return lua_interpreter
Beispiel #4
0
    def __init__(self, title="Timer Demo"):
        wx.Frame.__init__(
            self, None, -1, title
        )  #, size = (800,600), style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)

        self.TextCtrl = stc.StyledTextCtrl(self, wx.NewId())

        self.TextCtrl.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.TextCtrl, 1, wx.GROW)
        # set up the buttons
        ButtonSizer = self.SetUpTheButtons()
        sizer.Add(ButtonSizer, 0, wx.GROW)
        self.SetSizer(sizer)

        # now set up the timers:
        self.Timer1 = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer1, self.Timer1)
        #self.Bind(wx.EVT_TIMER, self.OnTimer1, id = self.Timer1.GetId())
        #self.Timer1.Bind(wx.EVT_TIMER, self.OnTimer1)

        self.Timer2 = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer2, self.Timer2)
        #self.Bind(wx.EVT_TIMER, self.OnTimer2, id = self.Timer2.GetId())
        #self.Timer2.Bind(wx.EVT_TIMER, self.OnTimer2)

        self.Counter1 = 0
        self.Counter2 = 0
Beispiel #5
0
    def __init__(self, *args, **kargs):
        wx.MiniFrame.__init__(self,
                              *args,
                              style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX
                              | wx.RESIZE_BORDER | wx.FRAME_FLOAT_ON_PARENT)
        vbox = wx.BoxSizer(wx.VERTICAL)

        panel = wx.Panel(self, wx.ID_ANY)
        panel.SetSizer(vbox)
        # self.tip = wx.StaticText(panel, -1,
        #                          style=wx.TE_MULTILINE)#|wx.TE_READONLY|wx.VSCROLL)
        # self.tip.SetBackgroundColour((255,255,0))
        self.tip = stc.StyledTextCtrl(panel, -1)
        self.tip.SetMarginWidth(0, 0)
        self.tip.SetMarginWidth(1, 0)
        self.tip.SetMarginWidth(2, 0)
        self.tip.SetReadOnly(True)
        self.tip.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, (255, 255, 0))

        vbox.Add(self.tip, 1, wx.EXPAND | wx.ALL, 5)
        self.Bind(wx.EVT_CLOSE, self.onWindowClose)
        self.Bind(wx.EVT_ACTIVATE, self.onActivate)
        #panel.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        #panel.Bind(wx.EVT_KILL_FOCUS, self.onKillFocus)
        #self.tip.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        #self.tip.Bind(wx.EVT_KILL_FOCUS, self.onKillFocus)
        self.Hide()
Beispiel #6
0
    def __init__(self, parent, texte=None):
        wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX|wx.THICK_FRAME)
        self.parent = parent

        # Bandeau
        intro = _(u"Vous pouvez consulter ici le journal d'évènements.")
        titre = _(u"Journal d'évènements")
        self.SetTitle(titre)
        self.ctrl_bandeau = CTRL_Bandeau.Bandeau(self, titre=titre, texte=intro, hauteurHtml=30, nomImage="Images/32x32/Log.png")

        # Editeur
        self.ctrl_editeur = stc.StyledTextCtrl(self, -1)
        self.ctrl_editeur.SetMarginType(1, stc.STC_MARGIN_NUMBER)
        self.ctrl_editeur.SetMarginWidth(1, 40)

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_fermer = CTRL_Bouton_image.CTRL(self, texte=_(u"Fermer"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_fermer)
        self.Bind(wx.EVT_CLOSE, self.OnBoutonFermer)

        # Init
        if texte != None :
            self.ctrl_editeur.SetText(texte)
Beispiel #7
0
    def __init__(self, parent, header, results, _title="Results"):
        wx.Dialog.__init__(self, parent, title=_title, size=(450, 500))
        self.Centre()

        cont = wx.BoxSizer(wx.VERTICAL)

        panel = wx.Panel(self)
        label = wx.StaticText(panel, label=header)
        self.txt = stc.StyledTextCtrl(panel)
        btn = wx.Button(panel, label=c.get_accept_msg())
        self.wrap = wx.CheckBox(panel, label="W. Wrap")

        self.txt.SetText(results)
        self.txt.SetReadOnly(True)
        font = wx.Font(8, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')
        self.txt.StyleSetFont(0, font)

        self.Bind(wx.EVT_BUTTON, self.OnClick, btn)
        self.Bind(wx.EVT_CHECKBOX, self.OnWrap, self.wrap)

        cont.Add(label, 0, wx.ALL, 2)
        cont.Add(self.txt, 2, wx.ALL | wx.EXPAND | wx.CENTER, 5)
        cont.Add(self.wrap, 0, wx.ALL | wx.CENTER, 1)
        cont.Add(btn, 0, wx.CENTER | wx.ALL, 5)
        panel.SetSizerAndFit(cont)
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, wx.ID_ANY)

        self.lb = wx.ListBox(self, choices=snip_list)
        self.lb.SetSelection(0)
        self.canvas = DisplayPanel(self)
        self.editor = stc.StyledTextCtrl(self, style=wx.BORDER_SIMPLE)
        self.editor.SetEditable(False)

        self.text = ''

        self.lb.Bind(wx.EVT_LISTBOX, self.OnListBoxSelect)
        self.Bind(wx.EVT_SIZE, self.OnSize)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.lb, 0, wx.EXPAND)
        sizer.Add((15,1))
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.canvas, 1, wx.EXPAND)
        vbox.Add((1, 15))
        vbox.Add(self.editor, 1, wx.EXPAND)
        sizer.Add(vbox, 1, wx.EXPAND)
        border = wx.BoxSizer()
        border.Add(sizer, 1, wx.EXPAND|wx.ALL, 30)
        self.SetSizer(border)

        wx.CallAfter(self.OnLoadSnippet)
Beispiel #9
0
    def __init__(self, *args, **kargs):
        wx.Dialog.__init__(self,
                           *args,
                           style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX
                           | wx.RESIZE_BORDER | wx.STAY_ON_TOP)

        vbox = wx.BoxSizer(wx.VERTICAL)

        panel = wx.Panel(self, wx.ID_ANY)
        panel.SetSizer(vbox)
        # self.tip = wx.StaticText(panel, -1,
        #                          style=wx.TE_MULTILINE)#|wx.TE_READONLY|wx.VSCROLL)
        # self.tip.SetBackgroundColour((255,255,0))
        self.tip = stc.StyledTextCtrl(panel, -1)
        self.tip.SetMarginWidth(0, 0)
        self.tip.SetMarginWidth(1, 0)
        self.tip.SetMarginWidth(2, 0)
        self.tip.SetReadOnly(True)
        self.tip.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, (190, 190, 190))

        vbox.Add(self.tip, 1, wx.EXPAND | wx.ALL, 5)
        button1 = wx.Button(panel, label="O.K.")
        vbox.Add(button1, 0, wx.ALIGN_RIGHT | wx.RIGHT, 20)
        self.Bind(wx.EVT_CLOSE, self.onWindowClose)
        self.Bind(wx.EVT_BUTTON, self.onOK, button1)
Beispiel #10
0
    def __init__(self, parent, ID, title, pos, size, parentApp):
        wx.Frame.__init__(self, parent, ID, title, pos, size,
                          TOOL_WINDOW_STYLE)
        panel = wx.Panel(self, -1)
        self.parentApp = parentApp
        wx.EVT_CLOSE(self, self.onCloseMe)
        wx.EVT_WINDOW_DESTROY(self, self.onDestroyMe)
        sizer1 = wx.BoxSizer(wx.VERTICAL)
        sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        self.hideTimers = wx.CheckBox(panel, -1, 'Hide timers',
                                      wx.DefaultPosition, wx.DefaultSize,
                                      wx.NO_BORDER)
        #self.hideTimers.SetValue(1)

        sizer2.Add(self.hideTimers, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 5)
        sizer2.Add((5, 5), 1)  # spacer
        self.hideUnused = wx.CheckBox(panel, -1, 'Hide unused (#)',
                                      wx.DefaultPosition, wx.DefaultSize,
                                      wx.NO_BORDER)
        # KEA 2004-04-10
        # default to showing all events
        # otherwise unused events will be missed at startup
        # self.hideUnused.SetValue(1)

        sizer2.Add(self.hideUnused, 0, wx.LEFT | wx.BOTTOM, 5)
        sizer1.Add(sizer2, 0, wx.EXPAND)

        self.maxSizeMsgHistory = 29000
        #self.maxSizeMsgHistory = 0 # Turn off

        # eventually, the font size should be settable in the user config
        self.msgHistory = stc.StyledTextCtrl(panel, -1, size=(100, 60))
        self.msgHistory.SetReadOnly(True)
        if wx.Platform == '__WXMSW__':
            self.msgHistory.StyleSetSpec(stc.STC_STYLE_DEFAULT,
                                         "face:Arial,size:9")
        else:
            self.msgHistory.StyleSetSize(stc.STC_STYLE_DEFAULT,
                                         wx.NORMAL_FONT.GetPointSize())
        # KEA 2005-12-25
        # change the lexer to Python
        # and denote unused messages as comments (e.g. #mouseUp
        self.msgHistory.StyleSetSpec(stc.STC_P_COMMENTLINE, "fore:#7F7F7F")
        self.msgHistory.SetLexer(stc.STC_LEX_PYTHON)
        self.msgHistory.SetUseHorizontalScrollBar(0)
        self.msgHistory.SetMarginWidth(1, 0)
        self.msgHistory.SetUndoCollection(0)

        sizer1.Add(self.msgHistory, 1, wx.EXPAND)
        sizer1.Fit(panel)
        sizer1.SetSizeHints(self)
        panel.SetSizer(sizer1)
        panel.SetAutoLayout(1)
        panel.Layout()

        # and now for a hack-fest
        if wx.Platform == '__WXMSW__':
            self.SetSize(size)

        event.EventLog.getInstance().addEventListener(self)
Beispiel #11
0
 def __init__(self, content):
     self.width = 800
     self.height = 500
     wx.Frame.__init__(self,
                       None,
                       -1,
                       u'SQLMAP',
                       size=(self.width, self.height),
                       style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
     tb = wx.Frame.CreateToolBar(self, style=wx.TB_FLAT | wx.TB_HORIZONTAL)
     tb.AddTool(104, u"搜索", wx.Bitmap("./ico/python.ico"))
     tb.Realize()
     self.panel = wx.Panel(self, -1)
     self.text = stc.StyledTextCtrl(self.panel,
                                    -1,
                                    pos=(2, 2),
                                    size=(self.width - 10,
                                          self.height - 50),
                                    style=wx.HSCROLL | wx.TE_MULTILINE)
     #self.text=wx.TextCtrl(self.panel,-1,pos=(2,2),size=(self.width-10,self.height-50), style=wx.HSCROLL|wx.TE_MULTILINE)
     self.text.SetBackgroundColour('black')
     self.text.SetForegroundColour(wx.GREEN)
     self.text.AppendText(content)
     self.Bind(wx.EVT_MENU, self.OnToolSelected, id=104)
     self.Bind(wx.EVT_FIND, self.OnFind)
     self.Bind(wx.EVT_FIND_NEXT, self.OnFindNext)
     self.Bind(wx.EVT_FIND_REPLACE, self.OnReplace)
     self.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnReplaceAll)
     self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
     self.search_forward = True
     self.Show()
    def test_stcStyleTextCtrl2(self):
        ed = stc.StyledTextCtrl(self.frame)
        ed.SetText(text)
        ed.EmptyUndoBuffer()
        ed.GotoPos(0)

        ed.INDICSTYLE00 = 0
        ed.INDICSTYLE01 = 1
        ed.INDICSTYLE02 = 2

        ed.IndicatorSetStyle(ed.INDICSTYLE00, stc.STC_INDIC_SQUIGGLE)
        ed.IndicatorSetForeground(ed.INDICSTYLE00, wx.RED)
        ed.IndicatorSetStyle(ed.INDICSTYLE01, stc.STC_INDIC_DIAGONAL)
        ed.IndicatorSetForeground(ed.INDICSTYLE01, wx.BLUE)
        ed.IndicatorSetStyle(ed.INDICSTYLE02, stc.STC_INDIC_STRIKE)
        ed.IndicatorSetForeground(ed.INDICSTYLE02, wx.RED)

        ed.StartStyling(100)

        ed.SetIndicatorCurrent(ed.INDICSTYLE00)
        ed.IndicatorFillRange(836, 10)
        ed.SetIndicatorCurrent(ed.INDICSTYLE01)
        ed.IndicatorFillRange(846, 8)
        ed.SetIndicatorCurrent(ed.INDICSTYLE02)
        ed.IndicatorFillRange(854, 10)
Beispiel #13
0
    def test_stcStyleTextCtrl5(self):
        ed = stc.StyledTextCtrl(self.frame)
        ed.SetText(text)
        ed.EmptyUndoBuffer()
        ed.GotoPos(0)

        ed.SetMarginType(0, stc.STC_MARGIN_NUMBER)
        ed.SetMarginWidth(0, 22)
        ed.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "size:%d,face:%s" % (pb-2, face1))
Beispiel #14
0
 def setup_editor(self):
     "define the editor panel"
     # self.editor = wx.TextCtrl(self.splitter, -1, style=wx.TE_MULTILINE)
     self.editor = stc.StyledTextCtrl(
         self.splitter)  # , -1, style=wx.TE_MULTILINE)
     self.editor.Enable(False)
     self.setup_text()
     self.editor.Bind(wx.EVT_TEXT, self.OnEvtText)
     return self.editor
Beispiel #15
0
    def test_stcStyleTextCtrl8(self):
        ed = stc.StyledTextCtrl(self.frame)
        ed.SetText(text)
        ed.EmptyUndoBuffer()
        ed.GotoPos(10)

        raw = ed.GetLineRaw(5)
        self.assertTrue(isinstance(raw, bytes))
        
        ed.AddTextRaw(b"some new text")
Beispiel #16
0
    def load_widgets(self):

        self.editor = stc.StyledTextCtrl(self,
                                         style=wx.TE_MULTILINE
                                         | wx.TE_WORDWRAP)
        self.editor.CmdKeyAssign(ord("+"), stc.STC_SCMOD_CTRL,
                                 stc.STC_CMD_ZOOMIN)
        self.editor.CmdKeyAssign(ord("-"), stc.STC_SCMOD_CTRL,
                                 stc.STC_CMD_ZOOMOUT)
        self.editor.SetViewWhiteSpace(False)
        self.editor.SetMargins(10, 0)
        self.editor.SetMarginType(1, stc.STC_MARGIN_NUMBER)
        self.editor.SetMarginWidth(2, 35)
        # self.editor.SetMarginType(
        #     2, stc.STC_MARGIN_SYMBOL | stc.STC_MARGIN_NUMBER)
        # self.editor.SetMarginMask(2, stc.STC_MASK_FOLDERS)
        # self.editor.SetMarginSensitive(2, True)
        # self.editor.SetMarginWidth(2, 35)
        self.editor.SetLexer(stc.STC_LEX_PYTHON)
        self.editor.SetKeyWords(0, " ".join(keyword.kwlist))
        self.editor.SetProperty("fold", "1")
        self.editor.SetProperty("tab.timmy.whinge.level", "1")
        self.editor.SetEdgeMode(stc.STC_EDGE_BACKGROUND)
        self.editor.SetEdgeColumn(78)
        self.editor.Bind(wx.EVT_KEY_DOWN, self.updateCaretPosInStatusBar)
        self.editor.SetValue("""

from sys import argv

def greet(name):
        print("Hello, {}".format(name))

if __name__ == "__main__":
        greet(argv[1])

""")

        self.syntax_highlight_styles_python = {
            "default": "#000000",
            "keyword": "#EF5350",
            "comment-line": "#BDBDBD",
            "block_comment": "#BDBDBD",
            "string": "#43A047",
            "block_string": "#43A047",
            "operators": "#EF5350",
            "number": "#29B6F6",
            "EOL_when_string_not_closed": "#E53935",
            "class_and_function_names": "#7E57C2",
            "identifiers": "#000000"
        }

        self.global_styles = {"linenum_back": "#F5F5F5", "cursor": "#000000"}

        self.update_syntax_highlight(self.syntax_highlight_styles_python,
                                     self.global_styles)
Beispiel #17
0
    def __init__(self, title="Timer Demo"):
        wx.Frame.__init__(self, None, -1, title, size=(500, 400))

        self.TextCtrl = stc.StyledTextCtrl(self, wx.NewId())

        self.StartTime = time.time()
        self.Counter = 0
        self.Interval = 5  # interval in seconds
        # now set up the timer:
        self.Timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.Timer.Start(500)
Beispiel #18
0
 def load_settings_widgets(self, event=None):
     global config
     self.settings_win = wx.Frame(self, title="Settings")
     self.settings_editor = stc.StyledTextCtrl(
         self.settings_win, wx.ID_ANY, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
     Highlighter.yaml(editor=self.settings_editor)
     config = yaml.load(open("./user_config.yml"))
     self.settings_editor.SetValue(open("./user_config.yml").read())
     self.settings_editor.SetViewWhiteSpace(False)
     self.settings_editor.SetMargins(50, 50)
     self.settings_editor.SetMarginType(2, stc.STC_MARGIN_NUMBER)
     self.settings_editor.SetMarginWidth(2, 35)
     self.settings_editor.SetMarginLeft(10)
Beispiel #19
0
    def test_stcStyleTextCtrl6(self):
        ed = stc.StyledTextCtrl(self.frame)
        ed.SetText(text)
        ed.EmptyUndoBuffer()
        ed.GotoPos(10)

        textbytes = ed.GetStyledText(100,150)
        self.assertTrue(isinstance(textbytes, memoryview))
        
        pointer = ed.GetCharacterPointer()
        self.assertTrue(isinstance(pointer, memoryview))
        
        line, pos = ed.GetCurLine()
        self.assertTrue(len(line) != 0)
        self.assertTrue(isinstance(pos, int))
Beispiel #20
0
 def createTextCtrl(self):
     textCtrl = stc.StyledTextCtrl(self,
                                   wx.ID_ANY,
                                   size=(250, 250),
                                   style=wx.SIMPLE_BORDER)
     # Define the context menu
     textCtrl.UsePopUp(0)
     self.idInsertFrame = wx.NewId()
     self.idGetStatusText = wx.NewId()
     self.idToggleScrapWindow = wx.NewId()
     menuInfo = (
         (_('Undo') + '\tCtrl+Z', lambda event: textCtrl.Undo(), wx.ID_ANY),
         (_('Redo') + '\tCtrl+Y', lambda event: textCtrl.Redo(), wx.ID_ANY),
         (''),
         (_('Cut') + '\tCtrl+X', lambda event: textCtrl.Cut(), wx.ID_ANY),
         (_('Copy') + '\tCtrl+C', lambda event: textCtrl.Copy(), wx.ID_ANY),
         (_('Paste') + '\tCtrl+V', lambda event: textCtrl.Paste(),
          wx.ID_ANY),
         (''),
         (_('Select all') + '\tCtrl+A', lambda event: textCtrl.SelectAll(),
          wx.ID_ANY),
         (''),
         (_('Refresh'), self.OnRefresh, wx.ID_ANY),
         (_('Insert frame #'), self.OnInsertFrameNumber,
          self.idInsertFrame),
         (_('Save to file...'), self.OnSave, wx.ID_SAVE),
         (_('Clear all'), self.OnClearAll, wx.ID_ANY),
         (_('Toggle scrap window'), self.OnToggleScrapWindow,
          self.idToggleScrapWindow),
     )
     self.contextMenu = menu = wx.Menu()
     for eachMenuInfo in menuInfo:
         # Define optional arguments
         if not eachMenuInfo:
             menu.AppendSeparator()
         else:
             label = eachMenuInfo[0]
             handler = eachMenuInfo[1]
             status = ''
             id = eachMenuInfo[2]
             menuItem = menu.Append(id, label, status)
             textCtrl.Bind(wx.EVT_MENU, handler, menuItem)
     textCtrl.contextMenu = menu
     textCtrl.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)
     # Misc properties
     textCtrl.SetMarginWidth(1, 0)
     textCtrl.SetEOLMode(stc.STC_EOL_LF)
     return textCtrl
Beispiel #21
0
    def test_stcStyleTextCtrl2(self):
        ed = stc.StyledTextCtrl(self.frame)
        ed.SetText(text)
        ed.EmptyUndoBuffer()
        ed.GotoPos(0)

        ed.IndicatorSetStyle(0, stc.STC_INDIC_SQUIGGLE)
        ed.IndicatorSetForeground(0, wx.RED)
        ed.IndicatorSetStyle(1, stc.STC_INDIC_DIAGONAL)
        ed.IndicatorSetForeground(1, wx.BLUE)
        ed.IndicatorSetStyle(2, stc.STC_INDIC_STRIKE)
        ed.IndicatorSetForeground(2, wx.RED)    
        ed.StartStyling(100, stc.STC_INDICS_MASK)
        ed.SetStyling(10, stc.STC_INDIC0_MASK)
        ed.SetStyling(8, stc.STC_INDIC1_MASK)
        ed.SetStyling(10, stc.STC_INDIC2_MASK | stc.STC_INDIC1_MASK)
Beispiel #22
0
 def test_stcStyleTextCtrl1(self):
     ed = stc.StyledTextCtrl(self.frame)
     ed.SetText(text)
     ed.EmptyUndoBuffer()
     ed.GotoPos(0)
     
     ed.SetMarginType(1, stc.STC_MARGIN_SYMBOL)
     ed.MarkerDefine(0, stc.STC_MARK_ROUNDRECT, "#CCFF00", "RED")
     ed.MarkerDefine(1, stc.STC_MARK_CIRCLE, "FOREST GREEN", "SIENNA")
     ed.MarkerDefine(2, stc.STC_MARK_SHORTARROW, "blue", "blue")
     ed.MarkerDefine(3, stc.STC_MARK_ARROW, "#00FF00", "#00FF00")
     ed.MarkerAdd(1, 0)
     ed.MarkerAdd(2, 1)
     ed.MarkerAdd(3, 2)
     ed.MarkerAdd(4, 3)
     ed.MarkerAdd(5, 0)
Beispiel #23
0
    def __init__(self, parent, title):
        # Filename and Directory name
        self.filename = ''
        self.dirname = ''

        # Transparent
        self.transparent = False

        # View Indentation Guides
        self.viewindentationguides = False

        # View Whitespace
        self.viewwhitespace = False

        # Always on Top
        self.alwaysontop = False

        # Line numbers enabled
        self.lineNumbersEnabled = True

        # View EOL's
        self.vieweol = False

        # Find variables
        self.pos = 0
        self.size = 0

        # Lexer
        self.lexer = "Normal Text"

        # Window
        wx.Frame.__init__(self, parent, title=title, size=(805, 645))
        self.control = stc.StyledTextCtrl(self, style=wx.TE_MULTILINE | wx.TE_WORDWRAP | wx.TE_RICH2)
        icon = wx.Icon()
        icon.CopyFromBitmap(wx.Bitmap("icons/favicon.png", wx.BITMAP_TYPE_ANY))
        self.ShowFullScreen(False)
        self.SetIcon(icon)
        self.SetupFunctions()

        self.control.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:Courier New")

        self.control.SetZoom(2)

        self.control.SetCaretLineBackground((241, 246, 250))
        self.control.SetCaretLineVisible(True)

        self.control.Bind(stc.EVT_STC_UPDATEUI, self.Scroll)
Beispiel #24
0
    def load_widgets(self):

        self.notebook = Notebook_Widget.FlatNotebook(self, wx.ID_ANY)

        self.notebook.SetAGWWindowStyleFlag(Notebook_Widget.FNB_NO_X_BUTTON)
        self.notebook.SetAGWWindowStyleFlag(Notebook_Widget.FNB_NO_NAV_BUTTONS)
        self.notebook.SetAGWWindowStyleFlag(Notebook_Widget.FNB_NODRAG)

        self.dirTree = wx.TreeCtrl(self.notebook, wx.ID_ANY,
                                   wx.DefaultPosition, wx.DefaultSize,
                                   wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT)
        self.dirTree.Bind(wx.EVT_TREE_SEL_CHANGED, self.updateEditorContent)
        self.updateDirTree()

        self.notebook.AddPage(self.dirTree, "Project")

        self.editor = stc.StyledTextCtrl(
            self.notebook, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
        self.editor.CmdKeyAssign(
            ord("+"), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
        self.editor.CmdKeyAssign(
            ord("-"), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
        self.editor.SetViewWhiteSpace(False)
        self.editor.SetMargins(50, 50)
        self.editor.SetMarginType(2, stc.STC_MARGIN_NUMBER)
        self.editor.SetMarginWidth(2, 35)
        self.editor.SetMarginLeft(10)
        # self.editor.SetMarginType(
        #     2, stc.STC_MARGIN_SYMBOL | stc.STC_MARGIN_NUMBER)
        # self.editor.SetMarginMask(2, stc.STC_MASK_FOLDERS)
        # self.editor.SetMarginSensitive(2, True)
        # self.editor.SetMarginWidth(2, 35)
        self.editor.SetProperty("fold", "1")
        self.editor.SetProperty("tab.timmy.whinge.level", "1")
        self.editor.SetEdgeMode(stc.STC_EDGE_BACKGROUND)
        self.editor.SetEdgeColumn(78)
        self.editor.Bind(wx.EVT_KEY_UP, self.editor_keyup)
        self.editor.SetValue("import __hello__")
        self.editor.SetIndent(4)
        self.editor.SetUseHorizontalScrollBar(False)

        Highlighter.python(editor=self.editor)
        self.file_ext = ".py"

        self.notebook.AddPage(self.editor, "Editor")
        self.notebook.SetSelection(1)
Beispiel #25
0
    def __init__(self, parent, title, output):
        wx.Frame.__init__(self, parent, title=title, size=(805, 645))
        self.control = stc.StyledTextCtrl(self, -1)
        icon = wx.Icon()
        icon.CopyFromBitmap(wx.Bitmap("icons/favicon.png", wx.BITMAP_TYPE_ANY))
        self.ShowFullScreen(False)
        self.SetIcon(icon)
        self.Margins()

        # self.control.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:Courier New")
        self.control.SetZoom(2)

        self.control.SetCaretLineBackground((241, 246, 250))
        self.control.SetCaretLineVisible(True)

        self.control.Bind(stc.EVT_STC_UPDATEUI, self.Scroll)
        self.control.SetValue(output)
        self.control.SetEditable(False)
Beispiel #26
0
    def getPage(self, word):
        if word == self.oldPage:
            self.fromToolbar = False
            return
        page_count = self.GetPageCount()
        for i in range(page_count):
            text = self.GetPageText(i)
            if text == word:
                self.oldPage = word
                if not self.fromToolbar:
                    self.sequence = self.sequence[0:self.seq_index + 1]
                    self.sequence.append(i)
                    self.seq_index = len(self.sequence) - 1
                    self.history_check()
                self.parent.setTitle(text)
                self.SetSelection(i)
                panel = self.GetPage(self.GetSelection())
                if not panel.isLoad:
                    panel.isLoad = True
                    panel.win = stc.StyledTextCtrl(panel, -1, size=panel.GetSize(), style=wx.BORDER_SUNKEN)
                    panel.win.SetUseHorizontalScrollBar(False)
                    panel.win.LoadFile(os.path.join(CeciliaLib.ensureNFD(DOC_PATH), word))
                    panel.win.SetMarginWidth(1, 0)
                    if self.searchKey is not None:
                        words = complete_words_from_str(panel.win.GetText(), self.searchKey)
                        _ed_set_style(panel.win, words)
                    else:
                        _ed_set_style(panel.win)
                    panel.win.SetSelectionEnd(0)

                    def OnPanelSize(evt, win=panel.win):
                        win.SetPosition((0, 0))
                        win.SetSize(evt.GetSize())

                    panel.Bind(wx.EVT_SIZE, OnPanelSize)
                self.fromToolbar = False
                return
        try:
            win = self.makePanel(CeciliaLib.getVar("currentCeciliaFile"))
            self.AddPage(win, word)
            self.getPage(word)
        except:
            pass
Beispiel #27
0
    def test_stcHasTextCtrlMethods(self):
        # Just ensure that the common TextCtrl methods are present. This is
        # done because the C++ class either derives from wxTextEntryBase
        # or from wxTextCtrlIface, but these classes are not part of the API
        # (and thus are not wrapped), so we have to kludge things.
        # See etg/_stc.py for details.

        t = stc.StyledTextCtrl(self.frame)
        t.Cut
        t.CanCut
        t.DiscardEdits
        t.GetDefaultStyle
        t.GetNumberOfLines
        t.GetStyle
        t.IsModified
        t.HitTest
        t.AppendText
        t.WriteText
        t.ChangeValue
Beispiel #28
0
    def __init__(self, parent, title):
        #Filename and Directory name
        self.filename = ''
        self.dirname = ''

        #Line numbers enabled
        self.lineNumbersEnabled = True

        #Sets left margins width to be
        self.leftMarginWidth = 25

        #Window
        wx.Frame.__init__(self, parent, title=title, size=(600, 400))
        self.control = stc.StyledTextCtrl(self,
                                          style=wx.TE_MULTILINE
                                          | wx.TE_WORDWRAP)
        icon = wx.Icon()
        icon.CopyFromBitmap(wx.Bitmap("favicon.png", wx.BITMAP_TYPE_ANY))
        self.SetIcon(icon)
        self.SetupFunctions()
Beispiel #29
0
 def New(self, name, reservedword, rw):
     """ open a new tab """
     self.onglet.append(wx.Panel(self, -1))
     self.AddPage(self.onglet[len(self.onglet) - 1], name)
     self.stcpage.append(
         stc.StyledTextCtrl(id=wx.NewId(),
                            name='stc',
                            parent=self.onglet[len(self.onglet) - 1],
                            size=(100, 100),
                            style=wx.SUNKEN_BORDER))
     self.SetSelection(len(self.onglet) - 1)
     self.stcpage[self.GetSelection()].Bind(stc.EVT_STC_MODIFIED,
                                            self.OnChange)
     self.stcpage[self.GetSelection()].Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
     self.stcpage[self.GetSelection()].Bind(wx.EVT_LEFT_UP, self.onclick)
     self.stcpage[self.GetSelection()].Bind(wx.EVT_RIGHT_UP, self.onclick)
     self.filename.append(os.getcwd() + "/" + name + ".pde")
     self.seteditorproperties(reservedword, rw)
     x, y = self.GetSize()
     self.stcpage[self.GetSelection()].SetSize((x, y - 20))
     self.editeur = self.stcpage[self.GetSelection()]
Beispiel #30
0
 def test_stcStyleTextCtrl3(self):
     ed = stc.StyledTextCtrl(self.frame)
     ed.SetText(text)
     ed.EmptyUndoBuffer()
     ed.GotoPos(0)
     
     ed.StyleSetSpec(stc.STC_STYLE_DEFAULT, "size:%d,face:%s" % (pb, face3))
     ed.StyleClearAll()
     ed.StyleSetSpec(1, "size:%d,bold,face:%s,fore:#0000FF" % (pb, face1))
     ed.StyleSetSpec(2, "face:%s,italic,fore:#FF0000,size:%d" % (face2, pb))
     ed.StyleSetSpec(3, "face:%s,bold,size:%d" % (face2, pb))
     ed.StyleSetSpec(4, "face:%s,size:%d" % (face1, pb-1))
     ed.StyleSetSpec(5, "back:#FFF0F0")
     ed.StartStyling(80, 0xff)
     ed.SetStyling(6, 1)    
     ed.StartStyling(100, 0xff)
     ed.SetStyling(20, 2)
     ed.StartStyling(180, 0xff)
     ed.SetStyling(4, 3)
     ed.SetStyling(2, 0)
     ed.SetStyling(10, 4)