示例#1
0
        def __init__(self, exctype=None, excvalue=None, tracebackobj=None,
                     parent=None, flags=QtCore.Qt.WindowFlags(0), **kwargs):

            super(QsciExceptionDialog, self).__init__(exctype, excvalue,
                                                      tracebackobj,
                                                      parent, flags, False,
                                                      **kwargs)

            self.groupboxVerticalLayout.removeWidget(self.tracebackTextEdit)
            self.tracebackTextEdit.setParent(None)
            del self.tracebackTextEdit

            self.tracebackTextEdit = Qsci.QsciScintilla()
            self.groupboxVerticalLayout.addWidget(self.tracebackTextEdit)

            self.tracebackTextEdit.setMarginLineNumbers(
                                        Qsci.QsciScintilla.NumberMargin, True)
            self.tracebackTextEdit.setMarginWidth(
                                        Qsci.QsciScintilla.NumberMargin, 30)

            lexer = Qsci.QsciLexerPython()
            self.tracebackTextEdit.setLexer(lexer)
            self.tracebackTextEdit.recolor()

            self.tracebackTextEdit.setReadOnly(True)

            self.tracebackGroupBox.toggled.connect(
                                            self.tracebackTextEdit.setVisible)

            if not self._excInfoSet():
                self.setExcInfo(*sys.exc_info())
            else:
                self._fill()
 def set_type(self):
     try:
         ext = self.file_name.split(".")[-1]
         print(ext)
     except:
         ext = ""
         self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self))
         pass
     if ext == "py":
         self.text_edit_field.setLexer(Qsci.QsciLexerPython(self))
         self.hide_web()
         print("type python")
     elif ext == "cpp" or ext == "c":
         self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self))
         self.hide_web()
         print("type cpp")
     elif ext == "html":
         self.text_edit_field.setLexer(Qsci.QsciLexerHTML(self))
         self.terminal.setHidden(True)
         self.browser = QWebView(self)
         self.browser.load(QUrl(self.file_name))
         self.browser.move(self.x_y[0] * 66, 30)
         self.browser.setFixedSize(self.x_y[0] * 0.33, self.x_y[1] - 20)
         self.browser.show()
         #self.browser.move(500,0)
         #self.setGeometry((self.screen.width()-self.wd+200)/2,0,self.wd,self.ht-50)
         #self.setFixedSize(self.wd+200,self.ht-50)
         print("type html")
示例#3
0
    def __init__(self, framework, tabWidget, showRequest, parent = None):
        QObject.__init__(self, parent)
        self.framework = framework
        QObject.connect(self, SIGNAL('destroyed(QObject*)'), self._destroyed)
        self.tabWidget = tabWidget
        self.showRequest = showRequest

        if self.showRequest:
            self.reqReqEdit_Tab = QWidget(self.tabWidget)
            self.tabWidget.addTab(self.reqReqEdit_Tab, 'Request')
            # TODO: must this hard-coded ?
            self.render_tab_index = 2
        else:
            self.render_tab_index = 1

        self.reqResEdit_Tab = QWidget(self.tabWidget)
        self.tabWidget.addTab(self.reqResEdit_Tab, 'Response')

        self.reqRenderView_Tab = QWidget(self.tabWidget)
        self.tabWidget.addTab(self.reqRenderView_Tab, 'Render')

        # TODO: a common utility method should be used to all scintilla stuff
        if self.showRequest:
            self.reqReqEdit_Layout = QVBoxLayout(self.reqReqEdit_Tab)
            self.reqReqEdit = Qsci.QsciScintilla(self.reqReqEdit_Tab)
            self.reqReqEdit.zoomTo(self.framework.get_zoom_size())
            self.reqReqEdit.setMarginLineNumbers(1, True)
            self.reqReqEdit.setMarginWidth(1, '1000')
            self.reqReqEdit.setWrapMode(1)
            self.reqReqEdit.setWrapVisualFlags(2, 1, 0)
            self.reqReqEdit_Layout.addWidget(self.reqReqEdit)

        self.reqResEdit_Layout = QVBoxLayout(self.reqResEdit_Tab)
        self.reqResEdit = Qsci.QsciScintilla(self.reqResEdit_Tab)
        self.reqResEdit.zoomTo(self.framework.get_zoom_size())
        self.reqResEdit.setMarginLineNumbers(1, True)
        self.reqResEdit.setMarginWidth(1, '1000')
        self.reqResEdit.setWrapMode(1)
        self.reqResEdit.setWrapVisualFlags(2, 1, 0)
        self.reqResEdit_Layout.addWidget(self.reqResEdit)

        self.reqRenderView_Layout = QVBoxLayout(self.reqRenderView_Tab)
        self.requesterPageFactory = StandardPageFactory(self.framework, None, self)
        self.reqRenderView = RenderingWebView(self.framework, self.requesterPageFactory, self.tabWidget)
        self.reqRenderView_Layout.addWidget(self.reqRenderView)

        self.request_url = None

        self.tabWidget.currentChanged.connect(self.do_render_apply)

        self.framework.subscribe_zoom_in(self.zoom_in_scintilla)
        self.framework.subscribe_zoom_out(self.zoom_out_scintilla)
示例#4
0
    def __init__(self, control, ui_control):
        print 'Initializing Scripts UI.'
        inLib.ModuleUI.__init__(self, control, ui_control, 'modules.scripts.scripts_design')

        self._runner = None

        self._ui.listWidgetFiles.dragEnterEvent = self._drag_enter_event
        self._ui.listWidgetFiles.dragMoveEvent = self._drag_move_event
        self._ui.listWidgetFiles.dropEvent = self._drop_event

        self._ui.listWidgetFiles.itemClicked.connect(self._on_file_clicked)
        self._ui.listWidgetFiles.itemActivated.connect(self.run)

        self._ui.pushButtonRun.clicked.connect(self.run)
        self._ui.pushButtonSave.clicked.connect(self._on_save_clicked)
        self._ui.pushButtonNew.clicked.connect(self.new)
        self._ui.pushButtonLoad.clicked.connect(self.loadFile)


        self._ui.scintillaScript = Qsci.QsciScintilla()
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setPointSize(10)
        self._ui.scintillaScript.setFont(font)
        self._ui.scintillaScript.setMarginsFont(font)
        fontmetrics = QtGui.QFontMetrics(font)
        self._ui.scintillaScript.setMarginWidth(0, fontmetrics.width("000"))
        self._ui.scintillaScript.setMarginLineNumbers(0, True)
        self._ui.scintillaScript.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)
        self._ui.scintillaScript.setCaretLineVisible(True)
        lexer = Qsci.QsciLexerPython()
        lexer.setDefaultFont(font)
        self._ui.scintillaScript.setLexer(lexer)
        self._ui.scintillaScript.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT,1,
                'Courier')
        self._ui.scintillaScript.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR,0)
        self._ui.scintillaScript.setTabWidth(4)
        self._ui.scintillaScript.setIndentationsUseTabs(False)
        self._ui.scintillaScript.setEolMode(Qsci.QsciScintilla.EolMode(Qsci.QsciScintilla.EolUnix))
        self._ui.gridLayout.addWidget(self._ui.scintillaScript, 1, 1)

        script_path = os.path.join(os.path.dirname(__file__), 'scripts')
        for element in os.listdir(script_path):
            element_path = os.path.join(script_path, element)
            if os.path.isfile(os.path.join(element_path)):
                if os.path.splitext(element_path)[1] == '.py':
                    self._add_filename(element_path)
示例#5
0
        def __init__(self, parent=None):
            """
            very similar to:
            https://stackoverflow.com/questions/40002373/qscintilla-based-text-editor-in-pyqt5-with-clickable-functions-and-variables
            """
            super(SimplePythonEditorWidget, self).__init__(parent)

            # Set the default font
            font = QFont()
            font.setFamily('Courier')
            font.setFixedPitch(True)
            font.setPointSize(10)
            self.setFont(font)
            self.setMarginsFont(font)
            self.set_font(font)

            self.setMarginLineNumbers(0, True)
            self.setMarginsBackgroundColor(QColor("#cccccc"))

            # Clickable margin 1 for showing markers
            self.setMarginSensitivity(1, True)
            if qt_version == 'pyqt4':
                self.connect(self,
                             QtCore.SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'),
                             self.on_margin_clicked)
            else:
                self.marginClicked.connect(self.on_margin_clicked)

            self.markerDefine(Qsci.QsciScintilla.RightArrow,
                              self.ARROW_MARKER_NUM)
            self.setMarkerBackgroundColor(QColor("#ee1111"),
                                          self.ARROW_MARKER_NUM)

            # Brace matching: enable for a brace immediately before or after
            # the current position
            self.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)

            # Current line visible with special background color
            self.setCaretLineVisible(True)
            self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

            # Set Python lexer
            # Set style for Python comments (style number 1) to a fixed-width
            # courier.
            lexer = Qsci.QsciLexerPython()
            lexer.setDefaultFont(font)
            self.setLexer(lexer)

            if qt_version == 'pyqt4':
                self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
            else:
                font_style = bytearray(str.encode("Courier"))
                self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, font_style)

            # Don't want to see the horizontal scrollbar at all
            # Use raw message to Scintilla here (all messages are documented
            # here: http://www.scintilla.org/ScintillaDoc.html)
            self.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)
示例#6
0
    def setupTextEditQuery(self):

        editor = self.textEditQuery
        scintilla = Qsci.QsciScintilla

        editor.setBackspaceUnindents(True)
        editor.setTabIndents(True)

        # Set the font
        self.font = QtGui.QFont()
        self.font.setFamily('terminus')
        self.font.setFixedPitch(True)
        self.font.setPointSize(11)
        editor.setFont(self.font)

        # Add line numbers
        self.font_metrics = QtGui.QFontMetrics(self.font)
        editor.setMarginsFont(self.font)
        editor.setMarginWidth(0, self.font_metrics.width('0000') + 5)
        editor.setMarginLineNumbers(0, True)

        # Add "maximum width" line
        editor.setEdgeMode(Qsci.QsciScintilla.EdgeLine)
        editor.setEdgeColumn(80)
        editor.setEdgeColor(QtGui.QColor(0xCCCCCC))

        # Add folding
        editor.setFolding(scintilla.BoxedTreeFoldStyle)

        # Highlight the matching brace
        editor.setBraceMatching(scintilla.SloppyBraceMatch)

        # Highlight our current line
        editor.setCaretLineVisible(True)
        editor.setCaretLineBackgroundColor(QtGui.QColor(0xE8F3FE))

        # Set the lexer to enable syntax highlighting
        self.lexer = Qsci.QsciLexerSQL(editor)
        self.lexer.setDefaultFont(self.font)
        editor.setLexer(self.lexer)

        # Create an autocompletion API
        self.api = psql_api.PSQLApi(self.lexer)

        # Autocompletion
        editor.setAutoIndent(True)
        editor.setCallTipsStyle(scintilla.CallTipsContext)
        editor.setAutoCompletionThreshold(1)
        editor.setAutoCompletionSource(scintilla.AcsAll)
        editor.setAutoCompletionFillupsEnabled(True)

        editor.setEolMode(scintilla.EolUnix)

        editor.setIndentationGuides(True)
        editor.setIndentationsUseTabs(False)
        editor.setTabIndents(True)
        editor.setTabWidth(4)
示例#7
0
    def set_document(self, document):
        """ Set the document on the underlying widget.

        """
        qdoc = self.qsci_doc_cache.get(document.uuid)
        if qdoc is None:
            qdoc = self.qsci_doc_cache[document.uuid] = Qsci.QsciDocument()
        self.qsci_doc = qdoc  # take a strong ref since PyQt doesn't
        self.widget.setDocument(qdoc)
示例#8
0
 def setScintillaProperties(self, scintillaWidget, contentType='html'):
     scintillaWidget.setFont(self.framework.get_font())
     scintillaWidget.setWrapMode(1)
     scintillaWidget.zoomTo(self.framework.get_zoom_size())
     # TOOD: set based on line numbers (size is in pixels)
     scintillaWidget.setMarginWidth(1, '1000')
     lexerInstance = Qsci.QsciLexerHTML(scintillaWidget)
     lexerInstance.setFont(self.framework.get_font())
     scintillaWidget.setLexer(lexerInstance)
     self.scintillaWidgets.add(scintillaWidget)
示例#9
0
    def __init__(self, parent=None):
        Qsci.QsciScintilla.__init__(self, parent)
        self.setLexer(Qsci.QsciLexerXML())
        self.text_object = TextObject("")
        self.highlight_index = self.indicatorDefine(self.RoundBoxIndicator, -1)
        self.setIndicatorDrawUnder(True, self.highlight_index)
        self.setIndicatorForegroundColor(QtGui.QColor("#dddddd"),
                                         self.highlight_index)

        self.orig_text = self.text_object.orig_text
示例#10
0
    def __init__(self, parent=None):
        Qsci.QsciScintilla.__init__(self, parent)

        self.lex = Qsci.QsciLexerPython()
        self.setLexer(self.lex)
        for i in range(5):
            self.setMarginWidth(i, 0)

        # Set Dark Color
        style_obj = set(styleD.keys()).intersection(dir(self.lex))
        self.setCaretForegroundColor(QtGui.QColor(255, 255, 255))
        shade = 30
        self.setCaretLineBackgroundColor(QtGui.QColor(shade, shade, shade))
        self.lex.setDefaultPaper(QtGui.QColor(shade, shade, shade))
        self.lex.setPaper(QtGui.QColor(shade, shade, shade), self.lex.Default)
        self.setColor(QtGui.QColor(255, 255, 255))
        self.setMarginsBackgroundColor(QtGui.QColor(60, 60, 60))
        self.setWhitespaceBackgroundColor(QtGui.QColor(80, 80, 80))
        self.setFoldMarginColors(QtGui.QColor(200, 200, 200),
                                 QtGui.QColor(90, 90, 90))
        ##            self.ui.te_sci.setPaper(QColor(80,80,80))
        self.setMarginsForegroundColor(QtGui.QColor(200, 200, 200))
        ##            self.ui.te_sci.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETBACK,Qsci.QsciScintilla.STYLE_DEFAULT,QColor(150,150,150))

        self.setMatchedBraceBackgroundColor(QtGui.QColor(shade, shade, shade))
        self.setMatchedBraceForegroundColor(QtGui.QColor(170, 0, 255))
        self.setUnmatchedBraceBackgroundColor(QtGui.QColor(
            shade, shade, shade))

        # Set defaults for all:
        style_obj = set(styleD.keys()).intersection(dir(self.lex))
        style_obj.remove('Default')
        style_obj = set(['Default']).union(sorted(style_obj))

        for c in sorted(style_obj, reverse=1):
            clr = styleD[c]
            if clr == '':
                clr = styleD['Default']
            try:
                exec('self.lex.setPaper(QtGui.QColor(30,30,30),self.lex.' + c +
                     ')')
                exec('self.lex.setColor(QtGui.QColor(' + clr + '),self.lex.' +
                     c + ')')
            except:
                print 'no keyword', c

        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Preferred)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setMaximumHeight(18)
        self.setStyleSheet('border:0px;')

        self.widgetObject = Qsci.QsciScintilla
        self.type = 'qscintilla'
示例#11
0
    def setup_functions_tab(self):
        self.functionsLayout = self.mainWindow.wfFunctionsEditPlaceholder.layout()
        if not self.functionsLayout:
            self.functionsLayout = QVBoxLayout(self.mainWindow.wfFunctionsEditPlaceholder)
        self.functionsEditScintilla = Qsci.QsciScintilla(self.mainWindow.wfFunctionsEditPlaceholder)

        ScintillaHelpers.SetScintillaProperties(self.framework, self.functionsEditScintilla, 'python')
        self.functionsEditScintilla.setAutoIndent(True)
        self.functionsLayout.addWidget(self.functionsEditScintilla)
        self.framework.subscribe_zoom_in(self.edit_function_zoom_in)
        self.framework.subscribe_zoom_out(self.edit_function_zoom_out)
示例#12
0
 def __init__(self):
     QtGui.QMainWindow.__init__(self)
     self.setWindowTitle('Custom Lexer Example')
     self.setGeometry(QtCore.QRect(50,200,400,400))
     self.editor = Qsci.QsciScintilla(self)
     self.editor.setUtf8(True)
     self.editor.setMarginWidth(2, 15)
     self.editor.setFolding(True)
     self.setCentralWidget(self.editor)
     self.lexer = CustomLexer(self.editor)
     self.editor.setLexer(self.lexer)
     self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n')
示例#13
0
    def __init__(self, parent):
        Qsci.QsciScintilla.__init__(self, parent)

        self.lexer = Qsci.QsciLexerSQL()
        self.lexer.setDefaultFont(self.font)
        self.lexer.setFont(self.font)
        self.setMarginsFont(self.font)

        fgColor = QtGui.QColor(190, 190, 190, 255)
        bgColor = QtGui.QColor(30, 36, 38, 255)
        black = QtGui.QColor(0, 0, 0, 255)
        comment = QtGui.QColor(101, 103, 99, 255)

        self.lexer.setDefaultColor(fgColor)
        self.lexer.setColor(fgColor, self.lexer.Default)
        self.lexer.setColor(comment, self.lexer.Comment)
        self.lexer.setColor(comment, self.lexer.CommentLine)
        self.lexer.setColor(comment, self.lexer.CommentDoc)
        self.lexer.setColor(QtGui.QColor(204, 33, 33, 255), self.lexer.Number)
        self.lexer.setColor(QtGui.QColor(114, 160, 207, 255), self.lexer.Keyword)
        self.lexer.setColor(QtGui.QColor(139, 226, 51, 255), self.lexer.DoubleQuotedString)
        self.lexer.setColor(QtGui.QColor(139, 226, 51, 255), self.lexer.SingleQuotedString)
        self.lexer.setColor(QtGui.QColor(252, 163, 61, 255), self.lexer.PlusKeyword)
        self.lexer.setColor(fgColor, self.lexer.Operator)
        self.lexer.setColor(fgColor, self.lexer.Identifier)
        self.lexer.setColor(comment, self.lexer.PlusComment)
        self.lexer.setColor(comment, self.lexer.CommentLineHash)
        self.lexer.setColor(comment, self.lexer.CommentDocKeyword)
        self.lexer.setColor(comment, self.lexer.CommentDocKeywordError)
        self.lexer.setPaper(bgColor)
        self.lexer.setDefaultPaper(bgColor)

        self.setCaretForegroundColor(fgColor)
        self.setSelectionBackgroundColor(black)
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor(44, 53, 56, 255))
        self.setMarginsForegroundColor(bgColor)
        self.setMarginsBackgroundColor(black)
        self.setMatchedBraceForegroundColor(fgColor)
        self.setMatchedBraceBackgroundColor(QtGui.QColor(89, 71, 47, 255))

        self.setAutoIndent(True)
        self.setFolding(Qsci.QsciScintilla.NoFoldStyle)
        self.setWrapMode(Qsci.QsciScintilla.WrapWord)
        self.setMarginWidth(0, 30)
        self.setMarginLineNumbers(0, True)
        self.setBraceMatching(self.SloppyBraceMatch)

        self.setLexer(self.lexer)
        self.setUtf8(True)

        self.filename = None
示例#14
0
    def __init__(self):

        Qsci.QsciScintilla.__init__(self)
        
        # Set the default font
        font = QtGui.QFont()
        font.setFamily('Courier') #Monospace
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)
        
        # Margin 0 is used for line numbers 
        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("0000"))
        self.setMarginLineNumbers(10, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#cccccc"))

        
        ################################################
        self.setWhitespaceVisibility(self.WsVisible)
        ################################################

        
        # same-line brace matching....
        self.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)
        
        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor("#99ccff"))
        
        # Choosing a lexer (syntax highlighting)
        lexer = Qsci.QsciLexerCPP() # C++ lexer
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
        
        self.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTH, 10)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTHTRACKING, 1)
        
        # not too small
        self.setMinimumSize(200, 200)


        ###################################################################

        # set vertical line at character 80 
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QtGui.QColor("#3333ff"))
示例#15
0
        def __init__(self, parent=None):
            super(SimplePythonEditorWidget, self).__init__(parent)

            # Set the default font
            font = QFont()
            font.setFamily('Courier')
            font.setFixedPitch(True)
            font.setPointSize(10)
            self.setFont(font)
            self.setMarginsFont(font)

            # Margin 0 is used for line numbers
            fontmetrics = QFontMetrics(font)
            self.setMarginsFont(font)
            self.setMarginWidth(0, fontmetrics.width("00000") + 6)
            self.setMarginLineNumbers(0, True)
            self.setMarginsBackgroundColor(QColor("#cccccc"))

            # Clickable margin 1 for showing markers
            self.setMarginSensitivity(1, True)
            self.connect(
                self,
                QtCore.SIGNAL(
                    'marginClicked(int, int, Qt::KeyboardModifiers)'),
                self.on_margin_clicked)
            self.markerDefine(Qsci.QsciScintilla.RightArrow,
                              self.ARROW_MARKER_NUM)
            self.setMarkerBackgroundColor(QColor("#ee1111"),
                                          self.ARROW_MARKER_NUM)

            # Brace matching: enable for a brace immediately before or after
            # the current position
            self.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)

            # Current line visible with special background color
            self.setCaretLineVisible(True)
            self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

            # Set Python lexer
            # Set style for Python comments (style number 1) to a fixed-width
            # courier.
            lexer = Qsci.QsciLexerPython()
            lexer.setDefaultFont(font)
            self.setLexer(lexer)
            self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1,
                               'Courier')

            # Don't want to see the horizontal scrollbar at all
            # Use raw message to Scintilla here (all messages are documented
            # here: http://www.scintilla.org/ScintillaDoc.html)
            self.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)
示例#16
0
def SetScintillaProperties(framework, scintillaWidget, contentType='html'):
    lexerInstance = None
    font = framework.get_font()
    if 'html' == contentType:
        lexerInstance = Qsci.QsciLexerHTML(scintillaWidget)
    elif 'javascript' == contentType:
        lexerInstance = Qsci.QsciLexerJavaScript(scintillaWidget)
    elif 'python' == contentType:
        lexerInstance = Qsci.QsciLexerPython(scintillaWidget)
        font = framework.get_python_code_font()
    elif contentType in ('hex', 'monospace'):
        font = framework.get_monospace_font()
    else:
        pass

    scintillaWidget.setFont(font)
    scintillaWidget.setWrapMode(1)
    scintillaWidget.zoomTo(framework.get_zoom_size())
    # TOOD: set based on line numbers (size is in pixels)
    scintillaWidget.setMarginWidth(1, '1000')
    if lexerInstance is not None:
        lexerInstance.setFont(font)
        scintillaWidget.setLexer(lexerInstance)
示例#17
0
 def __init__(self, parent):
     WidgetBase.__init__(self, parent)
     self.parent = parent
     self.setupUi(self)
     #Event handlers#
     self.bt_python_run.clicked.connect(self.onPythonCommand)
     # Setup namespaces etc, log stufff.
     self.logPython("Python version:\n" + sys.version, color="green")
     self.logPython("TrLib version:\n" + TrLib.GetVersion(), color="green")
     namespace = {"loadPlugins": parent.loadPlugins, "mainWindow": parent}
     self.logPython("Handle to main window %s stored in name: mainWindow" %
                    repr(parent.__class__),
                    color="brown")
     self.python_console = EmbedPython.PythonConsole(namespace)
     self.python_console.executeCode("from TrLib import *")
     self.logPython(
         "from TrLib import *  - Loading namespace from TrLib.py",
         color="brown")
     self.logPython("Type 'example' to run example code", color="blue")
     self.logPython("Type 'clear' to clear output field", color="blue")
     # Determine what type the input text field should be and setup its
     # event handler....
     if HAS_QSCI:
         self.txt_python_in = Qsci.QsciScintilla(self)
         self.txt_python_in.setLexer(Qsci.QsciLexerPython())
         self.txt_python_in.setAutoIndent(True)
     else:
         self.txt_python_in = QTextEdit(self)
     self.layout().addWidget(self.txt_python_in)
     self.txt_python_in.keyPressEvent = self.onPythonKey
     if not HAS_QSCI:
         self.logPython(
             "Qscintilla not installed. Python input lexer will not work...",
             color="red")
     self.python_console.clearCache()
     self.txt_python_in.setWhatsThis("Enter/edit input python code here")
示例#18
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setupUi(self)
        self.stdout = sys.stdout
        self.stderr = sys.stderr
        self.connect(self.btnClose, QtCore.SIGNAL('clicked()'), self.close)
        self.connect(self.btnCopy, QtCore.SIGNAL('clicked()'), self._copy)
        self.sysout = SysOut(self.sci)

        self.PLX = Qsci.QsciLexerPython(self)
        self.ABS = Qsci.QsciAPIs(self.PLX)
        self.PLX.setAPIs(self.ABS)

        self.sci.setAutoCompletionSource(Qsci.QsciScintilla.AcsAll)
        self.sci.setLexer(self.PLX)
        self.sci.setAutoCompletionThreshold(1)
        self.sci.setAutoIndent(True)
        self.sci.setAutoCompletionFillupsEnabled(True)
        self.sci.setBraceMatching(Qsci.QsciScintilla.StrictBraceMatch)
        self.sci.setMarginWidth(1, 0)
        self.sci.setReadOnly(1)
        print '*** Python %s on %s.***' % (sys.version, sys.platform)

        self.btnCopy.setEnabled(0)
示例#19
0
文件: settings.py 项目: rkyleg/scope
    def __init__(self, parent=None, pth=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.IDE = parent

        # Add Ace editor
        if 'ace' in self.IDE.editorD:
            import plugins.ace.ace
            self.ui.te_json = plugins.ace.ace.WebView(self.IDE, lang='json')
        else:
            # Add Scintilla
            import plugins.scintilla.scintilla
            self.ui.te_json = plugins.scintilla.scintilla.Sci(
                self.IDE, Qsci.QsciLexerJavaScript(), lang='json')

        self.ui.fr_json.layout().addWidget(self.ui.te_json)

        # Setup Plugins file
        if not os.path.exists(
                os.path.join(self.IDE.settingPath, 'plugins.json')):
            import shutil
            shutil.copyfile(
                os.path.abspath(os.path.dirname(__file__)) + '/plugins.json',
                os.path.join(self.IDE.settingPath, 'plugins.json'))

        self.ui.split_v.setSizes([self.IDE.width() / 2, self.IDE.width() / 2])
        self.ui.split_h.setSizes(
            [self.IDE.height() / 2,
             self.IDE.height() / 2])

        self.ui.fr_plugins.hide()

        # Signals
        self.ui.li_catg.currentRowChanged.connect(self.catg_change)
        self.ui.b_save_json.clicked.connect(self.save_json)

        self.ui.tr_plugins.itemDoubleClicked.connect(self.plugin_dclick)
        self.ui.b_plugin_file_add.clicked.connect(self.plugin_add_file)
        self.ui.b_plugin_url_add.clicked.connect(self.plugin_add_url)
        self.ui.b_plugin_manual_add.clicked.connect(self.plugin_add_manual)

        self.ui.tr_plugins.itemSelectionChanged.connect(self.plugin_select)

        self.ui.li_catg.setCurrentRow(0)
示例#20
0
    def set_autocompletions(self, options):
        """ Set the autocompletion options for when the autocompletion mode
        is in 'all' or 'apis'.
            
        """
        # Delete the old if one exists
        if self.qsci_api:
            # Please note that it is not possible to add or remove entries
            # once you’ve “prepared” so we have to destroy and create
            # a new provider every time.
            self.qsci_api.deleteLater()
            self.qsci_api = None

        # Add the new options
        api = self.qsci_api = Qsci.QsciAPIs(self.widget.lexer())
        for option in options:
            api.add(option)
        api.prepare()
示例#21
0
    def populate_response_content(self, url, req_headers, req_body, res_headers, res_body, res_content_type = ''):
            
        self.request_url = url
        self.request_headers = req_headers
        self.request_body = req_body
        self.response_headers = res_headers
        self.response_body = res_body
        self.response_content_type = res_content_type

        if self.showRequest:
            self.reqReqEdit.setText(ContentHelper.getCombinedText(self.request_headers, self.request_body, ''))

        # TODO: should support different lexers based on content type
        lexerInstance = Qsci.QsciLexerHTML(self.reqResEdit)
        lexerInstance.setFont(self.framework.get_font())
        self.reqResEdit.setLexer(lexerInstance)
        # TODO: should verify trailing newlines?
        self.reqResEdit.setText(ContentHelper.getCombinedText(self.response_headers, self.response_body, self.response_content_type))

        self.do_render_apply(self.tabWidget.currentIndex())
示例#22
0
    def init_ui(self):

        self.setGeometry(0, 0, self.width, self.height)

        self.setWindowTitle("OmegaIDE")
        self.text = Editor(Qsci.QsciLexerPython(self))
        self.text.cursorPositionChanged.connect(self.show_cursor_pos)

        self.setCentralWidget(self.text)

        self.init_file_manager()

        self.init_toolbar()

        self.init_menubar()
        self.init_status_bar()

        self.status_bar = self.statusBar()
        self.status_bar_text = QtGui.QLabel()
        self.status_bar_text.setText("")
        self.status_bar.addWidget(self.status_bar_text)
示例#23
0
文件: EncoderTab.py 项目: xtenex/raft
    def make_text_hex_tab(self, currentWidget):

        thisTabWidget = currentWidget

        textTab = QWidget(thisTabWidget)
        thisTabWidget.addTab(textTab, 'Text')
        hexTab = QWidget(thisTabWidget)
        thisTabWidget.addTab(hexTab, 'Hex')

        vlayout_text = QVBoxLayout(textTab)
        thisTextEdit = QTextEdit(textTab)
        vlayout_text.addWidget(thisTextEdit)

        vlayout_hex = QVBoxLayout(hexTab)
        thisHexEdit = Qsci.QsciScintilla(hexTab)
        ScintillaHelpers.SetScintillaProperties(self.framework, thisHexEdit,
                                                'monospace')

        vlayout_hex.addWidget(thisHexEdit)

        return (thisTextEdit, thisHexEdit)
示例#24
0
    def __init__(self, parent):
        Qsci.QsciScintilla.__init__(self)

        # Set the default font
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        # Margin 0 is used for line numbers

        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("0000"))
        self.setMarginLineNumbers(10, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#cccccc"))

        self.setWhitespaceVisibility(self.WsVisible)

        self.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor("#ffe4e4"))

        lexer = Qsci.QsciLexerCPP()
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        self.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTH, 10)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTHTRACKING, 1)

        # not too small
        self.setMinimumSize(200, 200)
示例#25
0
    def initialize(self, *args, **kwargs):
        " Init Main Class "
        super(Main, self).initialize(*args, **kwargs)
        self.scriptPath, self.scriptArgs = "", []
        self.profilerPath, self.tempPath = profilerPath, tempPath
        self.output = " ERROR: FAIL: No output ! "

        self.process = QProcess()
        self.process.finished.connect(self.on_process_finished)
        self.process.error.connect(self.on_process_error)

        self.tabWidget, self.stat = QTabWidget(), QWidget()
        self.tabWidget.tabCloseRequested.connect(
            lambda: self.tabWidget.setTabPosition(1) if self.tabWidget.
            tabPosition() == 0 else self.tabWidget.setTabPosition(0))
        self.tabWidget.setStyleSheet('QTabBar{font-weight:bold;}')
        self.tabWidget.setMovable(True)
        self.tabWidget.setTabsClosable(True)
        self.vboxlayout1 = QVBoxLayout(self.stat)
        self.hboxlayout1 = QHBoxLayout()
        self.filterTableLabel = QLabel("<b>Type to Search : </b>", self.stat)
        self.hboxlayout1.addWidget(self.filterTableLabel)
        self.filterTableLineEdit = QLineEdit(self.stat)
        self.filterTableLineEdit.setPlaceholderText(' Type to Search . . . ')
        self.hboxlayout1.addWidget(self.filterTableLineEdit)
        self.filterHintTableLabel = QLabel(" ? ", self.stat)
        self.hboxlayout1.addWidget(self.filterHintTableLabel)
        self.vboxlayout1.addLayout(self.hboxlayout1)
        self.tableWidget = QTableWidget(self.stat)
        self.tableWidget.setAlternatingRowColors(True)
        self.tableWidget.setColumnCount(8)
        self.tableWidget.setRowCount(2)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(4, item)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(5, item)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(6, item)
        item = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(7, item)
        self.tableWidget.itemDoubleClicked.connect(
            self.on_tableWidget_itemDoubleClicked)
        self.vboxlayout1.addWidget(self.tableWidget)
        self.tabWidget.addTab(self.stat, " ? ")

        self.source = QWidget()
        self.gridlayout = QGridLayout(self.source)
        self.scintillaWarningLabel = QLabel(
            "QScintilla is not installed!. Falling back to basic text edit!.",
            self.source)
        self.gridlayout.addWidget(self.scintillaWarningLabel, 1, 0, 1, 2)
        self.sourceTreeWidget = QTreeWidget(self.source)
        self.sourceTreeWidget.setAlternatingRowColors(True)
        self.sourceTreeWidget.itemActivated.connect(
            self.on_sourceTreeWidget_itemActivated)
        self.sourceTreeWidget.itemClicked.connect(
            self.on_sourceTreeWidget_itemClicked)
        self.sourceTreeWidget.itemDoubleClicked.connect(
            self.on_sourceTreeWidget_itemClicked)

        self.gridlayout.addWidget(self.sourceTreeWidget, 0, 0, 1, 1)
        self.sourceTextEdit = QTextEdit(self.source)
        self.sourceTextEdit.setReadOnly(True)
        self.gridlayout.addWidget(self.sourceTextEdit, 0, 1, 1, 1)
        self.tabWidget.addTab(self.source, " ? ")

        self.result = QWidget()
        self.vlayout = QVBoxLayout(self.result)
        self.globalStatGroupBox = QGroupBox(self.result)
        self.hboxlayout = QHBoxLayout(self.globalStatGroupBox)
        self.totalTimeLcdNumber = QLCDNumber(self.globalStatGroupBox)
        self.totalTimeLcdNumber.setSegmentStyle(QLCDNumber.Filled)
        self.totalTimeLcdNumber.setNumDigits(7)
        self.totalTimeLcdNumber.display(1000000)
        self.totalTimeLcdNumber.setFrameShape(QFrame.StyledPanel)
        self.totalTimeLcdNumber.setSizePolicy(QSizePolicy.Expanding,
                                              QSizePolicy.Expanding)
        self.hboxlayout.addWidget(self.totalTimeLcdNumber)
        self.tTimeLabel = QLabel("<b>Total Time (Sec)</b>",
                                 self.globalStatGroupBox)
        self.tTimeLabel.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        self.hboxlayout.addWidget(self.tTimeLabel)
        self.numCallLcdNumber = QLCDNumber(self.globalStatGroupBox)
        self.numCallLcdNumber.setNumDigits(7)
        self.numCallLcdNumber.display(1000000)
        self.numCallLcdNumber.setSegmentStyle(QLCDNumber.Filled)
        self.numCallLcdNumber.setFrameShape(QFrame.StyledPanel)
        self.numCallLcdNumber.setSizePolicy(QSizePolicy.Expanding,
                                            QSizePolicy.Expanding)
        self.hboxlayout.addWidget(self.numCallLcdNumber)
        self.numCallLabel = QLabel("<b>Number of calls</b>",
                                   self.globalStatGroupBox)
        self.numCallLabel.setSizePolicy(QSizePolicy.Minimum,
                                        QSizePolicy.Minimum)
        self.hboxlayout.addWidget(self.numCallLabel)
        self.primCallLcdNumber = QLCDNumber(self.globalStatGroupBox)
        self.primCallLcdNumber.setSegmentStyle(QLCDNumber.Filled)
        self.primCallLcdNumber.setFrameShape(QFrame.StyledPanel)
        self.primCallLcdNumber.setNumDigits(7)
        self.primCallLcdNumber.display(1000000)
        self.primCallLcdNumber.setSizePolicy(QSizePolicy.Expanding,
                                             QSizePolicy.Expanding)
        self.hboxlayout.addWidget(self.primCallLcdNumber)
        self.primCallLabel = QLabel("<b>Primitive calls (%)</b>",
                                    self.globalStatGroupBox)
        self.primCallLabel.setSizePolicy(QSizePolicy.Minimum,
                                         QSizePolicy.Minimum)
        self.hboxlayout.addWidget(self.primCallLabel)
        self.vlayout.addWidget(self.globalStatGroupBox)
        try:
            from PyKDE4.kdeui import KRatingWidget
            self.rating = KRatingWidget(self.globalStatGroupBox)
            self.rating.setToolTip('Profiling Performance Rating')
        except ImportError:
            pass
        self.tabWidget.addTab(self.result, " Get Results ! ")

        self.resgraph = QWidget()
        self.vlayout2 = QVBoxLayout(self.result)
        self.graphz = QGroupBox(self.resgraph)
        self.hboxlayout2 = QHBoxLayout(self.graphz)
        try:
            from PyKDE4.kdeui import KLed
            KLed(self.graphz)
        except ImportError:
            pass
        self.hboxlayout2.addWidget(
            QLabel('''
            Work in Progress  :)  Not Ready Yet'''))
        self.vlayout2.addWidget(self.graphz)
        self.tabWidget.addTab(self.resgraph, " Graphs and Charts ")

        self.pathz = QWidget()
        self.vlayout3 = QVBoxLayout(self.pathz)
        self.patz = QGroupBox(self.pathz)
        self.hboxlayout3 = QVBoxLayout(self.patz)
        self.profilepath = QLineEdit(profilerPath)
        self.getprofile = QPushButton(QIcon.fromTheme("document-open"), 'Open')
        self.getprofile.setToolTip(
            'Dont touch if you dont know what are doing')
        self.getprofile.clicked.connect(lambda: self.profilepath.setText(
            str(
                QFileDialog.getOpenFileName(
                    self.patz, ' Open the profile.py file ',
                    path.expanduser("~"), ';;(profile.py)'))))
        self.hboxlayout3.addWidget(
            QLabel(
                '<center><b>Profile.py Python Library Full Path:</b></center>')
        )
        self.hboxlayout3.addWidget(self.profilepath)
        self.hboxlayout3.addWidget(self.getprofile)

        self.argGroupBox = QGroupBox(self.pathz)
        self.hbxlayout = QHBoxLayout(self.argGroupBox)
        self.argLineEdit = QLineEdit(self.argGroupBox)
        self.argLineEdit.setToolTip(
            'Not touch if you dont know what are doing')
        self.argLineEdit.setPlaceholderText(
            'Dont touch if you dont know what are doing')
        self.hbxlayout.addWidget(
            QLabel('<b>Additional Profile Arguments:</b>'))
        self.hbxlayout.addWidget(self.argLineEdit)
        self.hboxlayout3.addWidget(self.argGroupBox)

        self.vlayout3.addWidget(self.patz)
        self.tabWidget.addTab(self.pathz, " Paths and Configs ")

        self.outp = QWidget()
        self.vlayout4 = QVBoxLayout(self.outp)
        self.outgro = QGroupBox(self.outp)
        self.outgro.setTitle(" MultiProcessing Output Logs ")
        self.hboxlayout4 = QVBoxLayout(self.outgro)
        self.outputlog = QTextEdit()
        self.outputlog.setText('''
        I do not fear computers, I fear the lack of them.   -Isaac Asimov ''')
        self.hboxlayout4.addWidget(self.outputlog)
        self.vlayout4.addWidget(self.outgro)
        self.tabWidget.addTab(self.outp, " Logs ")

        self.actionNew_profiling = QAction(QIcon.fromTheme("document-new"),
                                           'New Profiling', self)
        self.actionLoad_profile = QAction(QIcon.fromTheme("document-open"),
                                          'Open Profiling', self)
        self.actionClean = QAction(QIcon.fromTheme("edit-clear"), 'Clean',
                                   self)
        self.actionClean.triggered.connect(lambda: self.clearContent)
        self.actionAbout = QAction(QIcon.fromTheme("help-about"), 'About',
                                   self)
        self.actionAbout.triggered.connect(lambda: QMessageBox.about(
            self.dock, __doc__, ', '.join(
                (__doc__, __license__, __author__, __email__))))
        self.actionSave_profile = QAction(QIcon.fromTheme("document-save"),
                                          'Save Profiling', self)
        self.actionManual = QAction(QIcon.fromTheme("help-contents"), 'Help',
                                    self)
        self.actionManual.triggered.connect(lambda: open_new_tab(
            'http://docs.python.org/library/profile.html'))

        self.tabWidget.setCurrentIndex(2)

        self.globalStatGroupBox.setTitle("Global Statistics")
        item = self.tableWidget.horizontalHeaderItem(0)
        item.setText("Number of Calls")
        item = self.tableWidget.horizontalHeaderItem(1)
        item.setText("Total Time")
        item = self.tableWidget.horizontalHeaderItem(2)
        item.setText("Per Call")
        item = self.tableWidget.horizontalHeaderItem(3)
        item.setText("Cumulative Time")
        item = self.tableWidget.horizontalHeaderItem(4)
        item.setText("Per Call")
        item = self.tableWidget.horizontalHeaderItem(5)
        item.setText("Filename")
        item = self.tableWidget.horizontalHeaderItem(6)
        item.setText("Line")
        item = self.tableWidget.horizontalHeaderItem(7)
        item.setText("Function")
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.stat),
                                  "Statistics per Function")

        self.sourceTreeWidget.headerItem().setText(0, "Source files")
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.source),
                                  "Sources Navigator")
        #######################################################################

        self.scrollable, self.dock = QScrollArea(), QDockWidget()
        self.scrollable.setWidgetResizable(True)
        self.scrollable.setWidget(self.tabWidget)
        self.dock.setWindowTitle(__doc__)
        self.dock.setStyleSheet('QDockWidget::title{text-align: center;}')
        self.dock.setWidget(self.scrollable)
        QToolBar(self.dock).addActions(
            (self.actionNew_profiling, self.actionClean,
             self.actionSave_profile, self.actionLoad_profile,
             self.actionManual, self.actionAbout))

        self.actionNew_profiling.triggered.connect(
            self.on_actionNew_profiling_triggered)
        self.actionLoad_profile.triggered.connect(
            self.on_actionLoad_profile_triggered)
        self.actionSave_profile.triggered.connect(
            self.on_actionSave_profile_triggered)

        self.locator.get_service('misc').add_widget(
            self.dock, QIcon.fromTheme("document-open-recent"), __doc__)

        if QSCI:
            # Scintilla source editor management
            self.scintillaWarningLabel.setText(' QScintilla is Ready ! ')
            layout = self.source.layout()
            layout.removeWidget(self.sourceTextEdit)
            self.sourceTextEdit = Qsci.QsciScintilla(self.source)
            layout.addWidget(self.sourceTextEdit, 0, 1)
            doc = self.sourceTextEdit
            doc.setLexer(Qsci.QsciLexerPython(self.sourceTextEdit))
            doc.setReadOnly(True)
            doc.setEdgeMode(Qsci.QsciScintilla.EdgeLine)
            doc.setEdgeColumn(80)
            doc.setEdgeColor(QColor("#FF0000"))
            doc.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle)
            doc.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)
            doc.setCaretLineVisible(True)
            doc.setMarginLineNumbers(1, True)
            doc.setMarginWidth(1, 25)
            doc.setTabWidth(4)
            doc.setEolMode(Qsci.QsciScintilla.EolUnix)
            self.marker = {}
            for color in COLORS:
                mnr = doc.markerDefine(Qsci.QsciScintilla.Background)
                doc.setMarkerBackgroundColor(color, mnr)
                self.marker[color] = mnr
        self.currentSourcePath = None

        # Connect table and tree filter edit signal to unique slot
        self.filterTableLineEdit.textEdited.connect(
            self.on_filterLineEdit_textEdited)

        # Timer to display filter hint message
        self.filterHintTimer = QTimer(self)
        self.filterHintTimer.setSingleShot(True)
        self.filterHintTimer.timeout.connect(self.on_filterHintTimer_timeout)

        # Timer to start search
        self.filterSearchTimer = QTimer(self)
        self.filterSearchTimer.setSingleShot(True)
        self.filterSearchTimer.timeout.connect(
            self.on_filterSearchTimer_timeout)

        self.tabLoaded = {}
        for i in range(10):
            self.tabLoaded[i] = False
        self.backgroundTreeMatchedItems = {}
        self.resizeWidgetToContent(self.tableWidget)
示例#26
0
import sys
from PyQt4.QtGui import QApplication
from PyQt4 import QtCore, QtGui, Qsci
from PyQt4.Qsci import *

if __name__ == "__main__":
    app = QApplication(sys.argv)
    editor = QsciScintilla()

    ## Choose a lexer
    ## This can be any Scintilla lexer, but the original example used Python
    lexer = QsciLexerPython(editor)

    ## Create an API for us to populate with our autocomplete terms
    api = Qsci.QsciAPIs(lexer)
    ## Add autocompletion strings
    api.add("aLongString")
    api.add("aLongerString")
    api.add("aDifferentString")
    api.add("sOmethingElse")
    ## Compile the api for use in the lexer
    api.prepare()
    editor.setLexer(lexer)

    ## Set the length of the string before the editor tries to autocomplete
    ## In practise this would be higher than 1
    ## But its set lower here to make the autocompletion more obvious
    editor.setAutoCompletionThreshold(1)
    ## Tell the editor we are using a QsciAPI for the autocompletion

    editor.setAutoCompletionSource(QsciScintilla.AcsAPIs)
示例#27
0
    def __init__(self, parent=None, designMode=False):
        Qsci.QsciScintilla.__init__(self, parent)

        self.textEdit = Qsci.QsciScintilla()
        self.textEdit.setAutoCompletionThreshold(1)
        self.textEdit.setAutoCompletionSource(Qsci.QsciScintilla.AcsAll)
        self.textEdit.setAutoIndent(True)
        self.textEdit.setCallTipsStyle(Qsci.QsciScintilla.CallTipsContext)
        self.textEdit.setCallTipsVisible(0)
        self.pythonLexer = Qsci.QsciLexerPython(self.textEdit)
        self.api = Qsci.QsciAPIs(self.pythonLexer)
        self.api.add(Qt.QString("dupa(a,b)this is function dupa"))
        self.api.prepare()
        self.pythonLexer.setAPIs(self.api)
        self.textEdit.setLexer(self.pythonLexer)

        self.newAction = Qt.QAction(getThemeIcon("document-new"), "New", self)
        self.newAction.triggered.connect(self.newFile)
        self.newAction.setToolTip("Create new file")
        self.newAction.setShortcut("Ctrl+N")

        self.openAction = Qt.QAction(getThemeIcon("document-open"), "Open",
                                     self)
        self.openAction.triggered.connect(self.openFile)
        self.openAction.setToolTip("Open existing file")
        self.openAction.setShortcut("Ctrl+O")

        self.saveAction = Qt.QAction(getThemeIcon("document-save"), "Save",
                                     self)
        self.saveAction.triggered.connect(self.saveFile)
        self.saveAction.setToolTip("Save document to disk")
        self.saveAction.setShortcut("Ctrl+S")

        self.saveAsAction = Qt.QAction(getThemeIcon("document-save-as"),
                                       "Save as...", self)
        self.saveAction.triggered.connect(self.saveFile)
        self.saveAsAction.setToolTip("Save document under a new name")

        self.cutAction = Qt.QAction(getThemeIcon("edit-cut"), "Cut", self)
        self.cutAction.triggered.connect(self.cut)
        self.cutAction.setToolTip(
            "Cut current selection's contents to the clipboard")
        self.cutAction.setShortcut("Ctrl+X")
        self.cutAction.setEnabled(False)

        self.copyAction = Qt.QAction(getThemeIcon("edit-copy"), "Copy", self)
        self.copyAction.triggered.connect(self.copy)
        self.copyAction.setToolTip(
            "Copy current selection's contents to the clipboard")
        self.copyAction.setShortcut("Ctrl+C")
        self.copyAction.setEnabled(False)

        self.pasteAction = Qt.QAction(getThemeIcon("edit-paste"), "Paste",
                                      self)
        self.pasteAction.triggered.connect(self.paste)
        self.pasteAction.setToolTip(
            "Paste the clipboard's contents into the current selection")
        self.pasteAction.setShortcut("Ctrl+V")

        self.aboutAction = Qt.QAction("About", self)
        self.aboutAction.triggered.connect(self.about)
        self.aboutAction.setToolTip("Show the application's About box")

        self.textEdit.copyAvailable.connect(self.cutAction.setEnabled)
        self.textEdit.copyAvailable.connect(self.copyAction.setEnabled)

        self.setCurrentFile("")
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent, remove_stretch=True)
        message = _("Edit Standard Letters")
        self.setWindowTitle(message)

        self._standard_letters = None
        self.deleted_letters = []

        header_label = QtGui.QLabel("<b>%s</b>" % message)

        self.list_model = ListModel()

        self.list_view = QtGui.QListView()
        self.list_view.setModel(self.list_model)

        icon = QtGui.QIcon(":/eraser.png")
        delete_but = QtGui.QPushButton(icon, "")
        delete_but.setToolTip(_("Delete the currently selected letter"))
        delete_but.setMaximumWidth(80)

        icon = QtGui.QIcon(":/add_user.png")
        add_but = QtGui.QPushButton(icon, "")
        add_but.setToolTip(_("Add a New Letter"))
        add_but.setMaximumWidth(80)

        left_frame = QtGui.QFrame()
        layout = QtGui.QGridLayout(left_frame)
        layout.setMargin(0)
        layout.addWidget(self.list_view, 0, 0, 1, 3)
        layout.addWidget(delete_but, 1, 0)
        layout.addWidget(add_but, 1, 1)
        left_frame.setMaximumWidth(250)

        right_frame = QtGui.QFrame()
        layout = QtGui.QFormLayout(right_frame)
        layout.setMargin(0)
        self.description_line_edit = QtGui.QLineEdit()
        self.text_edit = Qsci.QsciScintilla()
        self.text_edit.setLexer(Qsci.QsciLexerHTML())
        self.footer_text_edit = Qsci.QsciScintilla()
        self.footer_text_edit.setLexer(Qsci.QsciLexerHTML())

        layout.addRow(_("Desctription"), self.description_line_edit)
        layout.addRow(_("Body Text"), self.text_edit)
        layout.addRow(_("Footer"), self.footer_text_edit)

        splitter = QtGui.QSplitter()
        splitter.addWidget(left_frame)
        splitter.addWidget(right_frame)
        splitter.setSizes([1, 10])
        self.insertWidget(header_label)
        self.insertWidget(splitter)

        self.list_view.pressed.connect(self.show_data)

        self.cancel_but.setText(_("Close"))
        self.apply_but.setText(_("Apply Changes"))

        self.set_check_on_cancel(True)
        self.signals()
        add_but.clicked.connect(self.add_letter)
        delete_but.clicked.connect(self.remove_letter)

        self.orig_data = []
        QtCore.QTimer.singleShot(100, self.load_existing)
示例#29
0
    def setup_ui(self, tabwidget, searchControlPlaceholder):

        self.tabwidget = tabwidget
        self.searchControlPlaceholder = searchControlPlaceholder

        self.networkAccessManager = self.framework.getNetworkAccessManager()

        if self.searchControlPlaceholder is not None:
            self.searchLayout = self.searchControlPlaceholder.layout()
            if not self.searchLayout or 0 == self.searchLayout:
                self.searchLayout = QVBoxLayout(self.searchControlPlaceholder)
            self.searchLayout.addWidget(
                self.makeSearchWidget(self.searchControlPlaceholder))
            self.searchLayout.addWidget(
                self.makeConfirmedUpdateWidget(self.searchControlPlaceholder))
            self.searchLayout.setSpacing(0)
            self.searchLayout.setContentsMargins(-1, 0, -1, 0)
            self.searchControlPlaceholder.updateGeometry()

        self.requestView = QWidget(tabwidget)
        self.requestView.setObjectName(tabwidget.objectName() + 'Request')
        self.tabwidget.addTab(self.requestView, 'Request')

        self.responseView = QWidget(tabwidget)
        self.responseView.setObjectName(tabwidget.objectName() + 'Response')
        self.tabwidget.addTab(self.responseView, 'Response')

        self.hexBody = QWidget(tabwidget)
        self.hexBody.setObjectName(tabwidget.objectName() + 'HexBody')
        self.hexBodyIndex = self.tabwidget.addTab(self.hexBody, 'Hex Body')

        self.scriptsView = QWidget(tabwidget)
        self.scriptsView.setObjectName(tabwidget.objectName() + 'Scripts')
        self.scriptsTabIndex = self.tabwidget.addTab(self.scriptsView,
                                                     'Scripts')

        self.commentsView = QWidget(tabwidget)
        self.commentsView.setObjectName(tabwidget.objectName() + 'Comments')
        self.tabwidget.addTab(self.commentsView, 'Comments')

        self.linksView = QWidget(tabwidget)
        self.linksView.setObjectName(tabwidget.objectName() + 'Links')
        self.tabwidget.addTab(self.linksView, 'Links')

        self.formsView = QWidget(tabwidget)
        self.formsView.setObjectName(tabwidget.objectName() + 'Forms')
        self.tabwidget.addTab(self.formsView, 'Forms')

        self.renderView = QWidget(tabwidget)
        self.renderView.setObjectName(tabwidget.objectName() + 'Render')
        self.renderTabIndex = self.tabwidget.addTab(self.renderView, 'Render')
        self.tabwidget.currentChanged.connect(self.handle_tab_currentChanged)

        self.generatedSourceView = QWidget(tabwidget)
        self.generatedSourceView.setObjectName(tabwidget.objectName() +
                                               'GeneratedSource')
        self.generatedSourceTabIndex = self.tabwidget.addTab(
            self.generatedSourceView, 'Generated Source')

        self.notesView = QWidget(tabwidget)
        self.notesView.setObjectName(tabwidget.objectName() + 'Notes')
        self.notesTabIndex = self.tabwidget.addTab(self.notesView, 'Notes')

        self.tab_item_widgets = []

        self.vlayout0 = QVBoxLayout(self.requestView)
        self.requestScintilla = Qsci.QsciScintilla(self.requestView)
        self.setScintillaProperties(self.requestScintilla)
        self.vlayout0.addWidget(self.requestScintilla)
        self.tab_item_widgets.append(self.requestScintilla)

        self.vlayout1 = QVBoxLayout(self.responseView)
        self.responseScintilla = Qsci.QsciScintilla(self.responseView)
        self.responseScintilla.setMarginLineNumbers(1, True)
        self.setScintillaProperties(self.responseScintilla)
        self.vlayout1.addWidget(self.responseScintilla)
        self.tab_item_widgets.append(self.responseScintilla)

        self.vlayout2a = QVBoxLayout(self.hexBody)
        self.hexBodyScintilla = Qsci.QsciScintilla(self.hexBody)
        self.hexBodyScintilla.setFont(self.framework.get_monospace_font())
        self.vlayout2a.addWidget(self.hexBodyScintilla)
        self.tab_item_widgets.append(self.hexBodyScintilla)

        self.vlayout2 = QVBoxLayout(self.scriptsView)
        self.scriptsScintilla = Qsci.QsciScintilla(self.scriptsView)
        #        self.scriptsScintilla.setMarginLineNumbers(1, True)
        self.setScintillaProperties(self.scriptsScintilla, 'javascript')
        self.vlayout2.addWidget(self.scriptsScintilla)
        self.tab_item_widgets.append(self.scriptsScintilla)

        self.vlayout3 = QVBoxLayout(self.commentsView)
        self.commentsScintilla = Qsci.QsciScintilla(self.commentsView)
        #        self.commentsScintilla.setMarginLineNumbers(1, True)
        self.setScintillaProperties(self.commentsScintilla, 'html')
        self.vlayout3.addWidget(self.commentsScintilla)
        self.tab_item_widgets.append(self.commentsScintilla)

        self.vlayout4 = QVBoxLayout(self.linksView)
        self.linksScintilla = Qsci.QsciScintilla(self.linksView)
        self.setScintillaProperties(self.linksScintilla)
        self.vlayout4.addWidget(self.linksScintilla)
        self.tab_item_widgets.append(self.linksScintilla)

        self.vlayout5 = QVBoxLayout(self.formsView)
        self.formsScintilla = Qsci.QsciScintilla(self.formsView)
        self.setScintillaProperties(self.formsScintilla, 'html')
        self.vlayout5.addWidget(self.formsScintilla)
        self.tab_item_widgets.append(self.formsScintilla)

        self.vlayout6 = QVBoxLayout(self.renderView)
        self.renderWebView = RenderingWebView(self.framework,
                                              self.standardPageFactory,
                                              self.renderView)
        self.renderWebView.page().setNetworkAccessManager(
            self.networkAccessManager)
        self.renderWebView.loadFinished.connect(
            self.render_handle_loadFinished)
        self.vlayout6.addWidget(self.renderWebView)
        self.tab_item_widgets.append(self.renderWebView)

        self.vlayout7 = QVBoxLayout(self.generatedSourceView)
        self.generatedSourceScintilla = Qsci.QsciScintilla(
            self.generatedSourceView)
        self.generatedSourceWebView = RenderingWebView(
            self.framework, self.headlessPageFactory, self.generatedSourceView)
        self.generatedSourceWebView.page().setNetworkAccessManager(
            self.networkAccessManager)
        self.generatedSourceWebView.loadFinished.connect(
            self.generatedSource_handle_loadFinished)
        self.generatedSourceWebView.setVisible(False)
        self.generatedSourceScintilla.setMarginLineNumbers(1, True)
        self.setScintillaProperties(self.generatedSourceScintilla, 'html')
        self.vlayout7.addWidget(self.generatedSourceWebView)
        self.vlayout7.addWidget(self.generatedSourceScintilla)
        self.tab_item_widgets.append(self.generatedSourceScintilla)

        self.vlayout8 = QVBoxLayout(self.notesView)
        self.notesTextEdit = QTextEdit(self.notesView)
        self.vlayout8.addWidget(self.notesTextEdit)
        self.tab_item_widgets.append(self.notesTextEdit)

        self.clear()
示例#30
0
 def _margin_style(self):
     """Style for margin area"""
     s = Qsci.QsciStyle()
     s.setPaper(QApplication.palette().color(QPalette.Window))
     s.setFont(self.font())
     return s