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)
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 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)
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')
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)
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)
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")
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)
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)
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()
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(640, 480) self.vindu = QtGui.QWidget(MainWindow) self.vindu.setStyleSheet(_fromUtf8('notusedasyet')) self.filename = "" self.vindu.setObjectName(_fromUtf8("vindu")) self.verticalLayout = QtGui.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.setMargin(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(QtGui.QFrame.NoFrame) self.codebox.setObjectName(_fromUtf8("codebox")) self.verticalLayout.addWidget(self.codebox) MainWindow.setCentralWidget(self.vindu) self.toolBar = QtGui.QToolBar(MainWindow) self.toolBar.setAutoFillBackground(False) self.toolBar.setIconSize(QtCore.QSize(32, 32)) self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.toolBar.setObjectName(_fromUtf8("toolBar")) MainWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar) self.toolBar.addSeparator() #first action Newfile self.toolBar.newAction = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.QAction(QtGui.QIcon(":/ico/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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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) #web baby self.toolBar.Action11 = QtGui.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 = QtGui.QAction(QtGui.QIcon(":/ico/find.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 = QtGui.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 = QtGui.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) #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.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) #font skrift = QFont() skrift.setFamily('Consolas') skrift.setFixedPitch(True) skrift.setPointSize(11) self.codebox.setFont(skrift) #python style lexer = QsciLexerPython(self.codebox) #api test not working lexer.setDefaultFont(skrift) self.codebox.setLexer(lexer) self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Consolas') #line numbers fontmetrics = QFontMetrics(skrift) self.codebox.setMarginsFont(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)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.name = _(self.name) self.query_editor = Qsci.QsciScintilla() self.query_editor.setLexer(Qsci.QsciLexerSQL()) self.query_editor.setCaretLineVisible(True) self.go_button = QtGui.QPushButton(_("Execute Query"), self) self.go_button.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Return) icon = QtGui.QIcon.fromTheme('x-office-spreadsheet') self.action_export_xls = QtGui.QAction(icon, "Export to Excel Spreadsheet", self) self.action_export_csv = QtGui.QAction(icon, "Export to csv", self) self.action_export_xls.setEnabled(export_xls.AVAILABLE) menu = QtGui.QMenu(self) menu.addAction(self.action_export_xls) menu.addAction(self.action_export_csv) export_toolbutton = QtGui.QToolButton(self) export_toolbutton.setText(_("&Export")) export_toolbutton.setPopupMode(export_toolbutton.InstantPopup) export_toolbutton.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) export_toolbutton.setMenu(menu) self.back_button = QtGui.QPushButton("<", self) self.back_button.setMaximumWidth(40) self.back_button.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Up) self.next_button = QtGui.QPushButton(">", self) self.next_button.setMaximumWidth(40) self.next_button.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Down) self.clear_text_button = QtGui.QPushButton("clear text", self) self.clear_text_button.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Delete) self.hist_combobox_headers = [ _("Query History"), _("Clear Items"), _("Clear All History") ] self.hist_combobox = QtGui.QComboBox(self) self.hist_combobox.addItems(self.hist_combobox_headers) self.model = QtSql.QSqlQueryModel(self) table_view = QtGui.QTableView(self) table_view.setModel(self.model) top_frame = QtGui.QWidget(self) layout = QtGui.QHBoxLayout(top_frame) layout.setMargin(0) layout.addWidget(self.go_button) layout.addWidget(export_toolbutton) sub_frame = QtGui.QFrame(self) layout = QtGui.QHBoxLayout(sub_frame) layout.setMargin(0) layout.addWidget(self.back_button) layout.addWidget(self.next_button) layout.addWidget(self.clear_text_button) frame = QtGui.QFrame(self) frame.setMaximumWidth(200) layout = QtGui.QVBoxLayout(frame) layout.setMargin(0) layout.addWidget(top_frame) layout.addWidget(sub_frame) layout.addItem( QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)) layout.addWidget(self.hist_combobox) top_frame = QtGui.QFrame(self) layout = QtGui.QHBoxLayout(top_frame) layout.setMargin(0) layout.addWidget(self.query_editor) layout.addWidget(frame) splitter = QtGui.QSplitter(self) splitter.setOrientation(QtCore.Qt.Vertical) splitter.addWidget(top_frame) splitter.addWidget(table_view) layout = QtGui.QVBoxLayout(self) layout.addWidget(splitter) splitter.setSizes([50, 400]) self.query_editor.setFocus() self.history = QtCore.QStringList() self.get_history() self.history_position = -1 self.connect_signals()
def create_widget(self): """ Create the underlying label widget. """ self.widget = Qsci.QsciScintilla(self.parent_widget())
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(640, 480) self.vindu = QtGui.QWidget(MainWindow) self.vindu.setStyleSheet(_fromUtf8('notusedasyet')) # MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.filename = "" self.vindu.closeEvent = self.closeEvent self.vindu.setObjectName(_fromUtf8("vindu")) self.verticalLayout = QtGui.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.setMargin(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(QtGui.QFrame.NoFrame) self.codebox.setObjectName(_fromUtf8("codebox")) self.verticalLayout.addWidget(self.codebox) MainWindow.setCentralWidget(self.vindu) self.toolBar = QtGui.QToolBar(MainWindow) self.toolBar.setAutoFillBackground(False) self.toolBar.setIconSize(QtCore.QSize(32, 32)) self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) 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.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 6 undo self.toolBar.Action6 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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.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) 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("0000") + 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) self.lbl = self.codebox
def setupUi(self, vindu): self.codebox = Qsci.QsciScintilla(vindu) vindu.setObjectName(_fromUtf8("vindu")) vindu.resize(1093, 734) vindu.setStyleSheet( _fromUtf8("QWidget { \n" " background-color: #c0c0c0;\n" " color: #ddd;\n" "}\n" "\n" "\n" "\n" "QPushButton {\n" "color: #333;\n" "border: 2px solid #555;\n" "border-radius: 0px;\n" "padding: 5px;\n" "background: qradialgradient(cx: 0.3, cy: -0.4,\n" "fx: 0.3, fy: -0.4,\n" "radius: 1.35, stop: 0 #fff, stop: 1 #888);\n" "min-width: 80px;\n" "}\n" " \n" "QPushButton:hover {\n" "background: qradialgradient(cx: 0.3, cy: -0.4,\n" "fx: 0.3, fy: -0.4,\n" "radius: 1.35, stop: 0 #fff, stop: 1 #bbb);\n" "}\n" " \n" "QPushButton:pressed {\n" "background: qradialgradient(cx: 0.4, cy: -0.1,\n" "fx: 0.4, fy: -0.1,\n" "radius: 1.35, stop: 0 #fff, stop: 1 #ddd);\n" "}")) self.codebox = Qsci.QsciScintilla(vindu) self.codebox.setGeometry(QtCore.QRect(-1, -1, 1101, 661)) self.codebox.setToolTip(_fromUtf8("")) self.codebox.setWhatsThis(_fromUtf8("")) self.codebox.setObjectName(_fromUtf8("codebox")) self.curFile = '' #font skrift = QFont() skrift.setFamily('Consolas') skrift.setFixedPitch(True) skrift.setPointSize(12) self.codebox.setFont(skrift) self.runbtr = QtGui.QPushButton(vindu) self.runbtr.setGeometry(QtCore.QRect(790, 680, 94, 34)) self.runbtr.setObjectName(_fromUtf8("runbtr")) self.impbtr = QtGui.QPushButton(vindu) self.impbtr.setGeometry(QtCore.QRect(890, 680, 94, 34)) self.impbtr.setObjectName(_fromUtf8("impbtr")) self.exbtr = QtGui.QPushButton(vindu) self.exbtr.setGeometry(QtCore.QRect(990, 680, 94, 34)) self.exbtr.setObjectName(_fromUtf8("exbtr")) #python style lexer = QsciLexerPython() lexer.setDefaultFont(skrift) self.codebox.setLexer(lexer) self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Consolas') #line numbers fontmetrics = QFontMetrics(skrift) self.codebox.setMarginsFont(skrift) self.codebox.setMarginWidth(0, fontmetrics.width("00000") + 6) self.codebox.setTabWidth(4) #self.codebox.setWhitespaceVisibility(True) #self.codebox.setWhitespaceSize(40) #self.codebox.setWhitespaceBackgroundColor(QColor(255, 0, 0, 127)) self.codebox.setMarginLineNumbers(0, True) self.codebox.setMarginsBackgroundColor(QColor("#cccccc")) #brace self.codebox.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.codebox.setCaretLineBackgroundColor(QColor("#ffe4e4")) #try to load api api = Qsci.QsciAPIs(lexer) api.load('idaapi.py') api.prepare() self.codebox.setAutoCompletionThreshold(1) self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs) self.codebox.setLexer(lexer) self.retranslateUi(vindu) QtCore.QObject.connect(self.runbtr, QtCore.SIGNAL(_fromUtf8("clicked()")), self.codebox.selectAll) QtCore.QMetaObject.connectSlotsByName(vindu)
def setupUi(self, interaction_dialog): interaction_dialog.setObjectName(_fromUtf8("interaction_dialog")) interaction_dialog.resize(1000, 641) self.verticalLayout_4 = QtGui.QVBoxLayout(interaction_dialog) self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.label = QtGui.QLabel(interaction_dialog) self.label.setText(_fromUtf8("")) self.label.setPixmap( QtGui.QPixmap(_fromUtf8("%s/Icons/Database.png" % (os.getcwd())))) self.label.setObjectName(_fromUtf8("label")) self.horizontalLayout.addWidget(self.label) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.interact_server_name = QtGui.QLabel(interaction_dialog) font = QtGui.QFont() font.setPointSize(8) self.interact_server_name.setFont(font) self.interact_server_name.setObjectName( _fromUtf8("interact_server_name")) self.verticalLayout.addWidget(self.interact_server_name) self.interact_server_connection = QtGui.QLabel(interaction_dialog) font = QtGui.QFont() font.setPointSize(8) self.interact_server_connection.setFont(font) self.interact_server_connection.setObjectName( _fromUtf8("interact_server_connection")) self.verticalLayout.addWidget(self.interact_server_connection) self.label_4 = QtGui.QLabel(interaction_dialog) font = QtGui.QFont() font.setPointSize(8) self.label_4.setFont(font) self.label_4.setObjectName(_fromUtf8("label_4")) self.verticalLayout.addWidget(self.label_4) self.horizontalLayout.addLayout(self.verticalLayout) self.horizontalLayout_3.addLayout(self.horizontalLayout) spacerItem = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem) self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.interact_comboBox = QtGui.QComboBox(interaction_dialog) font = QtGui.QFont() font.setPointSize(8) self.interact_comboBox.setFont(font) self.interact_comboBox.setObjectName(_fromUtf8("interact_comboBox")) self.verticalLayout_2.addWidget(self.interact_comboBox) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.lineEdit = QtGui.QLineEdit(interaction_dialog) font = QtGui.QFont() font.setPointSize(8) self.lineEdit.setFont(font) self.lineEdit.setObjectName(_fromUtf8("lineEdit")) self.horizontalLayout_2.addWidget(self.lineEdit) self.interact_browse = QtGui.QPushButton(interaction_dialog) font = QtGui.QFont() font.setPointSize(8) self.interact_browse.setFont(font) self.interact_browse.setObjectName(_fromUtf8("interact_browse")) self.horizontalLayout_2.addWidget(self.interact_browse) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.horizontalLayout_3.addLayout(self.verticalLayout_2) self.verticalLayout_4.addLayout(self.horizontalLayout_3) self.groupBox = QtGui.QGroupBox(interaction_dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.groupBox.sizePolicy().hasHeightForWidth()) self.groupBox.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(8) self.groupBox.setFont(font) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.verticalLayout_3 = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.horizontalLayout_7 = QtGui.QHBoxLayout() self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) self.response_table = QtGui.QTableWidget(self.groupBox) font = QtGui.QFont() font.setPointSize(8) self.response_table.setFont(font) self.response_table.setObjectName(_fromUtf8("response_table")) self.response_table.setColumnCount(0) self.response_table.setRowCount(0) self.horizontalLayout_7.addWidget(self.response_table) spacerItem1 = QtGui.QSpacerItem(0, 241, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.horizontalLayout_7.addItem(spacerItem1) self.verticalLayout_3.addLayout(self.horizontalLayout_7) self.horizontalLayout_8 = QtGui.QHBoxLayout() self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) self.interact_textBrowser = QtGui.QTextBrowser(self.groupBox) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.interact_textBrowser.sizePolicy().hasHeightForWidth()) self.interact_textBrowser.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(8) self.interact_textBrowser.setFont(font) self.interact_textBrowser.setObjectName( _fromUtf8("interact_textBrowser")) self.horizontalLayout_8.addWidget(self.interact_textBrowser) spacerItem2 = QtGui.QSpacerItem(0, 47, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) self.horizontalLayout_8.addItem(spacerItem2) self.verticalLayout_3.addLayout(self.horizontalLayout_8) self.verticalLayout_4.addWidget(self.groupBox) self.groupBox_2 = QtGui.QGroupBox(interaction_dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.groupBox_2.sizePolicy().hasHeightForWidth()) self.groupBox_2.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(8) self.groupBox_2.setFont(font) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) self.horizontalLayout_12 = QtGui.QHBoxLayout(self.groupBox_2) self.horizontalLayout_12.setObjectName( _fromUtf8("horizontalLayout_12")) self.horizontalLayout_11 = QtGui.QHBoxLayout() self.horizontalLayout_11.setObjectName( _fromUtf8("horizontalLayout_11")) self.sqleditor = Qsci.QsciScintilla(self.groupBox_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.sqleditor.sizePolicy().hasHeightForWidth()) self.sqleditor.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setFamily(_fromUtf8("MS Shell Dlg 2")) font.setPointSize(8) font.setWeight(50) font.setItalic(False) font.setUnderline(False) font.setStrikeOut(False) font.setBold(False) self.sqleditor.setFont(font) self.sqleditor.setToolTip(_fromUtf8("")) self.sqleditor.setWhatsThis(_fromUtf8("")) self.sqleditor.setObjectName(_fromUtf8("sqleditor")) self.horizontalLayout_11.addWidget(self.sqleditor) spacerItem3 = QtGui.QSpacerItem(0, 123, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.horizontalLayout_11.addItem(spacerItem3) self.horizontalLayout_12.addLayout(self.horizontalLayout_11) self.verticalLayout_4.addWidget(self.groupBox_2) self.horizontalLayout_5 = QtGui.QHBoxLayout() self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) spacerItem4 = QtGui.QSpacerItem(0, 32, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) self.horizontalLayout_5.addItem(spacerItem4) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.execute_sql_button = QtGui.QPushButton(interaction_dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.execute_sql_button.sizePolicy().hasHeightForWidth()) self.execute_sql_button.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(8) self.execute_sql_button.setFont(font) self.execute_sql_button.setObjectName(_fromUtf8("execute_sql_button")) self.horizontalLayout_4.addWidget(self.execute_sql_button) self.tables_button = QtGui.QPushButton(interaction_dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.tables_button.sizePolicy().hasHeightForWidth()) self.tables_button.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(8) self.tables_button.setFont(font) self.tables_button.setObjectName(_fromUtf8("tables_button")) self.horizontalLayout_4.addWidget(self.tables_button) self.save_report_button = QtGui.QPushButton(interaction_dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.save_report_button.sizePolicy().hasHeightForWidth()) self.save_report_button.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(8) self.save_report_button.setFont(font) self.save_report_button.setObjectName(_fromUtf8("save_report_button")) self.horizontalLayout_4.addWidget(self.save_report_button) self.close_interact_button = QtGui.QPushButton(interaction_dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.close_interact_button.sizePolicy().hasHeightForWidth()) self.close_interact_button.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(8) self.close_interact_button.setFont(font) self.close_interact_button.setObjectName( _fromUtf8("close_interact_button")) self.horizontalLayout_4.addWidget(self.close_interact_button) self.horizontalLayout_5.addLayout(self.horizontalLayout_4) self.verticalLayout_4.addLayout(self.horizontalLayout_5) self.retranslateUi(interaction_dialog) QtCore.QMetaObject.connectSlotsByName(interaction_dialog)
def Script_Editor(self, source, name): editor = Qsci.QsciScintilla(eval(name)) ## define the font to use font = QtGui.QFont() font.setFamily("Courier") font.setFixedPitch(True) font.setPointSize(10) # the font metrics here will help # building the margin width later fm = QtGui.QFontMetrics(font) ## set the default font of the editor ## and take the same font for line numbers editor.setFont(font) editor.setMarginsFont(font) #TODO : Adjust based on operating system editor.convertEols(Qsci.QsciScintilla.EolUnix) editor.setEolMode(Qsci.QsciScintilla.EolUnix) # Was EolUnix #editor.setEolVisibility(True) ## Line numbers # conventionnaly, margin 0 is for line numbers editor.setMarginWidth(0, fm.width("00000")) editor.setMarginLineNumbers(0, True) ## Edge Mode shows a red vetical bar at 80 chars editor.setEdgeMode(Qsci.QsciScintilla.EdgeLine) editor.setEdgeColumn(80) editor.setTabIndents(False) editor.setEdgeColor(QtGui.QColor("#FF0000")) editor.setTabWidth(4) ## Folding visual : we will use boxes editor.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle) ## Braces matching editor.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch) ## Editing line color editor.setCaretLineVisible(True) editor.setCaretLineBackgroundColor(QtGui.QColor("#caeee0")) ## Margins colors # line numbers margin editor.setMarginsBackgroundColor(QtGui.QColor("#333333")) editor.setMarginsForegroundColor(QtGui.QColor("#CCCCCC")) # folding margin colors (foreground,background) editor.setFoldMarginColors(QtGui.QColor("#bfe4ea"), QtGui.QColor("#66bfcd")) ## Choose a lexer lexer = Qsci.QsciLexerPython() lexer.setDefaultFont(font) editor.setLexer(lexer) #editor.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, 'Courier') text = """print '///////////////Script Execution Started//////////////////////'\n# Write Your Script here\n\n\n\n\n\n\n\n\n\n\n\n# Uncomment this and add variable to display the figure\n#from matplotlib import pyplot\n#fig=pyplot.figure()\n#pyplot.plot(variable)\n#pyplot.show()\nprint '///////////////Script Execution Ended//////////////////////'""" #encapsulated search function def Search(text=text, search_text=None): print 'searching :', search_text if text == None: return #editor.setIndicatorOutlineColor(QtGui.QColor("#FFE11F")) editor.findFirst(search_text, False, True, False, True) def Search_next(): #editor.setIndicatorOutlineColor(QtGui.QColor("#FFE11F")) editor.findNext() def Open_Search(text=text): value, ok = QtGui.QInputDialog.getText(editor, 'Search', 'Text to search') Search(text=text, search_text=str(value)) def Open_Replace(text=text): def ShowFirstOccurence(): editor.findFirst(inline.text(), False, True, False, True) def OK(): Replace('text', search_text=inline.text(), newtext=outline.text()) def Cancel(): self.wid.close() self.wid = QtGui.QWidget() Vert = QtGui.QVBoxLayout(self.wid) inline = QtGui.QLineEdit() outline = QtGui.QLineEdit() Vert.addWidget(inline) Vert.addWidget(outline) Hor = QtGui.QHBoxLayout() ok = QtGui.QPushButton('OK') cancel = QtGui.QPushButton('Cancel') Hor.addWidget(ok) Hor.addWidget(cancel) Vert.addLayout(Hor) self.wid.show() QtCore.QObject.connect(inline, QtCore.SIGNAL('textEdited(QString)'), ShowFirstOccurence) QtCore.QObject.connect(ok, QtCore.SIGNAL("clicked()"), OK) QtCore.QObject.connect(cancel, QtCore.SIGNAL("clicked()"), Cancel) def Replace(text=text, search_text=None, newtext=None): editor.findFirst(search_text, False, True, False, True) editor.replace(newtext) shcut1 = QtGui.QShortcut(editor) shcut1.setKey("CTRL+F") QtCore.QObject.connect(shcut1, QtCore.SIGNAL("activated()"), Open_Search) shcut1 = QtGui.QShortcut(editor) shcut1.setKey("CTRL+G") QtCore.QObject.connect(shcut1, QtCore.SIGNAL("activated()"), Search_next) shcut1 = QtGui.QShortcut(editor) shcut1.setKey("CTRL+H") QtCore.QObject.connect(shcut1, QtCore.SIGNAL("activated()"), Open_Replace) try: #text=str(open(self.Current_Script_Adress).read()) text = str(open(self.Current_Script_Adress).read()).replace( ' ', ' ') #4 spaces replaced by tab editor.setText(text) return editor except TypeError: text = """print '///////////////Script Execution Started//////////////////////'\n# Write Your Script here\n\n\n\n\n\n\n\n\n\n\n\n# Uncomment this and add variable to display the figure\n#from matplotlib import pyplot\n#fig=pyplot.figure()\n#pyplot.plot(variable)\n#pyplot.show()\nprint '///////////////Script Execution Ended//////////////////////'""" editor.setText(text) return editor except IOError: msgBox = QtGui.QMessageBox() msgBox.setText(""" SynaptiQs was unable to open <b>%s plugin</b> <p>Destination file was maybe renamed or deleted <p>Do not put spaces or special caracters in files names... """ % (source)) msgBox.exec_() return
def __init__(self, framework, parent=None): super(SequenceDialog, self).__init__(parent) self.setupUi(self) self.framework = framework QObject.connect(self, SIGNAL('destroyed(QObject*)'), self._destroyed) self.scintillaWidgets = set( ) # store scintilla widget reference to handle zoom in/zoom out # TODO: move to framework constants self.known_media_types = ('text/css', 'application/javascript', 'text/javascript', 'image/gif', 'image/png', 'image/jpeg', 'image/bmp') self.cookieJar = SequenceBuilderCookieJar(self.framework, self) self.networkAccessManager = SequenceBuilderNetworkAccessManager( self.framework, self.cookieJar) self.formCapture = SequenceBuilderFormCapture(self.framework, self) self.pageFactory = SequenceBuilderPageFactory(self.framework, self.formCapture, self) self.standardPageFactory = StandardPageFactory( self.framework, self.networkAccessManager, self) QObject.connect(self.networkAccessManager, SIGNAL('finished(QNetworkReply *)'), self.process_request_finished) self.embedded = EmbeddedWebkitWidget.EmbeddedWebkitWidget( self.framework, self.networkAccessManager, self.pageFactory, self.webBrowserFrame, self) self.sequenceTabWidget.currentChanged.connect( self.handle_currentChanged) self.is_recording = False self.sequence_items = {} self.qlock = QMutex() self.startRecordingButton.clicked.connect( self.handle_startRecording_clicked) self.stopRecordingButton.clicked.connect( self.handle_stopRecording_clicked) self.saveSequenceButton.clicked.connect( self.handle_saveSequence_clicked) self.deleteSequenceButton.clicked.connect( self.handle_deleteSequence_clicked) self.deleteSequenceButton.setEnabled(False) # attach RenderingWebView to renderViewSequenceTabWidget self.sequenceRenderView_Layout = QVBoxLayout( self.renderViewSequenceTabWidget) self.sequenceRenderView = RenderingWebView( self.framework, self.standardPageFactory, self.renderViewSequenceTabWidget) self.sequenceRenderView_Layout.addWidget(self.sequenceRenderView) self.sequencePropertiesTabWidget.currentChanged.connect( self.handle_properties_currentChanged) self.sequenceRenderView.page().selectionChanged.connect( self.handle_renderView_selectionChanged) # use Scintilla for request and response views self.sequenceRequestView_Layout = QVBoxLayout( self.requestViewSequenceTabWidget) self.sequenceRequestViewEdit = Qsci.QsciScintilla( self.requestViewSequenceTabWidget) self.setScintillaProperties(self.sequenceRequestViewEdit) self.sequenceRequestView_Layout.addWidget(self.sequenceRequestViewEdit) self.sequenceResponseView_Layout = QVBoxLayout( self.responseViewSequenceTabWidget) self.sequenceResponseViewEdit = Qsci.QsciScintilla( self.responseViewSequenceTabWidget) self.setScintillaProperties(self.sequenceResponseViewEdit, 'html') self.sequenceResponseView_Layout.addWidget( self.sequenceResponseViewEdit) self.sequenceStepsTreeWidget.itemClicked.connect( self.handle_steps_itemClicked) self.sequenceStepsTreeWidget.setContextMenuPolicy(Qt.CustomContextMenu) self.menu = QMenu(self.sequenceStepsTreeWidget) self.connect(self.sequenceStepsTreeWidget, SIGNAL("customContextMenuRequested(const QPoint&)"), self.sequence_steps_context_menu) action = QAction("Remove from sequence", self) action.triggered.connect(self.handle_remove_from_sequence) self.menu.addAction(action) action = QAction("Copy URL", self) action.triggered.connect(self.sequence_step_copy_url) self.menu.addAction(action) self.inSessionPatternEdit.textChanged.connect( self.handle_sessionEdit_textChanged) self.inSessionPatternRE.stateChanged.connect( self.handle_sessionRE_stateChanged) self.outOfSessionPatternEdit.textChanged.connect( self.handle_sessionEdit_textChanged) self.outOfSessionPatternRE.stateChanged.connect( self.handle_sessionRE_stateChanged) QObject.connect(self.sequencesComboBox, SIGNAL('currentIndexChanged(const QString &)'), self.handle_sequenceCombo_text_currentIndexChanged) QObject.connect(self.sequencesComboBox, SIGNAL('currentIndexChanged(int)'), self.handle_sequenceCombo_currentIndexChanged) self.useSessionDetectionCheckbox.stateChanged.connect( self.handle_useSessionDection_stateChanged) self.setUseSessionDetection() self.includeMediaCheckbox.stateChanged.connect( self.handle_includeMedia_stateChanged) self.framework.subscribe_add_sequence_builder_response_id( self.add_manual_sequence_builder_item) self.originatingResponses = {} self.sequenceResponseIds = set() self.Data = None self.cursor = None self.framework.subscribe_database_events(self.db_attach, self.db_detach) self.framework.subscribe_zoom_in(self.zoom_in_scintilla) self.framework.subscribe_zoom_out(self.zoom_out_scintilla)