Beispiel #1
0
 def _config_autocomplete(self):
     # if source is set, make use of all variables
     self.setAutoCompletionSource(Qsci.QsciScintilla.AcsAll if self.autocomplete_source else Qsci.QsciScintilla.AcsNone)
     # invoke autocompletion when typed 1 character
     self.setAutoCompletionThreshold(1)
     # autocompletion case-insensitive
     self.setAutoCompletionCaseSensitivity(False)
     # don't replace typed text, but append
     self.setAutoCompletionReplaceWord(False)
     # don't complete word even if there's only one suggestion
     self.setAutoCompletionUseSingle(Qsci.QsciScintilla.AcusNever)
     # show calltips independent of context
     self.setCallTipsStyle(Qsci.QsciScintilla.CallTipsNoContext)
     #self.setCallTipsStyle(Qsci.QsciScintilla.CallTipsNoAutoCompletionContext)
     #self.setCallTipsStyle(Qsci.QsciScintilla.CallTipsContext)
     # display all applicable calltips
     self.setCallTipsVisible(0)
     # show calltips beneath the typed text
     self.setCallTipsPosition(Qsci.QsciScintilla.CallTipsBelowText)
     # configure calltip colors
     self.setCallTipsBackgroundColor(QtGui.QColor('#fffff0'))
     self.setCallTipsForegroundColor(QtGui.QColor(QtCore.Qt.black))
     self.setCallTipsHighlightColor(QtGui.QColor(QtCore.Qt.blue))
     ## `Qsci.QsciAPIs` internal autocomplete object
     self.autocomplete = Qsci.QsciAPIs(self.lexer)
     self.reset_autocomplete_source()
Beispiel #2
0
    def __init__(self):
        super(ScriptPage, self).__init__()
        self.setupUi(self)

        self.scriptCodeEditor.setUtf8(1)

        lex = Qsci.QsciLexerPython(self)
        api = Qsci.QsciAPIs(lex)
        api.load(API_FILE)
        api.prepare()
        self.current_script = None  # type: model.Script
        self.scriptCodeEditor.setLexer(lex)

        self.scriptCodeEditor.setBraceMatching(
            Qsci.QsciScintilla.SloppyBraceMatch)
        self.scriptCodeEditor.setAutoIndent(True)
        self.scriptCodeEditor.setBackspaceUnindents(True)
        self.scriptCodeEditor.setIndentationWidth(4)
        self.scriptCodeEditor.setIndentationGuides(True)
        self.scriptCodeEditor.setIndentationsUseTabs(False)
        self.scriptCodeEditor.setAutoCompletionThreshold(3)
        self.scriptCodeEditor.setAutoCompletionSource(
            Qsci.QsciScintilla.AcsAll)
        self.scriptCodeEditor.setCallTipsStyle(
            Qsci.QsciScintilla.CallTipsNoContext)
        lex.setFont(ui_common.monospace_font())
Beispiel #3
0
    def setNoneAutocomplete(self):
        #AutoCompletion
        self.autocomplete = Qsci.QsciAPIs(self.lexer)
        self.autocomplete.clear()

        self.autocomplete.prepare()

        self.setAutoCompletionThreshold(3)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
Beispiel #4
0
 def __init__(self, parent=None):
     super().__init__(parent=parent)
     self.lexer = Qsci.QsciLexerPython()
     api = Qsci.QsciAPIs(self.lexer)
     api.prepare()
     self.setLexer(self.lexer)
     self.setAutoCompletionThreshold(1)
     self.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
     self.init_ui()
     return
Beispiel #5
0
    def __init__(self,
                 parent=None,
                 *,
                 fontsize=11,
                 fontfamily='monospace',
                 autocompletion_words=(),
                 autocomplete_python=True,
                 theme='dark',
                 **kwds):
        super().__init__(parent)

        # Fonts
        self.setAllFonts(fontfamily, fontsize)
        self.setMarginSensitivity(1, False)
        self.setCaretLineVisible(True)

        # Configure lexer and api for autocompletion
        lexer = Qsci.QsciLexerPython(self)
        lexer.setDefaultFont(self.font())
        words = list(autocompletion_words)
        if autocomplete_python:
            words.extend(PYTHON_WORDS)
        if words:
            api = Qsci.QsciAPIs(lexer)
            for word in words:
                api.add(word)
            api.prepare()
        self.setLexer(lexer)

        # Set font for lexer again?
        bfamily = bytes(fontfamily, encoding='utf8')
        self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, bfamily)
        self.setAllFonts(fontfamily, fontsize, True)

        # General indentation behavior
        self.setAutoIndent(True)
        self.setTabWidth(4)
        self.setIndentationsUseTabs(False)
        self.setTabIndents(True)
        self.setBackspaceUnindents(True)
        self.setIndentationGuides(True)

        # Configure autocompletion and brace matching
        self.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)
        self.setAutoCompletionThreshold(2)
        self.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)

        # Set colors
        self._theme = theme
        color_kwds = {k: v for (k, v) in kwds.items() if k.endswith('_color')}
        self.setTheme(theme, **color_kwds)

        # Check for any rogue parameter
        if kwds:
            raise TypeError('invalid parameter: %r' % kwds.popitem()[0])
    def set_autocompletion(self, items):
        """
            Allow the strings contained in items to be autocompleted after two characters

            @param items: List of strings containing the words to propose for autocompletion
        """
        self.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
        self.setAutoCompletionThreshold(2)
        self.api = Qsci.QsciAPIs(self.lexer_)
        for item in items:
            self.api.add(item)
        self.api.prepare()
Beispiel #7
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()
Beispiel #8
0
    def __initScintilla(self):
        # delete text editor placeholder
        scintilla = Qsci.QsciScintilla(self)

        ########################
        # setup scintilla
        # set default font
        font = QtGui.QFont()
        font.setFamily('Deja Vu Sans Mono')
        font.setFixedPitch(True)
        font.setPointSize(11)

        # brace matching
        scintilla.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)

        # set lexer
        lexer = Qsci.QsciLexerCPP()
        lexer.setDefaultFont(font)
        lexer.setFont(font)
        scintilla.setLexer(lexer)

        scintilla.setLexer(lexer)
        scintilla.__myLexer = lexer  # save reference to retain scope

        # auto-completion api
        scintilla.__myApi = Qsci.QsciAPIs(lexer)

        scintilla.setAutoCompletionThreshold(1)
        scintilla.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)

        # remove horizontal scrollbar
        scintilla.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)

        # display default line numbers
        fm = QtGui.QFontMetrics(font)
        scintilla.setMarginWidth(0, fm.width("00000"))
        scintilla.setMarginLineNumbers(0, True)
        ########################

        # insert widget into main vlayout
        self.ui.vlayout.addWidget(scintilla)
        self.__scintilla = scintilla
    def __init__(self):
        super(PyOneScript, self).__init__()

        self.setAttribute(Qt.WA_DeleteOnClose)
        self.isUntitled = True

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

        self.setMarginSensitivity(1, True)
        self.marginClicked.connect(self.on_margin_clicked)
        self.markerDefine(QsciScintilla.RightArrow, self.ARROW_MARKER_NUM)
        self.setMarkerBackgroundColor(QColor("#ee1111"), self.ARROW_MARKER_NUM)
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
        self.setEolMode(Qsci.QsciScintilla.EolUnix)
        self.setAutoCompletionSource(Qsci.QsciScintilla.AcsAll)
        self.setAutoCompletionThreshold(1)
        self.setAutoIndent(True)
        self.setIndentationsUseTabs(True)
        self.setTabWidth(4)
        self.setAutoCompletionFillupsEnabled(True)
        self.setBraceMatching(Qsci.QsciScintilla.StrictBraceMatch)
        self.setMarginLineNumbers(1, 1)
        self.setMarginWidth(1, 35)
        self.setUtf8(True)
        self.setEolVisibility(False)
        self.setMinimumSize(600, 450)
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

        self.lexer = QsciLexerPython()
        self.lexer.setDefaultFont(font)

        self.setLexer(self.lexer)
        self.sense = Qsci.QsciAPIs(self.lexer)
        self.sense.prepare()

        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
Beispiel #10
0
    def setupEditor(self):
        #Font
        self.font = QtGui.QFont()
        self.font.setFamily('Inconsolata')
        self.font.setPointSize(12)
        self.ui.textEdit.setFont(self.font)
        self.ui.textEdit.setMarginsFont(self.font)

        #Syntax
        self.lexer = Qsci.QsciLexerPython()
        self.lexer.setFont(self.font)
        self.lexer.setDefaultFont(self.font)

        #Autocomplete
        api = Qsci.QsciAPIs(self.lexer)
        keys = dir(builtins) + keyword.kwlist
        [api.add(key) for key in keys]
        api.prepare()
        self.ui.textEdit.setLexer(self.lexer)
        self.ui.textEdit.setAutoCompletionThreshold(1)
        self.ui.textEdit.setAutoCompletionSource(Qsci.QsciScintilla.AcsAll)

        #Indent
        self.ui.textEdit.setIndentationWidth(4)
        self.ui.textEdit.setTabWidth(4)
        self.ui.textEdit.setIndentationsUseTabs(False)
        self.ui.textEdit.setAutoIndent(True)

        #Current line
        self.ui.textEdit.SendScintilla(Qsci.QsciScintilla.SCI_SETINDICATORCURRENT, 0, 0)
        self.ui.textEdit.setCaretLineVisible(True)
        self.ui.textEdit.setCaretLineBackgroundColor(QtGui.QColor("#f0f0ff"))

        #Margin
        self.ui.textEdit.setMarginWidth(0, 15)
        self.ui.textEdit.setMarginWidth(1, 15)
        self.ui.textEdit.setMarginLineNumbers(0, False)
        self.ui.textEdit.setMarginLineNumbers(1, True)
        self.ui.textEdit.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle)
Beispiel #11
0
    def __init__(self, parent=None):
        QtWidgets.QMainWindow.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        if getattr(sys, 'frozen', False):
            iconpath = os.path.join(os.path.dirname(sys.executable), "asc",
                                    "data", "icon.svg")
            pixmap = QtGui.QPixmap(iconpath)
        else:
            icon = pkgutil.get_data('asc', os.path.join('data', 'icon.svg'))
            pixmap = QtGui.QPixmap()
            pixmap.loadFromData(icon)
        icon = QtGui.QIcon()
        icon.addPixmap(pixmap, QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        # Script mode selector
        self.ui.modeGroup = QtWidgets.QActionGroup(self)
        self.ui.actionModeOW = QtWidgets.QAction("OW Script Mode", self)
        self.ui.actionModeOW.setCheckable(True)
        self.ui.actionModeAI = QtWidgets.QAction("AI Script Mode", self)
        self.ui.actionModeAI.setCheckable(True)
        self.ui.menuSettings.addAction(self.ui.actionModeOW)
        self.ui.menuSettings.addAction(self.ui.actionModeAI)
        self.ui.modeGroup.addAction(self.ui.actionModeOW)
        self.ui.modeGroup.addAction(self.ui.actionModeAI)
        self.ui.actionModeOW.setChecked(True)
        self.mode = "ow"

        connections = ((self.ui.actionOpen,
                        self.load_file), (self.ui.actionNew,
                                          self.new_file), (self.ui.actionSave,
                                                           self.save_file),
                       (self.ui.actionSave_As,
                        self.save_as), (self.ui.actionLoad_ROM, self.load_rom),
                       (self.ui.actionQuit,
                        self.close), (self.ui.actionDecompile,
                                      self.decompile), (self.ui.actionCompile,
                                                        self.action_compile),
                       (self.ui.actionDebug,
                        self.action_debug), (self.ui.actionCut,
                                             self.ui.textEdit.cut),
                       (self.ui.actionCopy,
                        self.ui.textEdit.copy), (self.ui.actionPaste,
                                                 self.ui.textEdit.paste),
                       (self.ui.actionDelete,
                        self.ui.textEdit.removeSelectedText),
                       (self.ui.actionUndo,
                        self.ui.textEdit.undo), (self.ui.actionRedo,
                                                 self.ui.textEdit.redo),
                       (self.ui.actionFind,
                        self.find), (self.ui.actionInsert_String,
                                     self.insert_string), (self.ui.actionAbout,
                                                           self.help_about),
                       (self.ui.actionManual,
                        self.manual), (self.ui.actionCommand_Help,
                                       self.command_help),
                       (self.ui.actionModeOW,
                        self.set_mode_ow), (self.ui.actionModeAI,
                                            self.set_mode_ai))

        for action, function in connections:
            action.triggered.connect(function)

        self.rom_file_name = ""
        self.file_name = ""
        # QScintilla
        self.ui.textEdit.setMarginLineNumbers(1, True)
        self.ui.textEdit.setMarginWidth(1, 30)
        self.font = QtGui.QFont("mono", 10)
        self.ui.textEdit.setFont(self.font)
        lexer = QsciLexerPKS(self.ui.textEdit)
        lexer.setDefaultFont(self.font)
        self.ui.textEdit.setLexer(lexer)

        self.api = Qsci.QsciAPIs(lexer)
        self.set_autocompletion()
        self.ui.textEdit.setAutoCompletionThreshold(1)
        self.ui.textEdit.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
        self.ui.textEdit.setAutoIndent(True)

        self.ui.textEdit.setText(asc.get_canvas())

        self.ui.textEdit.cursorPositionChanged.connect(self.cur_pos_changed)
Beispiel #12
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(640, 480)
        self.vindu = QtWidgets.QWidget(MainWindow)
        self.vindu.setStyleSheet(_fromUtf8('notusedasyet'))
        #MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        self.filename = ""
        self.vindu.setObjectName(_fromUtf8("vindu"))
        self.verticalLayout = PyQt5.QtWidgets.QVBoxLayout(self.vindu)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/ico/python.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
        MainWindow.setWindowIcon(icon)
        self.verticalLayout.setContentsMargins(0,0,0,0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName(_fromUtf8('verticalLayout'))
        self.codebox = Qsci.QsciScintilla(self.vindu)
        self.codebox.setToolTip(_fromUtf8(""))
        self.codebox.setWhatsThis(_fromUtf8(""))
        self.codebox.setAutoFillBackground(False)
        self.codebox.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.codebox.setObjectName(_fromUtf8("codebox"))
        self.verticalLayout.addWidget(self.codebox)
        MainWindow.setCentralWidget(self.vindu)
        #toolbar
        self.toolBar = QtWidgets.QToolBar(MainWindow)
        self.toolBar.setAutoFillBackground(False)
        self.toolBar.setIconSize(QtCore.QSize(32, 32))
        self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        self.toolBar.setObjectName(_fromUtf8("toolBar2"))
        MainWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar)
        self.toolBar.addSeparator()
        #toolbar2 debugger
        #self.toolBar2 = QtGui.QToolBar(MainWindow)
        #self.toolBar2.setAutoFillBackground(False)
        #self.toolBar2.setIconSize(QtCore.QSize(32, 32))
        #self.toolBar2.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        #self.toolBar2.setObjectName(_fromUtf8("toolBar"))
       # MainWindow.addToolBar(QtCore.Qt.RightToolBarArea, self.toolBar2)
#        self.toolBar2.addSeparator()
        #getting ready for debugger
        self.codebox.setMarginSensitivity(1, True)
        self.codebox.marginClicked.connect(self.on_margin_clicked)
        self.codebox.markerDefine(QsciScintilla.FullRectangle, self.ARROW_MARKER_NUM)
        self.codebox.setMarkerBackgroundColor(QColor("#ee1111"), self.ARROW_MARKER_NUM)
        #first action Newfile
        self.toolBar.newAction = QtWidgets.QAction(QtGui.QIcon(":/ico/new.png"),"New",self.toolBar)
        self.toolBar.newAction.setStatusTip("Clear TextBox or make new document.")
        self.toolBar.newAction.setShortcut("Ctrl+N")
        self.toolBar.newAction.triggered.connect(self.newfile)
        #second Action OpenFile
        self.toolBar.secondAction = QtWidgets.QAction(QtGui.QIcon(":/ico/open.png"),"Open",self.toolBar)
        self.toolBar.secondAction.setStatusTip("Create a new document from scratch.")
        self.toolBar.secondAction.setShortcut("Ctrl+O")
        self.toolBar.secondAction.triggered.connect(self.open)
        # action 3 save file
        self.toolBar.Action3 = QtWidgets.QAction(QtGui.QIcon(":/ico/save.png"),"Save",self.toolBar)
        self.toolBar.Action3.setStatusTip("Save Your File.")
        self.toolBar.Action3.setShortcut("Ctrl+S")
        self.toolBar.Action3.triggered.connect(self.savefile)
        #action 4 run file
        self.toolBar.Action4 = QtWidgets.QAction(QtGui.QIcon(":/ico/run32.png"),"Run",self.toolBar)
        self.toolBar.Action4.setStatusTip("Run")
        self.toolBar.Action4.setShortcut("Ctrl+E")
        self.toolBar.Action4.triggered.connect(self.runto)
        #action 21 debug
        #self.toolBar2.Action21 = QtGui.QAction(QtGui.QIcon(":/ico/run32.png"),"Debug",self.toolBar)
        #self.toolBar2.Action21.setStatusTip("Debug File.")
        #self.toolBar2.Action21.setShortcut("Ctrl+7")
        #self.toolBar2.Action21.triggered.connect(self.debugto)
        #action 6 undo
        self.toolBar.Action6 =  QtWidgets.QAction(QtGui.QIcon(":/ico/undo.png"),"Redo",self.toolBar)
        self.toolBar.Action6.setStatusTip("Undo.")
        self.toolBar.Action6.setShortcut("Ctrl+Z")
        self.toolBar.Action6.triggered.connect(self.codebox.undo)
        #action 7 redo
        self.toolBar.Action7 = QtWidgets.QAction(QtGui.QIcon(":/ico/redo.png"),"Redo",self.toolBar)
        self.toolBar.Action7.setStatusTip("Redo.")
        self.toolBar.Action7.setShortcut("Ctrl+Y")
        self.toolBar.Action7.triggered.connect(self.codebox.redo)
        #action8 rerset Folding
        self.toolBar.Action8 = QtWidgets.QAction(QtGui.QIcon(":/ico/align-justify.png"),"Reset Folding",self.toolBar)
        self.toolBar.Action8.setStatusTip("Reset Folding.")
        self.toolBar.Action8.setShortcut("Ctrl+R")
        self.toolBar.Action8.triggered.connect(self.nofoldingl)
        #actions9 CircledTreeFoldStyle
        self.toolBar.Action9 = QtWidgets.QAction(QtGui.QIcon(":/ico/bullet.png"),"Circled Tree Folding",self.toolBar)
        self.toolBar.Action9.setStatusTip("Circled Tree Folding.")
        self.toolBar.Action9.setShortcut("Ctrl+C")
        self.toolBar.Action9.triggered.connect(self.Circledfold)
        #actions10 plainFoldStyle
        self.toolBar.Action10 = QtWidgets.QAction(QtGui.QIcon(":/ico/number.png"),"Plain Folding",self.toolBar)
        self.toolBar.Action10.setStatusTip("Plain Folding")
        self.toolBar.Action10.setShortcut("Ctrl+P")
        self.toolBar.Action10.triggered.connect(self.plainfold)
        # fonts
        self.toolBar.Action21 = QtWidgets.QAction(QtGui.QIcon(":/ico4/font.png"), "Fonts", self.toolBar)
        self.toolBar.Action21.setStatusTip("Fonts")
        self.toolBar.Action21.setShortcut("Ctrl+F")
        self.toolBar.Action21.triggered.connect(self.font_choice)
        #web baby
        self.toolBar.Action11 = QtWidgets.QAction(QtGui.QIcon(":/ico/web.png"),"Hex-rays Homepage",self.toolBar)
        self.toolBar.Action11.setStatusTip("Home of Hex-rays")
        self.toolBar.Action11.setShortcut("Ctrl+W")
        self.toolBar.Action11.triggered.connect(self.webopen)
        #irc
        self.toolBar.Action12 = QtWidgets.QAction(QtGui.QIcon(":/ico3/settings.png"),"Open Ida Pro Python SDK",self.toolBar)
        self.toolBar.Action12.setStatusTip("Ida Pro Python SDK")
        self.toolBar.Action12.setShortcut("Ctrl+I")
        self.toolBar.Action12.triggered.connect(self.sdkopen)
        #github Python
        self.toolBar.Action14 = QtWidgets.QAction(QtGui.QIcon(":/ico/github.png"),"Open git python",self.toolBar)
        self.toolBar.Action14.setStatusTip("Open git python")
        self.toolBar.Action14.setShortcut("Ctrl+G")
        self.toolBar.Action14.triggered.connect(self.gitopen)
        #auther me :)
        self.toolBar.Action15 = QtWidgets.QAction(QtGui.QIcon(":/ico/auth.png"),"Author",self.toolBar)
        self.toolBar.Action15.setStatusTip("Author")
        self.toolBar.Action15.setShortcut("Ctrl+B")
        self.toolBar.Action15.triggered.connect(self.Author)
        #toggle off code regonision
        self.toolBar.Action16 = QtWidgets.QAction(QtGui.QIcon(":/ico2/pythonminus.png"),"Disable Code recognition",self.toolBar)
        self.toolBar.Action16.setStatusTip("Disable Code recognition")
        self.toolBar.Action16.setShortcut("Alt+D")
        self.toolBar.Action16.triggered.connect(self.Diablecode)
        #toogle on
        self.toolBar.Action17 = QtWidgets.QAction(QtGui.QIcon(":/ico2/pypluss.png"),"Enable Code recognition",self.toolBar)
        self.toolBar.Action17.setStatusTip("Enable Code recognition")
        self.toolBar.Action17.setShortcut("Alt+E")
        self.toolBar.Action17.triggered.connect(self.Reiablecode)
        # zoom in
        self.toolBar.Action18 = QtWidgets.QAction(QtGui.QIcon(":/ico3/in.png"),"Zoom In",self.toolBar)
        self.toolBar.Action18.setStatusTip("Zoom In")
        self.toolBar.Action18.setShortcut("CTRL+SHIFT++")
        self.toolBar.Action18.triggered.connect(self.udder)
        #zoom out
        self.toolBar.Action19 = QtWidgets.QAction(QtGui.QIcon(":/ico3/out.png"),"Zoom Out",self.toolBar)
        self.toolBar.Action19.setStatusTip("Zoom Out")
        self.toolBar.Action19.setShortcut("CTRL+SHIFT+-")
        self.toolBar.Action19.triggered.connect(self.odder)

        self.toolBar.Action20 = QtWidgets.QAction(QtGui.QIcon(":/ico3/10.png"),"Profile Code",self.toolBar)
        self.toolBar.Action20.setStatusTip("Profile Code")
        self.toolBar.Action20.setShortcut("CTRL+SHIFT+E")
        self.toolBar.Action20.triggered.connect(self.runtoprob)

        #actions
        self.toolBar.addAction(self.toolBar.newAction)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.secondAction)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action3)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action4)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action6)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action7)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action8)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action9)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action10)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action21)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action11)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action12)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action14)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action15)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action16)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action17)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action18)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action19)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action20)

        #self.toolBar2.addAction(self.toolBar.Action21)
        #self.toolBar2.addSeparator()
        #font
        self.skrift = QFont()
        self.skrift.setFamily('Consolas')
        self.skrift.setFixedPitch(True)
        self.skrift.setPointSize(12)
        self.codebox.setFont(self.skrift)

        #python style
        self.lexer = QsciLexerPython(self.codebox)
        self.lexer.setFont(self.skrift)
        self.lexer.setEolFill(True)
        #api test not working
        api = Qsci.QsciAPIs(self.lexer)
        API_FILE = dn+'\\Python.api'
        API_FILE2 = dn+'\\idc.api'
        API_FILE3 = dn+'\\idaapi.api'
        api.load(API_FILE)
        api.load(API_FILE2)
        api.load(API_FILE3)

        api.prepare()
        self.codebox.setAutoCompletionThreshold(0)
        self.codebox.setAutoCompletionThreshold(6)
        self.codebox.setAutoCompletionThreshold(8)
        self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
        self.lexer.setDefaultFont(self.skrift)
        self.codebox.setLexer(self.lexer)
        self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Consolas')

        #line numbers
        fontmetrics = QFontMetrics(self.skrift)
        self.codebox.setMarginsFont(self.skrift)
        self.codebox.setMarginWidth(0, fontmetrics.width("00000") + 6)
        self.codebox.setTabWidth(4)

        #brace
        self.codebox.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        #auto line tab =4
        self.codebox.setAutoIndent(True)

        #scroolbar
        self.codebox.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    def __init__(self, parent=None, autocompletions=None):
        super(SmsTextWidget, self).__init__(parent)

        # Set the default font
        font = QFont()
        font.setFamily('Consolas')
        font.setFixedPitch(True)
        font.setPointSize(9)
        self.setFont(font)
        self.setMarginsFont(font)
        """
        Customization - GENERAL
        """
        self.lexer = SmsLexer(self)
        # Disable the lexer
        self.setLexer(self.lexer)
        # Set the encoding to UTF-8
        self.setUtf8(True)
        # Set the End-Of-Line character to Unix style ('\n')
        #self.setEolMode(QsciScintilla.EolUnix)
        # Make End-Of-Line characters visible
        #self.setEolVisibility(True)
        # Set the zoom factor, the factor is in points.
        self.zoomTo(3)
        """
        Customization - LINE WRAPPING
        """
        # Set the text wrapping mode to word wrap
        self.setWrapMode(QsciScintilla.WrapWord)
        # Set the text wrapping mode visual indication
        self.setWrapVisualFlags(QsciScintilla.WrapFlagInMargin)
        # Set the text wrapping to indent the wrapped lines
        self.setWrapIndentMode(QsciScintilla.WrapIndentSame)
        """
        Customization - EDGE MARKER
        """
        # Set the edge marker's position and set it to color the background
        # when a line goes over the limit of 50 characters
        self.setEdgeMode(QsciScintilla.EdgeBackground)
        self.setEdgeColumn(2000)
        edge_color = caret_fg_color = QColor("#1fff0000")
        self.setEdgeColor(edge_color)
        # Add a long line that will display the edge marker coloring
        #self.append("\nSome long line that will display the edge marker's functionality.")
        """
        Customization - INDENTATION
        """
        # Set indentation with spaces instead of tabs
        self.setIndentationsUseTabs(False)
        # Set the tab width to 4 spaces
        self.setTabWidth(4)
        # Set tab indent mode, see the 3.3.4 chapter in QSciDocs
        # for a detailed explanation
        self.setTabIndents(True)
        # Set autoindentation mode to maintain the indentation
        # level of the previous line (the editor's lexer HAS
        # to be disabled)
        self.setAutoIndent(True)
        # Make the backspace jump back to the tab width guides
        # instead of deleting one character, but only when
        # there are ONLY whitespaces on the left side of the
        # cursor
        self.setBackspaceUnindents(True)
        # Set indentation guides to be visible
        self.setIndentationGuides(True)
        """
        Customization - CARET (the blinking cursor indicator)
        """
        # # Set the caret color to red
        # caret_fg_color = QColor("#ffff0000")
        # self.setCaretForegroundColor(caret_fg_color)
        # # Enable and set the caret line background color to slightly transparent blue
        # self.setCaretLineVisible(True)
        # caret_bg_color = QColor("#7f0000ff")
        # self.setCaretLineBackgroundColor(caret_bg_color)
        # # Set the caret width of 4 pixels
        # self.setCaretWidth(4)
        """
        Customization - AUTOCOMPLETION (Partially usable without a lexer)
        """

        self.__api = Qsci.QsciAPIs(self.lexer)
        autocompletions = [
            "test_autocompletion",
            "add(int arg_1, float arg_2) Add two integers together",
            "subtract(int arg_1, test arg_2)",
            "subtract(float arg_1, float arg_2)",
            "subtract(test arg_1, test arg_2)",
            "divide(float div_1, float div_2)",
            "some_func(arg_3)",
            "\\$ABC$",
        ]
        for ac in autocompletions:
            self.__api.add(ac)
        self.__api.prepare()

        # Set the autocompletions to case INsensitive
        self.setAutoCompletionCaseSensitivity(False)
        # Set the autocompletion to not replace the word to the right of the cursor
        self.setAutoCompletionReplaceWord(False)
        # Set the autocompletion source to be the words in the
        # document
        self.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
        # Set the autocompletion dialog to appear as soon as 1 character is typed
        self.setAutoCompletionThreshold(1)
Beispiel #14
0
    def onDoubleClicked(self, index):
        self.index = index  #.... wie oben ... def onClicked(...):
        indexItem = self.model.index(index.row(), 0, index.parent())

        fileName, filePath, fileDir, fileInfo = self.getFileInformation()

        if fileDir:
            filePath = self.checkPath(filePath)
            try:
                os.chdir(filePath)
            except Exception as e:
                self.mainWindow.statusBar.showMessage(str(e), 3000)
            self.path = self.checkPath(os.getcwd())

            self.model.setRootPath(filePath)

            if self.rootIsDecorated:
                self.setRootIsDecorated(False)

        else:
            self.filename = filePath

            try:
                with open(self.filename, 'r') as f:
                    self.text = f.read()
            except Exception as e:
                self.mainWindow.statusBar.showMessage(str(e), 3000)

                self.filename = None
                return

            # debug
            if self.textPad:

                if not self.textPad.filename:
                    editor = CodeEditor(self.mainWindow)
                    editor.setText(self.text)
                    editor.filename = filePath
                    self.notebook.newTab(editor)
                    self.textPad = editor

                    x = self.notebook.count()  # number of tabs
                    index = x - 1
                    self.notebook.setCurrentIndex(index)
                    tabName = os.path.basename(editor.filename)

                    self.notebook.setTabText(x, tabName)
                    self.textPad = editor
                    #self.textPad.filename = filePath

                else:
                    editor = CodeEditor(self.mainWindow)
                    editor.setText(self.text)
                    editor.filename = filePath
                    tabName = os.path.basename(editor.filename)
                    self.notebook.newTab(editor)
                    x = self.notebook.count()  # number of tabs
                    index = x - 1
                    self.notebook.setCurrentIndex(index)
                    self.textPad = editor
                    #self.textPad.filename = filePath

            if not self.textPad:
                editor = CodeEditor(self.mainWindow)
                editor.filename = None
                self.notebook.newTab(editor)
                x = self.notebook.count()
                index = x - 1
                self.notebook.setCurrentIndex(index)
                self.textPad = editor
                #self.textPad.filename = filePath

            # make codeView
            codeViewList = self.codeView.makeDictForCodeView(self.text)
            self.codeView.updateCodeView(codeViewList)

            # update textPad Autocomplete
            autocomplete = Qsci.QsciAPIs(self.textPad.lexer)
            self.textPad.autocomplete = autocomplete
            self.textPad.setPythonAutocomplete()

        self.clearSelection()
Beispiel #15
0
    def __init__(self,
                 parent=None,
                 ShowPrint=True,
                 ShowError=True,
                 StatusBar=None,
                 AsDock=False,
                 logCount=30,
                 ScriptsPath='Scripts/',
                 InitalizeScripts=True,
                 btnText="Console",
                 btnIcon="F:/04/06/29.PNG",
                 addObj=None):
        '''
        Parent - Pass QWIDGET based objects. Else I will create my own.
        ShowPrint - Redirect standard prints
        ShowError - Redirect standard errors
        StatusBar - Attach DevC Invoke button to this status bar else You should invoke DevC explicitly
        AsDock - If True creates DevC as a dock else as a dialog window
        '''
        last_update_date = 'July 02 2015'  # July 02 2015 , Jan 12 2013
        self.addObj = addObj
        self.parent = parent
        self.asDock = AsDock
        self.logCount = logCount

        super(DevConsole, self).__init__(self.parent)
        atexit.register(self.writeToLog)

        # Load File
        self.loadedFile = False
        self.loadedFileName = ''
        self.pyDesigner = 'C:\Python34\Lib\site-packages\PyQt5\designer.exe'

        #Flags
        self.qtTools = kmxQtCommonTools.CommonTools(self)
        self.ttls = kmxTools.Tools()
        self.qtTree = kmxQtTreeWidget.TreeWidget()
        self.qtMenu = kmxQtMenuBuilder.MenuBuilder()
        self.qtConn = kmxQtConnections.QtConnections(self)
        self.qtIcon = kmxQtCommonTools.iconSetup(self)

        self.standalone = 0 if self.parent else 1

        if self.standalone:
            print('No parent specified! Creating standalone console!')
            self.parent = self.win = QtWidgets.QMainWindow()
            self.win.resize(689, 504)

            self.mainWidget = QtWidgets.QWidget(self.win)
            self.setupUi(self.mainWidget)
            self.win.setCentralWidget(self.mainWidget)
            self.toolbar = QtWidgets.QToolBar('Main Tools', self)
            self.toolbar2 = QtWidgets.QToolBar('Additional Tools', self)
            self.toolbar.setFloatable(True)
            self.toolbar2.setFloatable(True)
            self.win.addToolBar(self.toolbar)
            self.win.addToolBar(self.toolbar2)
            self.setStandAloneModeFeatures()

            self.btnExecute.setVisible(0)
            self.btnLoadScript.setVisible(0)
            self.btnSaveScript.setVisible(0)
            self.btnNewScript.setVisible(0)
            self.btnQuickSaveScript.setVisible(0)

            self.label.setVisible(1)
            self.label.setText('Output:')
            self.line.setVisible(0)
            #self.sciOutput.resize(self.sciOutput.width(), self.sciOutput.height() + 90)

        elif self.asDock:
            if hasattr(self.parent, 'addDockWidget'):
                print('Creating dock based console!')
                self.win = QtWidgets.QDockWidget(self.parent)
                base = QtWidgets.QWidget()
                self.setupUi(base)
                self.win.setWidget(base)
                self.parent.addDockWidget(QtCore.Qt.DockWidgetArea(2),
                                          self.win)

                # print ('Creating dock based console!')
                # self.dck = QtWidgets.QDockWidget(self.parent)
                #
                # dlg = QtWidgets.QWidget()
                #
                # self.win = QtWidgets.QMainWindow()
                # lyt = QtWidgets.QVBoxLayout()
                # lyt.addWidget(self.win)
                # wdgt = QtWidgets.QWidget(self.dck)
                # self.setupUi(wdgt)
                # self.win.setCentralWidget(wdgt)
                #
                # dlg.setLayout(lyt)
                #
                # self.dck.setWidget(dlg)
                # self.parent.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dck)

            else:
                print('Unsupported Parent for creating dock based console! ' +
                      str(self.parent))
                print('Connecting console to given parent as a dialog...' +
                      str(self.parent))
                self.win = QtWidgets.QDialog(self.parent)
                self.setupUi(self.win)
        else:
            print('Connecting console to given parent as a dialog...' +
                  str(self.parent))
            self.win = QtWidgets.QDialog(self.parent)
            self.setupUi(self.win)

        self.outputFont = self.sciOutput.font()
        self.outputFont.setFamily("Courier")
        self.outputFont.setPointSize(10)
        self.outputFont.setFixedPitch(True)
        self.sciOutput.setFont(self.outputFont)
        self.sciOutput.setMarginsFont(self.outputFont)

        print(
            "Outputs Redirected to HaPy. Check HaPy console log for furthur system messages."
        )
        if ShowPrint: sys.stdout = self
        if ShowError: sys.stderr = self

        self.inter = InteractiveInterpreter()
        self.inter.locals['dev'] = self
        globals()['dev'] = self

        self.win.setWindowIcon(self.parent.windowIcon())
        self.win.setWindowTitle('HaPy')

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

        self.sciOutput.setReadOnly(1)
        self._setQSci(self.sciOutput)

        # Connections
        self.tabWidget.tabCloseRequested.connect(self.tabClose)

        if not self.standalone:
            self.btnExecute.clicked.connect(self.btnRedirector)
            #self.btnExecute_2.clicked.connect(self.btnRedirector)
            self.btnLoadScript.clicked.connect(self.btnRedirector)
            self.btnSaveScript.clicked.connect(self.btnRedirector)
            self.btnNewScript.clicked.connect(self.btnRedirector)
            self.btnQuickSaveScript.clicked.connect(self.btnRedirector)

        self.qtTools.connectToRightClick(self.treeWidget,
                                         self.pluginRightClick)
        self.tabWidget.__class__.keyReleaseEvent = self.tabKeyPress

        if StatusBar:
            self.stsBtnDebugger = QtWidgets.QToolButton(self.parent)
            self.stsBtnDebugger.setText(btnText)
            self.stsBtnDebugger.setToolTip(btnText)
            self.stsBtnDebugger.setAutoRaise(1)
            self.stsBtnDebugger.setMaximumHeight(18)
            StatusBar.addPermanentWidget(self.stsBtnDebugger, 0)
            self.stsBtnDebugger.clicked.connect(self.btnRedirector)
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap(btnIcon), QtGui.QIcon.Normal,
                           QtGui.QIcon.On)
            self.stsBtnDebugger.setIcon(icon)
        else:
            self.stsBtnDebugger = None

        self.win.hide()

        # Plugin Lister
        #self.treeWidget.headerItem().setText(0, "DevS")
        self.treeWidget.itemDoubleClicked.connect(self.pluginSelected)

        self.treeWidget.setVisible(False)

        print('---------------------------------------')
        print('HaPy - Handy Python')
        print('Interactive Interpreter')
        print('---------------------------------------')
        print('Initiated!')

        print('\nLog Start Time: ' + str(strftime("%Y/%m/%d %H:%M:%S")))
        print('\n---------------------------------------\n')
        print('*** Python %s on %s.***' % (sys.version, sys.platform))
        print(sys.copyright)
        print('')
        print('Platform: ' + sys.platform)
        print('Version: ' + str(sys.getwindowsversion()))
        print('FileSys encodeing: ' + str(sys.getfilesystemencoding()))

        drline = "\n---------------------------------------\n"
        self.credit = drline + 'About HaPy:\nHandy Python - Interactive Interpreter/Scripting Environment \nAn expreimental project by \nKumaresan Lakshmanan\nFor Quick, Portable windows automation. \nDate: ' + last_update_date + drline
        print(self.credit)

        self.InitalizeScripts = InitalizeScripts
        self.scriptsDirName = ScriptsPath
        self.scriptsPath = os.path.abspath(self.scriptsDirName)
        print("Checking scripts path..." + os.path.abspath(self.scriptsPath))

        if self.scriptsPath:
            if self.InitalizeScripts and self.scriptsPath and not os.path.exists(
                    self.scriptsPath):
                os.makedirs(self.scriptsPath)
        else:
            print('Invalid script path!')

        #Start loading the scripts...
        try:
            self.execPlugin()
            self.treeWidget.setVisible(True)
        except:
            print(errorReport())

        try:
            if self.InitalizeScripts:
                self.execStartUp()
            else:
                self.addEmptyTab()
        except:
            print(errorReport())

        if self.standalone:
            self.qtConn.uiMain = self.win
            self.qtConn.installEventHandler()
            self.qtConn.addEventConnection(self.win, 'WindowDeactivate',
                                           self.onWinDeAct)
            self.qtConn.addEventConnection(self.win, 'Close', self.onClose)
            self.qtConn.addEventConnection(self.win, 'Hide', self.onHide)
            self.qtConn.addEventConnection(self.win, 'Show', self.onShow)

            if (os.path.exists('layout.lyt')):
                customList = self.qtTools.uiLayoutRestore(
                    'layout.lyt', [self.splitter, self.splitter_2])
                if (customList):
                    self.win.resize(customList[0])
                    self.win.move(customList[1])
            self.loadTabs()
        print("All set, You are ready to go...")
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8('MainWindow'))
        MainWindow.resize(640, 480)
        self.vindu = QtWidgets.QWidget(MainWindow)
        self.vindu.setStyleSheet(_fromUtf8('notusedasyet'))
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
        #MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        self.filename = ''
        self.vindu.setObjectName(_fromUtf8('vindu'))
        self.verticalLayout = PyQt5.QtWidgets.QVBoxLayout(self.vindu)
        app_icon = QtGui.QIcon()
        app_icon.addFile(':/ico/ico.png', QtCore.QSize(16, 16))
        MainWindow.setWindowIcon(app_icon)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName(_fromUtf8('verticalLayout'))
        self.codebox = Qsci.QsciScintilla(self.vindu)
        self.codebox.setToolTip(_fromUtf8(''))
        self.codebox.setWhatsThis(_fromUtf8(''))
        self.codebox.setAutoFillBackground(False)
        self.codebox.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.codebox.setObjectName(_fromUtf8('codebox'))
        self.verticalLayout.addWidget(self.codebox)
        MainWindow.setCentralWidget(self.vindu)
        self.toolBar = QtWidgets.QToolBar(MainWindow)
        self.toolBar.setAutoFillBackground(False)
        self.toolBar.setIconSize(QtCore.QSize(32, 32))
        self.toolBar.setObjectName(_fromUtf8('toolBar'))
        MainWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar)
        self.toolBar.addSeparator()

        #getting ready for debugger
        self.codebox.setMarginSensitivity(1, True)
        self.codebox.marginClicked.connect(self.on_margin_clicked)

        #self.codebox.connect(self.codebox, QtCore.SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'), self.on_margin_clicked)
        self.codebox.markerDefine(QsciScintilla.FullRectangle,
                                  self.ARROW_MARKER_NUM)
        self.codebox.setMarkerBackgroundColor(QColor("#ee1111"),
                                              self.ARROW_MARKER_NUM)
        #first action Newfile
        self.toolBar.newAction = QtWidgets.QAction(
            QtGui.QIcon(":/ico/new.png"), "New", self.toolBar)
        self.toolBar.newAction.setStatusTip(
            "Clear TextBox or make new document.")
        self.toolBar.newAction.setShortcut("Ctrl+N")
        self.toolBar.newAction.triggered.connect(self.newfile)
        #second Action OpenFile
        self.toolBar.secondAction = QtWidgets.QAction(
            QtGui.QIcon(":/ico/open.png"), "Open", self.toolBar)
        self.toolBar.secondAction.setStatusTip(
            "Create a new document from scratch.")
        self.toolBar.secondAction.setShortcut("Ctrl+O")
        self.toolBar.secondAction.triggered.connect(self.open)
        # action 3 save file
        self.toolBar.Action3 = QtWidgets.QAction(QtGui.QIcon(":/ico/save.png"),
                                                 "Save", self.toolBar)
        self.toolBar.Action3.setStatusTip("Save Your File.")
        self.toolBar.Action3.setShortcut("Ctrl+S")
        self.toolBar.Action3.triggered.connect(self.savefile)
        #action 4 run file
        self.toolBar.Action4 = QtWidgets.QAction(
            QtGui.QIcon(":/ico/run32.png"), "Run To Debugger", self.toolBar)
        self.toolBar.Action4.setStatusTip("Run your file within debugger.")
        self.toolBar.Action4.setShortcut("Ctrl+E")
        self.toolBar.Action4.triggered.connect(self.runto)
        #action 4 run file on windows
        '''self.toolBar.Action5 = QtWidgets.QAction(QtGui.QIcon("icons/Folder_Open.ico"),"Run On windows",self.toolBar)
        self.toolBar.Action5.setStatusTip("Run your file within windows.")
        self.toolBar.Action5.setShortcut("Ctrl+S")
        self.toolBar.Action5.triggered.connect(self.runtoglobal)
        '''
        #action 6 undo
        self.toolBar.Action6 = QtWidgets.QAction(QtGui.QIcon(":/ico/undo.png"),
                                                 "Undo", self.toolBar)
        self.toolBar.Action6.setStatusTip("Undo.")
        self.toolBar.Action6.setShortcut("Ctrl+Z")
        self.toolBar.Action6.triggered.connect(self.codebox.undo)
        #action 7 redo
        self.toolBar.Action7 = QtWidgets.QAction(QtGui.QIcon(":/ico/redo.png"),
                                                 "Redo", self.toolBar)
        self.toolBar.Action7.setStatusTip("Redo.")
        self.toolBar.Action7.setShortcut("Ctrl+Y")
        self.toolBar.Action7.triggered.connect(self.codebox.redo)
        #action8 rerset Folding
        self.toolBar.Action8 = QtWidgets.QAction(
            QtGui.QIcon(":/ico/align-justify.png"), "Reset Folding",
            self.toolBar)
        self.toolBar.Action8.setStatusTip("Reset Folding.")
        self.toolBar.Action8.setShortcut("Ctrl+R")
        self.toolBar.Action8.triggered.connect(self.nofoldingl)
        #actions9 CircledTreeFoldStyle
        self.toolBar.Action9 = QtWidgets.QAction(
            QtGui.QIcon(":/ico/bullet.png"), "Circled Tree Folding",
            self.toolBar)
        self.toolBar.Action9.setStatusTip("Circled Tree Folding.")
        self.toolBar.Action9.setShortcut("Ctrl+C")
        self.toolBar.Action9.triggered.connect(self.Circledfold)
        #actions10 plainFoldStyle
        self.toolBar.Action10 = QtWidgets.QAction(
            QtGui.QIcon(":/ico/number.png"), "Plain Folding", self.toolBar)
        self.toolBar.Action10.setStatusTip("Plain Folding")
        self.toolBar.Action10.setShortcut("Ctrl+P")
        self.toolBar.Action10.triggered.connect(self.plainfold)
        # fonts
        self.toolBar.Action21 = QtWidgets.QAction(
            QtGui.QIcon(":/ico4/font.png"), "Fonts", self.toolBar)
        self.toolBar.Action21.setStatusTip("Fonts")
        self.toolBar.Action21.setShortcut("Ctrl+F")
        self.toolBar.Action21.triggered.connect(self.font_choice)
        #web baby
        self.toolBar.Action11 = QtWidgets.QAction(QtGui.QIcon(":/ico/web.png"),
                                                  "Goto x64dbg homepage",
                                                  self.toolBar)
        self.toolBar.Action11.setStatusTip("Home of x64dbg")
        self.toolBar.Action11.setShortcut("Ctrl+W")
        self.toolBar.Action11.triggered.connect(self.webopen)
        #irc
        self.toolBar.Action12 = QtWidgets.QAction(QtGui.QIcon(":/ico/irc.png"),
                                                  "Open X64dbg Irc",
                                                  self.toolBar)
        self.toolBar.Action12.setStatusTip("Talk about x64dbg on irc")
        self.toolBar.Action12.setShortcut("Ctrl+I")
        self.toolBar.Action12.triggered.connect(self.ircopen)
        #github Python
        self.toolBar.Action14 = QtWidgets.QAction(
            QtGui.QIcon(":/ico/github.png"), "Open git python", self.toolBar)
        self.toolBar.Action14.setStatusTip("Open git python")
        self.toolBar.Action14.setShortcut("Ctrl+G")
        self.toolBar.Action14.triggered.connect(self.gitopen)
        #auther me :)
        self.toolBar.Action15 = QtWidgets.QAction(
            QtGui.QIcon(":/ico/auth.png"), "Author", self.toolBar)
        self.toolBar.Action15.setStatusTip("Author")
        self.toolBar.Action15.setShortcut("Ctrl+B")
        self.toolBar.Action15.triggered.connect(self.Author)
        #toggle off code regonision
        self.toolBar.Action16 = QtWidgets.QAction(
            QtGui.QIcon(":/ico2/pythonminus.png"), "Disable Code recognition",
            self.toolBar)
        self.toolBar.Action16.setStatusTip("Disable Code recognition")
        self.toolBar.Action16.setShortcut("Alt+D")
        self.toolBar.Action16.triggered.connect(self.Diablecode)
        #toogle on
        self.toolBar.Action17 = QtWidgets.QAction(
            QtGui.QIcon(":/ico2/pypluss.png"), "Enable Code recognition",
            self.toolBar)
        self.toolBar.Action17.setStatusTip("Enable Code recognition")
        self.toolBar.Action17.setShortcut("Alt+E")
        self.toolBar.Action17.triggered.connect(self.Reiablecode)
        # zoom in
        self.toolBar.Action18 = QtWidgets.QAction(QtGui.QIcon(":/ico3/in.png"),
                                                  "Zoom In", self.toolBar)
        self.toolBar.Action18.setStatusTip("Zoom In")
        self.toolBar.Action18.setShortcut("CTRL+SHIFT++")
        self.toolBar.Action18.triggered.connect(self.udder)
        #zoom out
        self.toolBar.Action19 = QtWidgets.QAction(
            QtGui.QIcon(":/ico3/out.png"), "Zoom Out", self.toolBar)
        self.toolBar.Action19.setStatusTip("Zoom Out")
        self.toolBar.Action19.setShortcut("CTRL+SHIFT+-")
        self.toolBar.Action19.triggered.connect(self.odder)

        self.toolBar.Action20 = QtWidgets.QAction(QtGui.QIcon(":/ico3/10.png"),
                                                  "Profile Code", self.toolBar)
        self.toolBar.Action20.setStatusTip("Profile Code")
        self.toolBar.Action20.setShortcut("CTRL+SHIFT+E")
        self.toolBar.Action20.triggered.connect(self.runtoprob)

        #actions
        self.toolBar.addAction(self.toolBar.newAction)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.secondAction)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action3)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action4)
        #self.toolBar.addSeparator()
        #For now global run isent here
        #self.toolBar.addAction(self.toolBar.Action5)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action6)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action7)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action8)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action9)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action10)
        self.toolBar.addAction(self.toolBar.Action21)
        self.toolBar.addSeparator()
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action11)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action12)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action14)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action15)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action16)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action17)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action18)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action19)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action20)

        #font
        self.skrift = QFont()
        self.skrift.setFamily('Consolas')
        self.skrift.setFixedPitch(True)
        self.skrift.setPointSize(12)
        self.codebox.setFont(self.skrift)

        #python style
        self.lexer = QsciLexerPython(self.codebox)
        self.lexer.setFont(self.skrift)
        self.lexer.setEolFill(True)
        #api test not working
        api = Qsci.QsciAPIs(self.lexer)
        apidir = os.path.dirname(os.path.realpath(__file__))
        API_FILE = apidir + r'\Python.api'
        api.load(API_FILE)
        api.prepare()
        self.codebox.setAutoCompletionThreshold(1)
        self.codebox.setAutoCompletionThreshold(6)
        self.codebox.setAutoCompletionThreshold(8)
        self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
        self.lexer.setDefaultFont(self.skrift)
        self.codebox.setLexer(self.lexer)
        self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1,
                                   'Consolas')

        #line numbers
        fontmetrics = QFontMetrics(self.skrift)
        self.codebox.setMarginsFont(self.skrift)
        self.codebox.setMarginWidth(0, fontmetrics.width("0000") + 6)
        self.codebox.setTabWidth(4)

        #brace
        self.codebox.setBraceMatching(QsciScintilla.SloppyBraceMatch)
        self.codebox.setCaretLineBackgroundColor(QColor("#ffe4e4"))

        #auto line tab =4
        self.codebox.setAutoIndent(True)

        #scroolbar
        self.codebox.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)