def __init__(self): super(MainWindow, self).__init__() # Store ourself. self.windows.append(self) # State! self.current_file = None # Editor! self.editor = QTextEdit() self.setCentralWidget(self.editor) # Style the editor #style.apply_stylesheet(self.editor, 'editor.qss') # Menus and Stuff! self.init_actions() self.init_menus() self.init_toolbars() self.init_statusbar() # Settings! self.init_settings() # Icons! self.reload_icons() #style.style_reloaded.connect(self.reload_icons) # Fancy! #style.enable_aero(self) self.update_title()
def __init__(self): super(TwoStepLandmarkWidget, self).__init__() self.textFrame = QTextEdit( "<p>Place your mouse over the desired " "landmark point. Press 'Space' to shoot a ray through the volume. " "Move the volume around and move the mouse to move the locator. " "Press 'Space' again to define the final place of the landmark.</p>" "<p>You can also use the ray profile to define the landmark's location.</p>" ) self.textFrame.setReadOnly(True) self.textFrame.setFrameShape(QFrame.NoFrame) self.textFrame.setAutoFillBackground(False) self.textFrame.setAttribute(Qt.WA_TranslucentBackground) self.textFrame.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.textFrame.setStyleSheet("background: #aaa") self.histogramWidget = TrackingHistogramWidget() self.histogramWidget.setMinimumHeight(100) self.histogramWidget.setVisible(False) self.button = QPushButton("Pick current landmark position") self.button.clicked.connect(self.applyButtonClicked) self.button.setVisible(False) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.textFrame) layout.addWidget(self.histogramWidget) layout.addWidget(self.button) self.setLayout(layout)
class ScratchPadWidget(QtGui.QWidget): def __init__(self, parent): """ Constructor This widget is kind of different. It does not exactly subclass CustomWidget """ QtGui.QWidget.__init__(self) self.name = "Scratchpad" self.parent = parent self.config = self.parent.config self.iconp = self.config.icons_path self.icon = QIcon(self.iconp + 'pencil.png') self._createGui() def _createGui(self): self._createScratchPadWindow() scratchpad_layout = QtGui.QVBoxLayout() save_btn = QtGui.QPushButton("Save to file", self) save_btn.setIcon(QIcon(self.iconp + 'save-download.png')) label = QtGui.QLabel("Write some notes here") scratchpad_layout.addWidget(label) scratchpad_layout.addWidget(self.scratchpad_window) scratchpad_layout.addWidget(save_btn) # Connect signals and slots save_btn.clicked.connect(self._saveButtonClicked) self.setLayout(scratchpad_layout) def _createScratchPadWindow(self): """ Some binary analysis commands will output to this. """ self.scratchpad_window = QTextEdit() self.scratchpad_window.setFontPointSize(9) ################################################################# # GUI Callbacks def _saveButtonClicked(self): try: filename, flt = QFileDialog.getSaveFileName(self, "File to save notes", "", selectedFilter='*.txt') sp_text = self.scratchpad_window.toPlainText() with open(filename, 'w') as f: f.write(sp_text) print "Saved notes to \"%s\"" % filename except: print "[!] Problem saving notes..." print traceback.format_exc()
def setupUi(self): self.mainlayout = QVBoxLayout(self) self.title = QLabel("CardBord Operator", self) self.mainlayout.addWidget(self.title) self.user_txtarea = QTextEdit(self) self.ai_txtarea = QTextEdit(self) self.users_edit_title = QLabel("質問に答えてください") self.users_edit = QLineEdit("", self) self.txtarea_layout = QHBoxLayout() self.txtarea_layout.addWidget(self.user_txtarea) self.txtarea_layout.addWidget(self.ai_txtarea) self.mainlayout.addLayout(self.txtarea_layout) self.mainlayout.addWidget(self.users_edit_title) self.mainlayout.addWidget(self.users_edit) self.send_btn = QPushButton("send", self) self.send_btn.setObjectName("send_btn") self.mainlayout.addWidget(self.send_btn) QMetaObject.connectSlotsByName(self)
class QAbstractTextDocumentLayoutTest(UsesQApplication): objectType = QTextFormat.UserObject + 1 def foo(self): fmt = QTextCharFormat() fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType) cursor = self.textEdit.textCursor() cursor.insertText(py3k.unichr(0xFFFC), fmt) self.textEdit.setTextCursor(cursor) self.textEdit.close() def testIt(self): self.textEdit = QTextEdit() self.textEdit.show() interface = Foo() self.textEdit.document().documentLayout().registerHandler(QAbstractTextDocumentLayoutTest.objectType, interface) QTimer.singleShot(0, self.foo) self.app.exec_() self.assertTrue(Foo.called)
def __init__(self, parent=None): super(LoggingArea, self).__init__() self.layout = QVBoxLayout(self) self.hbox_buttons_top = QHBoxLayout(self) self.button_start = QPushButton('Start Logging', self) self.button_start.clicked.connect(parent._start_logging) self.hbox_buttons_top.addWidget(self.button_start) self.button_stop = QPushButton('Stop Logging', self) self.button_stop.clicked.connect(parent._stop_logging) self.hbox_buttons_top.addWidget(self.button_stop) self.layout.addLayout(self.hbox_buttons_top) self.te_logging = QTextEdit(self) self.layout.addWidget(self.te_logging) self.hbox_buttons_bottom = QHBoxLayout(self) self.button_clear = QPushButton('Clear Data', self) self.button_clear.clicked.connect(self._clear_data) self.hbox_buttons_bottom.addWidget(self.button_clear) self.button_clipboard = QPushButton('Copy to Clipboard', self) self.button_clipboard.clicked.connect(self._copy_to_cliboard) self.hbox_buttons_bottom.addWidget(self.button_clipboard) self.button_file = QPushButton('Save to CSV', self) self.button_file.clicked.connect(self._save_to_csv) self.button_file.setEnabled(False) self.hbox_buttons_bottom.addWidget(self.button_file) self.layout.addLayout(self.hbox_buttons_bottom) self.setLayout(self.layout)
class QAbstractTextDocumentLayoutTest(UsesQApplication): objectType = QTextFormat.UserObject + 1 def foo(self): fmt = QTextCharFormat() fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType) cursor = self.textEdit.textCursor() cursor.insertText(py3k.unichr(0xfffc), fmt) self.textEdit.setTextCursor(cursor) self.textEdit.close() def testIt(self): self.textEdit = QTextEdit() self.textEdit.show() interface = Foo() self.textEdit.document().documentLayout().registerHandler( QAbstractTextDocumentLayoutTest.objectType, interface) QTimer.singleShot(0, self.foo) self.app.exec_() self.assertTrue(Foo.called)
class MyMainWindow(QMainWindow): def __init__(self, parent=None): super(MyMainWindow, self).__init__(parent) self.initTitle() self.initMainToolBar() self.initCentralWidget() def initTitle(self): pid = QApplication.instance().applicationPid() self.setWindowTitle("My Projects - ({0})".format(pid)) def initMainToolBar(self): self.tb1 = self.addToolBar("ToolBar 1") self.tb1.addWidget(QLabel("ToolBar 1")) self.tb1.orientationChanged.connect(self.mainToolBarOrientationChanged) self.tb1.addSeparator() for index in range(5): pb = QPushButton("B {0}".format(index)) self.tb1.addWidget(pb) def mainToolBarOrientationChanged(self, orientation): print "Orientation changed {0}".format(orientation) def initCentralWidget(self): self.intro = QTextEdit() self.setCentralWidget(self.intro) self.intro.setText("This application is still being designed")
def __init__(self, parent=None): super(AddDialogWidget, self).__init__(parent) nameLabel = QLabel("Name") addressLabel = QLabel("Address") buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.nameText = QLineEdit() self.addressText = QTextEdit() grid = QGridLayout() grid.setColumnStretch(1, 2) grid.addWidget(nameLabel, 0, 0) grid.addWidget(self.nameText, 0, 1) grid.addWidget(addressLabel, 1, 0, Qt.AlignLeft | Qt.AlignTop) grid.addWidget(self.addressText, 1, 1, Qt.AlignLeft) layout = QVBoxLayout() layout.addLayout(grid) layout.addWidget(buttonBox) self.setLayout(layout) self.setWindowTitle("Add a Contact") buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
def addAction(self, action): """ Adds an action to the text edit context menu :param action: QAction """ QTextEdit.addAction(self, action) self.__context_menu.addAction(action)
def __init__(self, filename=None): QTextEdit.__init__(self) self.setStyleSheet('font: 9pt "Courier";') if filename: self.__current_file = filename self.__loadfile(filename) else: self.__current_file = None
def Layout(self): #LAYOUT self.directory_prompt = QLabel(self) self.directory_prompt.setText("Directory Selected:") self.directory_prompt.move(25, 50) self.directory_prompt.resize(150, 30) self.directory_prompt.setVisible(False) self.browse_btn = QPushButton("Browse", self) self.browse_btn.move(130, 50) self.browse_btn.resize(50, 30) self.browse_btn.setStatusTip(" Browse Folder") # self.browse_btn.setStyleSheet("background-color: rgb(186, 186, 186); border-radius: 15px;border-style: solid;border-width: 2px;border-color: black;"); self.browse_btn.clicked.connect(self.browse) self.dir_shower = QLabel(self) self.dir_shower.setText("") self.dir_shower.setVisible(False) self.label_version = QLabel(self) self.label_version.setText("Version to rename") self.label_version.setVisible(False) self.version = QTextEdit() self.version.setStatusTip("Version to rename example: 1_6") self.version.setFixedHeight(30) self.version.setFixedWidth(40) self.version.setVisible(False) self.run_mars = QPushButton("RENAME", self) self.run_mars.setVisible(False) self.run_mars.move(50, 200) self.run_mars.resize(self.screen_w / 2 - 150, 50) self.run_mars.setStatusTip('') self.run_mars.setStyleSheet( "background-color: rgb(142, 229, 171); border-radius: 15px;") self.run_mars.clicked.connect(self.run_event) self.menu_layout = QtGui.QHBoxLayout() self.menu_layout.addWidget(self.browse_btn) self.menu_layout.addWidget(self.directory_prompt) self.menu_layout.addWidget(self.dir_shower) self.menu_layout.addStretch() self.version_layout = QtGui.QHBoxLayout() self.version_layout.addWidget(self.label_version) self.version_layout.addWidget(self.version) self.version_layout.addStretch() self.run_layout = QtGui.QHBoxLayout() self.run_layout.addWidget(self.run_mars) self.main_layout = QtGui.QVBoxLayout() self.main_layout.addLayout(self.menu_layout) self.main_layout.addLayout(self.version_layout) self.main_layout.addLayout(self.run_layout) self.main_layout.addStretch()
def keyPressEvent(self, event): if self._ignorable(event): event.ignore() return if self._requests_completion(event): self._completer.show_completion_for(self._text_under_cursor(), self.cursorRect()) elif self._requests_info(event): self._show_info() QTextEdit.keyPressEvent(self, event)
def __init__(self, variable_setting, parent=None): super(FoamDictWidget, self).__init__(parent) self.buttonLayout = QHBoxLayout() self.pushButtonInsert = QPushButton("Add new row") self.pushButtonRemove = QPushButton("Del selected row") self.pushButtonRestore = QPushButton("Restore table") self.pushButtonClear = QPushButton("Clear table") self.buttonLayout.addWidget(self.pushButtonInsert) self.buttonLayout.addWidget(self.pushButtonRemove) self.buttonLayout.addWidget(self.pushButtonRestore) self.buttonLayout.addWidget(self.pushButtonClear) self.tableWidget = QTableWidget() # header, should not sort, has vertical scrollbar # set column count, fixed to 2, size of TableItem self.tableWidget.setColumnCount(2) # self.tableWidget.setHorizontalHeaderItem(0, ) self.tableWidget.setHorizontalHeaderLabels(['key', 'value text']) # set a default row count, insert as needed self.tableWidget.setRowCount(0) self.buttonPreview = QPushButton('Preview FoamFile write-out') # self.buttonLoad = QPushButton('load dict from existing case ') self.buttonCustomize = QPushButton('Customize (convert into raw)') self.textPreview = QTextEdit('') self.textPreview.setVisible(False) self.textPreview.setEnabled(False) #PySide has different name other than @QtCore.pyqtSlot, but PySide.QtCore.SLOT #PySide has different name other than @QtCore.pyqtSlot, but PySide.QtCore.SLOT self.pushButtonInsert.clicked.connect(self.insertRow) self.pushButtonRemove.clicked.connect(self.removeRow) self.pushButtonRestore.clicked.connect(self.restoreDict) self.pushButtonClear.clicked.connect(self.clearDict) # self.tableWidget.doubleClicked.connect( self.showPreview) # does not work for PySide self.buttonPreview.clicked.connect(self.showPreview) self.buttonCustomize.clicked.connect(self.customizeDict) self._previewing = False self.settings = variable_setting self.previous_settings = self.settings #self.restoreDict() self.updateDictView(self.settings) self.myLayout = QVBoxLayout() self.myLayout.addLayout(self.buttonLayout) self.myLayout.addWidget(self.tableWidget) self.myLayout.addWidget(self.buttonPreview) self.myLayout.addWidget(self.textPreview) self.setLayout(self.myLayout)
def SetupComponents(self): """ Function to setup status bar, central widget, menu bar """ self.myStatusBar = QStatusBar() self.setStatusBar(self.myStatusBar) self.myStatusBar.showMessage('Ready', 10000) self.textEdit = QTextEdit() self.setCentralWidget(self.textEdit) # self.CreateActions() # self.CreateMenus() # self.fileMenu.addAction(self.newAction) # self.fileMenu.addSeparator() # self.fileMenu.addAction(self.exitAction) # self.editMenu.addAction(self.copyAction) # self.fileMenu.addSeparator() # self.editMenu.addAction(self.pasteAction) # self.helpMenu.addAction(self.aboutAction) self.myStatusBar = QStatusBar() self.setStatusBar(self.myStatusBar) self.myStatusBar.showMessage('Ready', 10000) self.CreateActions() self.CreateMenus() self.CreateToolBar() self.fileMenu.addAction(self.newAction) self.fileMenu.addAction(self.openAction) self.fileMenu.addAction(self.saveAction) self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAction) self.editMenu.addAction(self.cutAction) self.editMenu.addAction(self.copyAction) self.editMenu.addAction(self.pasteAction) self.editMenu.addSeparator() self.editMenu.addAction(self.undoAction) self.editMenu.addAction(self.redoAction) self.editMenu.addAction(self.ss_image) self.editMenu.addSeparator() self.editMenu.addAction(self.selectAllAction) self.formatMenu.addAction(self.fontAction) self.helpMenu.addAction(self.aboutAction) self.helpMenu.addSeparator() self.helpMenu.addAction(self.aboutQtAction) self.mainToolBar.addAction(self.newAction) self.mainToolBar.addAction(self.openAction) self.mainToolBar.addAction(self.saveAction) self.mainToolBar.addSeparator() self.mainToolBar.addAction(self.cutAction) self.mainToolBar.addAction(self.copyAction) self.mainToolBar.addAction(self.pasteAction) self.mainToolBar.addSeparator() self.mainToolBar.addAction(self.undoAction) self.mainToolBar.addAction(self.redoAction)
def testIt(self): self.textEdit = QTextEdit() self.textEdit.show() interface = Foo() self.textEdit.document().documentLayout().registerHandler(QAbstractTextDocumentLayoutTest.objectType, interface) QTimer.singleShot(0, self.foo) self.app.exec_() self.assertTrue(Foo.called)
def _createOutputWindow(self): """ Some binary analysis commands will output to this. """ self.output_label = QtGui.QLabel('Output') self.output_window = QTextEdit() self.output_window.setFontPointSize(10) self.output_window.setReadOnly(True) # Save it for later use self.output_window.original_textcolor = self.output_window.textColor()
def __init__(self, stream=None): QtGui.QDialog.__init__(self) self.stream = stream self.setWindowTitle('Console Messages') self.layout = QHBoxLayout(self) self.layout.setSpacing(6) self.layout.setContentsMargins(3, 3, 3, 3) self.edit = QTextEdit(self) self.edit.setReadOnly(True) self.layout.addWidget(self.edit) self.resize(450, 250)
class Notepad(QWidget): def __init__(self, parent=None): super().__init__(parent) self._text_edit = QTextEdit() self._open_button = QPushButton(self.tr("&Open")) self._save_button = QPushButton(self.tr("&Save")) self._exit_button = QPushButton(self.tr("&Exit")) button_layout = QVBoxLayout() button_layout.addWidget(self._open_button) button_layout.addWidget(self._save_button) button_layout.addWidget(self._exit_button) button_layout.addStretch() main_layout = QHBoxLayout() main_layout.addWidget(self._text_edit) main_layout.addLayout(button_layout) self.setLayout(main_layout) self.setWindowTitle(self.tr('Notepad')) self._save_button.clicked.connect(self.save) self._open_button.clicked.connect(self.open) self._exit_button.clicked.connect(self.exit) def open(self): file_name = QFileDialog.getOpenFileName(self)[0] if file_name != '': try: with open(file_name, mode='rt') as in_file: text = in_file.read() self._text_edit.setText(text) except: QMessageBox.critical(self, self.tr('Error'), self.tr('Could not open file')) def save(self): file_name = QFileDialog.getSaveFileName(self)[0] if file_name != '': try: with open(file_name, mode='wt') as out_file: text = self._text_edit.toPlainText() out_file.write(text) except: QMessageBox.critical(self, self.tr('Error'), self.tr('Could not save file')) def exit(self): button = QMessageBox.question( self, self.tr('Notepad - Quit'), self.tr('Do you really want to quit?'), QMessageBox.Yes | QMessageBox.No) if button == QMessageBox.Yes: self.window().close()
class Notepad(QWidget): def __init__(self, parent=None): super().__init__(parent) self._text_edit = QTextEdit() self._open_button = QPushButton(self.tr("&Open")) self._save_button = QPushButton(self.tr("&Save")) self._exit_button = QPushButton(self.tr("&Exit")) button_layout = QVBoxLayout() button_layout.addWidget(self._open_button) button_layout.addWidget(self._save_button) button_layout.addWidget(self._exit_button) button_layout.addStretch() main_layout = QHBoxLayout() main_layout.addWidget(self._text_edit) main_layout.addLayout(button_layout) self.setLayout(main_layout) self.setWindowTitle(self.tr('Notepad')) self._save_button.clicked.connect(self.save) self._open_button.clicked.connect(self.open) self._exit_button.clicked.connect(self.exit) def open(self): file_name = QFileDialog.getOpenFileName(self)[0] if file_name != '': try: with open(file_name, mode='rt') as in_file: text = in_file.read() self._text_edit.setText(text) except: QMessageBox.critical(self, self.tr('Error'), self.tr('Could not open file')) def save(self): file_name = QFileDialog.getSaveFileName(self)[0] if file_name != '': try: with open(file_name, mode='wt') as out_file: text = self._text_edit.toPlainText() out_file.write(text) except: QMessageBox.critical(self, self.tr('Error'), self.tr('Could not save file')) def exit(self): button = QMessageBox.question(self, self.tr('Notepad - Quit'), self.tr('Do you really want to quit?'), QMessageBox.Yes | QMessageBox.No) if button == QMessageBox.Yes: self.window().close()
class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.resize(731, 475) centralwidget = QWidget(self) gridLayout = QGridLayout(centralwidget) # textEdit needs to be a class variable. self.textEdit = QTextEdit(centralwidget) gridLayout.addWidget(self.textEdit, 0, 0, 1, 1) self.setCentralWidget(centralwidget) menubar = QMenuBar(self) menubar.setGeometry(QRect(0, 0, 731, 29)) menu_File = QMenu(menubar) self.setMenuBar(menubar) statusbar = QStatusBar(self) self.setStatusBar(statusbar) actionShow_GPL = QAction(self) actionShow_GPL.triggered.connect(self.showGPL) action_About = QAction(self) action_About.triggered.connect(self.about) iconToolBar = self.addToolBar("iconBar.png") #------------------------------------------------------ # Add icons to appear in tool bar - step 1 actionShow_GPL.setIcon(QIcon(":/showgpl.png")) action_About.setIcon(QIcon(":/about.png")) action_Close = QAction(self) action_Close.setCheckable(False) action_Close.setObjectName("action_Close") action_Close.setIcon(QIcon(":/quit.png")) #------------------------------------------------------ # Show a tip on the Status Bar - step 2 actionShow_GPL.setStatusTip("Show GPL Licence") action_About.setStatusTip("Pop up the About dialog.") action_Close.setStatusTip("Close the program.") #------------------------------------------------------ menu_File.addAction(actionShow_GPL) menu_File.addAction(action_About) menu_File.addAction(action_Close) menubar.addAction(menu_File.menuAction()) iconToolBar.addAction(actionShow_GPL) iconToolBar.addAction(action_About) iconToolBar.addAction(action_Close) action_Close.triggered.connect(self.close) def showGPL(self): '''Read and display GPL licence.''' self.textEdit.setText(open('COPYING.txt').read()) def about(self): '''Popup a box with about message.''' QMessageBox.about(self, "About PyQt, Platform and the like")
def __init__(self, parent, *args): QPlainTextEdit.__init__(self, *args) self.parent = parent self.config_main = self.parent.config_main self.config_theme = self.parent.config_theme self.tools = self.parent.tools self.lvars = self.parent.lvars self._loaded = False self.setFrameStyle(QFrame.NoFrame) self.setLineWrapMode(QPlainTextEdit.NoWrap) self._setup_ui() self._casts_marked = False self._casts_selections = None self.cursorPositionChanged.connect( self._on_cursor_position_changed) self._bracket_info = hrdev_plugin.include.helper.AttributeDict() self._bracket_info.saved_bracket = None self._bracket_info.depth = 0 self._bracket_info.seeking_nl = False self._bracket_info.open_brackets = ['[', '{', '('] self._bracket_info.closed_brackets = [']', '}', ')'] self._bracket_info.pairs_closed = {']': '[', '}': '{', ')': '('} self._bracket_info.pairs_open = {'[': ']', '{': '}', '(': ')'} self._bracket_info.ignore_stack_left = [] self._bracket_info.ignore_stack_right = [] self._left_selected_bracket = QTextEdit.ExtraSelection() self._right_selected_bracket = QTextEdit.ExtraSelection() toolTipWidget = QtGui.QLabel() toolTipWidget.setStyleSheet( "QLabel { background-color : #ffffcc; color : #222; padding: 5px; }" ) toolTipWidget.setFrameShape(QtGui.QFrame.StyledPanel) toolTipWidget.setWindowFlags(QtCore.Qt.ToolTip) toolTipWidget.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) toolTipWidget.hide() self._toolTipWidget = toolTipWidget self._timer = QtCore.QBasicTimer() self._timer.start(2000, self) self._min_marker_len = self.config_main.getint( 'editor', 'min_marker_len') return
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) # self.setObjectName("MainWindow") self.resize(731, 475) centralwidget = QWidget(self) # centralwidget.setObjectName("centralwidget") gridLayout = QGridLayout(centralwidget) # gridLayout.setObjectName("gridLayout") # textEdit needs to be a class variable. self.textEdit = QTextEdit(centralwidget) # self.textEdit.setObjectName("textEdit") gridLayout.addWidget(self.textEdit, 0, 0, 1, 1) self.setCentralWidget(centralwidget) menubar = QMenuBar(self) menubar.setGeometry(QRect(0, 0, 731, 29)) # menubar.setObjectName("menubar") menu_File = QMenu(menubar) # menu_File.setObjectName("menu_File") self.setMenuBar(menubar) statusbar = QStatusBar(self) # statusbar.setObjectName("statusbar") self.setStatusBar(statusbar) actionShow_GPL = QAction(self) # actionShow_GPL.setObjectName("actionShow_GPL") actionShow_GPL.triggered.connect(self.showGPL) action_About = QAction(self) # action_About.setObjectName("action_About") action_About.triggered.connect(self.about) iconToolBar = self.addToolBar("iconBar.png") #------------------------------------------------------ # Add icons to appear in tool bar - step 1 actionShow_GPL.setIcon(QIcon(":/showgpl.png")) action_About.setIcon(QIcon(":/about.png")) action_Close = QAction(self) action_Close.setCheckable(False) action_Close.setObjectName("action_Close") action_Close.setIcon(QIcon(":/quit.png")) #------------------------------------------------------ # Show a tip on the Status Bar - step 2 actionShow_GPL.setStatusTip("Show GPL Licence") action_About.setStatusTip("Pop up the About dialog.") action_Close.setStatusTip("Close the program.") #------------------------------------------------------ menu_File.addAction(actionShow_GPL) menu_File.addAction(action_About) menu_File.addAction(action_Close) menubar.addAction(menu_File.menuAction()) iconToolBar.addAction(actionShow_GPL) iconToolBar.addAction(action_About) iconToolBar.addAction(action_Close) action_Close.triggered.connect(self.close)
def __init__(self, parent=None, format=settings.log_fmt, level=logging.INFO): logging.Handler.__init__(self) # Initialize a log handler as the super class self.setFormatter(logging.Formatter(format)) # Set the formatter for the logger self.setLevel(level) # Set the logging level self.frame = QFrame(parent) # Initialize a QFrame to place other widgets in self.frame2 = QFrame(parent) # Initialize frame2 for the label and checkbox self.label = QLabel('Logs') # Define a label for the frame self.check = QCheckBox('Debugging') # Checkbox to enable debugging logging self.check.clicked.connect(self.__changeLevel) # Connect checkbox clicked to the __changeLevel method self.log_widget = QTextEdit() # Initialize a QPlainTextWidget to write logs to self.log_widget.verticalScrollBar().minimum() # Set a vertical scroll bar on the log widget self.log_widget.horizontalScrollBar().minimum() # Set a horizontal scroll bar on the log widget self.log_widget.setLineWrapMode(self.log_widget.NoWrap) # Set line wrap mode to no wrapping self.log_widget.setFont(QFont("Courier", 12)) # Set the font to a monospaced font self.log_widget.setReadOnly(True) # Set log widget to read only layout = QHBoxLayout() # Initialize a horizontal layout scheme for the label and checkbox frame layout.addWidget(self.label) # Add the label to the layout scheme layout.addWidget(self.check) # Add the checkbox to the layout scheme self.frame2.setLayout(layout) # Set the layout for frame to the horizontal layout layout = QVBoxLayout() # Initialize a layout scheme for the widgets layout.addWidget(self.frame2) # Add the label/checkbox frame to the layout scheme layout.addWidget(self.log_widget) # Add the text widget to the layout scheme self.frame.setLayout(layout)
class Console(): def __init__(self, targetLayoutContainer): self.textarea = QTextEdit() self.commits = QListWidget() self.commits.addAction(QAction('Rollback to this revision', self.commits, triggered=self.rollback)) self.commits.setContextMenuPolicy(Qt.ActionsContextMenu) self.widget = QTabWidget() self.widget.addTab(self.textarea, 'Log') self.widget.addTab(self.commits, 'Commits') targetLayoutContainer.addWidget(self.widget) def color(self, module, function, color, *args): print module, function, args prettyString = '<font color="' + color + '"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>' self.textarea.append(''.join(prettyString)) def info(self, module, function, *args): print module, function, args prettyString = '<font color="black"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>' self.textarea.append(''.join(prettyString)) def error(self, module, function, *args): print module, function, args prettyString = '<font color="red"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>' self.textarea.append(''.join(prettyString)) def warn(self, module, function, *args): print module, function, args prettyString = '<font color="#BE9900"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>' self.textarea.append(''.join(prettyString)) def set_commits(self, commits): self.commits.clear() for commit in commits: self.commits.addItem(commit) def clear(self): self.textarea.clear() def rollback(self): targetCommit = self.commits.currentItem().text().split(' ')[0] if QMessageBox.warning(None, 'Rollback to commit?', 'All commits after ' + targetCommit + ' will be lost, proceed?', QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes: rollback(targetCommit)
def __init__(self): BaseDock.__init__(self, 100) self.ttt = QTextEdit() self.setWidget(self.ttt) tt = QStyleOptionDockWidget() tt.closable = False tt.title = "OMG" self.initStyleOption(tt) self.setFeatures(QDockWidget.DockWidgetClosable)
def _make_supply_order_detail_view(self): # There's a self.proto somewhere, don't mess with it :-) # proto = [] # proto.append( TextLinePrototype('description',_('Description'), editable=True,nullable=False)) # proto.append( FloatNumberPrototype('quantity',_('Quantity'), editable=True,nullable=False)) # proto.append( FloatNumberPrototype('unit_price',_('Unit price'), editable=True,nullable=False)) # self.detail_model = PrototypedModelView(proto, self) # self.detail_view = PrototypedQuickView(proto, self) # self.detail_view.setModel(self.detail_model) # self.detail_view.verticalHeader().hide() self.detail_description = QTextEdit() self.detail_description.setTextInteractionFlags( Qt.TextBrowserInteraction) self.delivery_date_widget = QLabel() self.creation_date_widget = QLabel() self.supplier_reference_widget = QLabel() hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Delivery date"))) hlayout.addWidget(self.delivery_date_widget) hlayout.addStretch() hlayout3 = QHBoxLayout() hlayout3.addWidget(QLabel(_("Creation date"))) hlayout3.addWidget(self.creation_date_widget) hlayout3.addStretch() hlayout2 = QHBoxLayout() hlayout2.addWidget(QLabel(_("Supplier's reference"))) hlayout2.addWidget(self.supplier_reference_widget) hlayout2.addStretch() layout = QVBoxLayout() layout.addLayout(hlayout) layout.addLayout(hlayout3) layout.addLayout(hlayout2) layout.addWidget(self.detail_description) layout.addStretch() # layout.addWidget(self.detail_view) # layout.setStretch(0,1) # layout.setStretch(1,3) return layout
def testRefcount(self): textedit = QTextEdit() textedit.setReadOnly(True) doc = textedit.document() cursor = QTextCursor(doc) cursor.insertText("PySide Rocks") ud = TestUserData({"Life": 42}) self.assertEqual(sys.getrefcount(ud), 2) cursor.block().setUserData(ud) self.assertEqual(sys.getrefcount(ud), 3) ud2 = cursor.block().userData() self.assertEqual(sys.getrefcount(ud), 4) self.udata = weakref.ref(ud, None) del ud, ud2 self.assertEqual(sys.getrefcount(self.udata()), 2)
def initGUI(self): self.setWindowTitle("A Simple Text Editor") self.setWindowIcon(QIcon('appicon.png')) self.setGeometry(100, 100, 800, 600) self.center() # Text Editor self.textEdit = QTextEdit() self.setCentralWidget(self.textEdit) self.fileName = None self.filters = "Text files (*.txt)" # Setup and Show self.setupComponents() self.show()
def focusNextPrevChild ( self, next ): """ Suppress tabbing to the next window in multi-line commands. """ if next and self._more: return False return QTextEdit.focusNextPrevChild( self, next )
def __init__(self): super(TwoStepLandmarkWidget, self).__init__() self.textFrame = QTextEdit("<p>Place your mouse over the desired " "landmark point. Press 'Space' to shoot a ray through the volume. " "Move the volume around and move the mouse to move the locator. " "Press 'Space' again to define the final place of the landmark.</p>" "<p>You can also use the ray profile to define the landmark's location.</p>") self.textFrame.setReadOnly(True) self.textFrame.setFrameShape(QFrame.NoFrame) self.textFrame.setAutoFillBackground(False) self.textFrame.setAttribute(Qt.WA_TranslucentBackground) self.textFrame.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.textFrame.setStyleSheet("background: #aaa") self.histogramWidget = TrackingHistogramWidget() self.histogramWidget.setMinimumHeight(100) self.histogramWidget.setVisible(False) self.button = QPushButton("Pick current landmark position") self.button.clicked.connect(self.applyButtonClicked) self.button.setVisible(False) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.textFrame) layout.addWidget(self.histogramWidget) layout.addWidget(self.button) self.setLayout(layout)
def _toogle_breakpoint(self, cursor, line_number): '''Toggle breakpoint line.''' if line_number in self.breakpoints: self.breakpoints[line_number].cursor.clearSelection() self.breakpoints.pop(line_number) selections = [] for prev_selection in self.breakpoints: selections.append(self.breakpoints[prev_selection]) self.edit.setExtraSelections(selections) return color = self.config_theme.get('editor', 'breakpoint_line_color') selection = QTextEdit.ExtraSelection() selection.format.setBackground(QtGui.QColor(color)) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = cursor self.breakpoints[line_number] = selection selections = [] for prev_selection in self.breakpoints: selections.append(self.breakpoints[prev_selection]) selections.append(selection) self.edit.setExtraSelections(selections) return
def setupUI(self): self.pushButton = QPushButton(u"Search", self) #self.testButton = QPushButton(u"Test", self) self.lineEdit = QLineEdit(self) self.textEdit = QTextEdit(self) self.comboBox = QComboBox(self) self.label = QLabel(u"DB:", self) self.progressBar = QProgressBar(self) self.progressBar.setRange(0,1) self.textEdit.setReadOnly(True) self.layout = QVBoxLayout() self.topLayout = QHBoxLayout() self.topLayout.addWidget(self.label) self.topLayout.addWidget(self.comboBox) self.topLayout.addWidget(self.lineEdit) self.topLayout.addWidget(self.pushButton) #self.topLayout.addWidget(self.testButton) #self.testButton.clicked.connect(self.onTestButtonClicked) self.layout.addLayout(self.topLayout) self.layout.addWidget(self.textEdit) self.layout.addWidget(self.progressBar) self.setLayout(self.layout) self.resize(600, 700) self.setWindowTitle(u"Search Data for NCBI")
def __init__(self, cpacs_file, cpacs_schema): super(EditorWindow, self).__init__() self.editor = QTextEdit() self.temp = CPACS_Handler() self.temp.loadFile(cpacs_file, cpacs_schema) text = self.temp.tixi.exportDocumentAsString() xpath = self.temp.tixi.uIDGetXPath('NACA0009') print xpath #directory = self.temp.tixi.exportDocumentAsString() #version = self.temp.tixi.getTextElement('/cpacs/vehicles/aircraft/model/name') #attributeValue = self.temp.tixi.getTextAttribute(config.path_element2, config.attrName2) vecX = self.temp.tixi.getFloatVector(xpath + "/pointList/x",100) vecY = self.temp.tixi.getFloatVector(xpath + "/pointList/y",100) vecZ = self.temp.tixi.getFloatVector(xpath + "/pointList/z",100) print vecX print vecY print vecZ self.temp.tixi.close() #print version #print attributeValue self.editor.setText(text) self.statusBar() self.setWindowTitle('Simple XML editor') self.setCentralWidget(self.editor) self.resize(800, 800)
def __init__(self, log, parent=None): super(EditConfigurationDialog, self).__init__(parent) layout = QVBoxLayout() self._log = log self.text_edit_widget = QTextEdit() layout.addWidget(self.text_edit_widget) buttons = QDialogButtonBox() # buttons.addButton( QDialogButtonBox.StandardButton.Cancel) buttons.addButton(QDialogButtonBox.StandardButton.Save) layout.addWidget(buttons) buttons.button(QDialogButtonBox.StandardButton.Save).clicked.connect( self._save) self.setLayout(layout)
def SetupComponents(self): """ Function to setup status bar, central widget, menu bar """ self.myStatusBar = QStatusBar() self.setStatusBar(self.myStatusBar) self.myStatusBar.showMessage('Ready', 10000) self.textEdit = QTextEdit() self.setCentralWidget(self.textEdit) self.createActions() self.createMenus() # Invoques toolbar creation and after that, reuses menu actions from # createActions() to create toolbar bottons. self.CreateToolBar() self.mainToolBar.addAction(self.newAction) self.mainToolBar.addSeparator() self.mainToolBar.addAction(self.copyAction) self.mainToolBar.addAction(self.pasteAction) self.fileMenu.addAction(self.newAction) self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAction) self.editMenu.addAction(self.copyAction) self.fileMenu.addSeparator() self.editMenu.addAction(self.pasteAction) self.helpMenu.addAction(self.aboutAction)
def __init__(self): super(MainWindow, self).__init__() # Store ourself. self.windows.append(self) # State! self.current_file = None # Editor! self.editor = QTextEdit() self.setCentralWidget(self.editor) # Style the editor style.apply_stylesheet(self.editor, 'editor.qss') # Menus and Stuff! self.init_actions() self.init_menus() self.init_toolbars() self.init_statusbar() # Settings! self.init_settings() # Icons! self.reload_icons() style.style_reloaded.connect(self.reload_icons) # Fancy! style.enable_aero(self) self.update_title() # Now, for some plugins. plugins.run_signal('new_window', self)
def __init__(self, parent, change_tracker: ChangeTracker): super(CommentsWidget, self).__init__(parent) self._change_tracker = change_tracker #self.setObjectName("zwhite") layout = QVBoxLayout() self.comments_list_widget = QFrame( self ) # If you use QWidget, the background won't be set; don't know why :-( self.comments_list_widget.setStyleSheet("background: white;") self.comments_list_widget.setAutoFillBackground(True) #self.comments_list_widget.setObjectName("zwhite") self._comments_layout = QVBoxLayout() self.comments_list_widget.setLayout(self._comments_layout) self.comments_list_widget.hide() self.text_edit = QTextEdit(self) self.submit_button = QPushButton(("Add"), self) layout.addWidget(self.comments_list_widget) layout.addWidget(self.text_edit) hlayout = QHBoxLayout() hlayout.addStretch() hlayout.addWidget(self.submit_button) layout.addLayout(hlayout) self.setLayout(layout) self.submit_button.clicked.connect(self.submit_comment)
def tesIterator(self): edit = QTextEdit() cursor = edit.textCursor() fmt = QTextCharFormat() frags = [] for i in range(10): fmt.setFontPointSize(i + 10) frags.append("block%d" % i) cursor.insertText(frags[i], fmt) doc = edit.document() block = doc.begin() index = 0 for i in block: self.assertEqual(i.fragment().text(), frags[index]) index += 1
def SetupComponents(self): """ Function to setup status bar, central widget, menu bar """ self.myStatusBar = QStatusBar() self.setStatusBar(self.myStatusBar) self.myStatusBar.showMessage('Ready', 10000) self.textEdit = QTextEdit() self.setCentralWidget(self.textEdit) self.CreateActions() self.CreateMenus() self.fileMenu.addAction(self.newAction) self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAction) self.editMenu.addAction(self.copyAction) self.fileMenu.addSeparator() self.editMenu.addAction(self.pasteAction) self.helpMenu.addAction(self.aboutAction)
def tesIterator(self): edit = QTextEdit() cursor = edit.textCursor() fmt = QTextCharFormat() frags = [] for i in range(10): fmt.setFontPointSize(i+10) frags.append("block%d"%i) cursor.insertText(frags[i], fmt) doc = edit.document() block = doc.begin() index = 0 for i in block: self.assertEqual(i.fragment().text(), frags[index]) index += 1
def testPropertyValues(self): app = QApplication(sys.argv) textEdit = QPlainTextEdit() textEdit.insertPlainText("PySide INdT") selection = QTextEdit.ExtraSelection() selection.cursor = textEdit.textCursor() selection.cursor.setPosition(2) self.assertEqual(selection.cursor.position(), 2)
def _createLayout(self): 'Create the Widget Layout' self._txtLogbook = QLineEdit() self._txtLogbook.setReadOnly(True) self._lblLogbook = QLabel(self.tr('&Logbook File:')) self._lblLogbook.setBuddy(self._txtLogbook) self._btnBrowse = QPushButton('...') self._btnBrowse.clicked.connect(self._btnBrowseClicked) self._btnBrowse.setStyleSheet('QPushButton { min-width: 24px; max-width: 24px; }') self._btnBrowse.setToolTip(self.tr('Browse for a Logbook')) self._cbxComputer = QComboBox() self._lblComputer = QLabel(self.tr('Dive &Computer:')) self._lblComputer.setBuddy(self._cbxComputer) self._btnAddComputer = QPushButton(QPixmap(':/icons/list-add.png'), self.tr('')) self._btnAddComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }') self._btnAddComputer.clicked.connect(self._btnAddComputerClicked) self._btnRemoveComputer = QPushButton(QPixmap(':/icons/list-remove.png'), self.tr('')) self._btnRemoveComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }') self._btnRemoveComputer.clicked.connect(self._btnRemoveComputerClicked) hbox = QHBoxLayout() hbox.addWidget(self._btnAddComputer) hbox.addWidget(self._btnRemoveComputer) gbox = QGridLayout() gbox.addWidget(self._lblLogbook, 0, 0) gbox.addWidget(self._txtLogbook, 0, 1) gbox.addWidget(self._btnBrowse, 0, 2) gbox.addWidget(self._lblComputer, 1, 0) gbox.addWidget(self._cbxComputer, 1, 1) gbox.addLayout(hbox, 1, 2) gbox.setColumnStretch(1, 1) self._pbTransfer = QProgressBar() self._pbTransfer.reset() self._txtStatus = QTextEdit() self._txtStatus.setReadOnly(True) self._btnTransfer = QPushButton(self.tr('&Transfer Dives')) self._btnTransfer.clicked.connect(self._btnTransferClicked) self._btnExit = QPushButton(self.tr('E&xit')) self._btnExit.clicked.connect(self.close) hbox = QHBoxLayout() hbox.addWidget(self._btnTransfer) hbox.addStretch() hbox.addWidget(self._btnExit) vbox = QVBoxLayout() vbox.addLayout(gbox) vbox.addWidget(self._pbTransfer) vbox.addWidget(self._txtStatus) vbox.addLayout(hbox) self.setLayout(vbox)
def __init__(self, variable_setting, parent=None): super(FoamDictWidget, self).__init__(parent) self.buttonLayout = QHBoxLayout() self.pushButtonInsert = QPushButton("Insert") #self.pushButtonLoad = QPushButton("Load default") self.pushButtonRestore = QPushButton("Restore") self.pushButtonClear = QPushButton("Clear") self.buttonLayout.addWidget(self.pushButtonInsert) #self.buttonLayout.addWidget(self.pushButtonLoad) self.buttonLayout.addWidget(self.pushButtonRestore) self.buttonLayout.addWidget(self.pushButtonClear) self.buttonPreview = QPushButton('Preview FoamFile write-out') self.textPreview = QTextEdit('') self.textPreview.setVisible(False) self.textPreview.setEnabled(False) self.tableWidget = QTableWidget() #header, should not sort, has vertical scrollbar # set column count, fixed to 2, size of TableItem self.tableWidget.setColumnCount(2) #5self.tableWidget.setHorizontalHeaderItem(0, ) self.tableWidget.setHorizontalHeaderLabels(['key', 'value text']) # set a default row count, insert as needed self.tableWidget.setRowCount(0) #PySide has different name other than @QtCore.pyqtSlot, but PySide.QtCore.SLOT QtCore.QObject.connect(self.pushButtonInsert, QtCore.SIGNAL("clicked()"), self.insertRow) QtCore.QObject.connect(self.pushButtonRestore, QtCore.SIGNAL("clicked()"), self.restoreDict) QtCore.QObject.connect(self.pushButtonClear, QtCore.SIGNAL("clicked()"), self.clearDict) # QtCore.QObject.connect(self.tableWidget, QtCore.SIGNAL("doubleClicked()"), self.showPreview) # does not work for PySide QtCore.QObject.connect(self.buttonPreview, QtCore.SIGNAL("clicked()"), self.showPreview) self._previewing = False self.settings = variable_setting self.restoreDict() self.myLayout = QVBoxLayout() self.myLayout.addLayout(self.buttonLayout) self.myLayout.addWidget(self.tableWidget) self.myLayout.addWidget(self.buttonPreview) self.myLayout.addWidget(self.textPreview) self.setLayout(self.myLayout)
def newwindow(self): import pprint print("##############") pprint.pprint(self.output_of_algorithm) print("##############") self.wid = QWidget() self.wid.resize(250, 150) self.wid.setWindowTitle('NewWindow') self.result = QTextEdit(self.wid) self.result.setText(str(self.output_of_algorithm)) #self.start_airport.addItems(self.airports) self.result.setMinimumHeight(200) self.result.setMaximumHeight(200) self.result.setMinimumWidth(600) self.start_airport.setMaximumWidth(600) # self.start_airport.move(150, 5) self.output_of_algorithm = None self.wid.show()
def __init__(self, parent=None): """Create Qt widgets, connect event handlers.""" super(App, self).__init__(parent) self.windowTitle = 'DMD | ' self.fileName = '' self.setWindowTitle(self.windowTitle + 'Unsaved File') exitAction = QAction('Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(self.close) openAction = QAction('Open', self) openAction.setShortcut('Ctrl+O') openAction.setStatusTip('Open Markdown File') openAction.triggered.connect(self.openFile) newAction = QAction('New', self) newAction.setShortcut('Ctrl+N') newAction.setStatusTip('New Markdown File') newAction.triggered.connect(self.newFile) saveAction = QAction('Save', self) saveAction.setShortcut('Ctrl+S') saveAction.setStatusTip('Save File') saveAction.triggered.connect(self.saveFile) self.statusBar() menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(newAction) fileMenu.addAction(openAction) fileMenu.addAction(saveAction) fileMenu.addAction(exitAction) self.setGeometry(300, 300, 1024, 768) self.show() self.txtInput = QTextEdit() self.txtInput.setTabStopWidth(20) self.webPreview = QWebView() self.webPreview.setHtml('Start typing...', baseUrl=QUrl('preview')) self.txtInput.textChanged.connect(self.loadPreview) splitter = QSplitter() splitter.addWidget(self.txtInput) splitter.addWidget(self.webPreview) self.setCentralWidget(splitter)
def _watch_line(self): '''Handler for current line change.''' selection = QTextEdit.ExtraSelection() color = self.config_theme.get('editor', 'current_line_color') selection.format.setBackground(QtGui.QColor(color)) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = self.textCursor() return selection
def __init__(self, parent): self.parent = parent self.dialog = QDialog(self.parent.parent) mainLayout = QVBoxLayout() aux = QHBoxLayout() name = QLabel("Signal Name: ") self.nameBox = QLineEdit() aux.addWidget(name) aux.addWidget(self.nameBox) aux2 = QWidget() aux2.setLayout(aux) mainLayout.addWidget(aux2) auxBox = QHBoxLayout() self.fileLabel = QLabel("File: ") button = QPushButton("...") button.clicked.connect(self.fileChoosing) auxBox.addWidget(self.fileLabel) auxBox.addWidget(button) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) hBox = QHBoxLayout() hBox.addWidget(QLabel("Sample Rate (Hz): ")) self.sampleRate = QLineEdit() self.sampleRate.setText("60") hBox.addWidget(self.sampleRate) auxW = QWidget() auxW.setLayout(hBox) mainLayout.addWidget(auxW) auxBox = QHBoxLayout() commentaryLabel = QLabel("Commentary: ") self.commentaryBox = QTextEdit() auxBox.addWidget(commentaryLabel) auxBox.addWidget(self.commentaryBox) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) buttonOk = QPushButton("Add Signal") buttonOk.clicked.connect(self.addSignalClicked) mainLayout.addWidget(buttonOk) self.dialog.setLayout(mainLayout) self.dialog.show()
def __init__ ( self, parent = None ): """ Initialise the instance. """ if isinstance( parent, QLayout ): parent = None QTextEdit.__init__( self, parent ) self.setAcceptDrops( True ) self.setAcceptRichText( False ) self.setWordWrapMode( QTextOption.WrapAnywhere ) self.interpreter = code.InteractiveInterpreter() self.exec_callback = None ### PYSIDE: self._line = QString() self._line = '' self._lines = [] self._more = False self.history = [] self.historyIndex = 0 self._reading = False self._point = 0 # Interpreter prompts. try: sys.ps1 except AttributeError: sys.ps1 = ">>> " try: sys.ps2 except AttributeError: sys.ps2 = "... " # Interpreter banner: self.write( 'Python %s on %s.\n' % ( sys.version, sys.platform ) ) self.write( 'Type "copyright", "credits" or "license" for more ' 'information.\n' ) self.write( sys.ps1 )
def __init__(self, targetLayoutContainer): self.textarea = QTextEdit() self.commits = QListWidget() self.commits.addAction(QAction('Rollback to this revision', self.commits, triggered=self.rollback)) self.commits.setContextMenuPolicy(Qt.ActionsContextMenu) self.widget = QTabWidget() self.widget.addTab(self.textarea, 'Log') self.widget.addTab(self.commits, 'Commits') targetLayoutContainer.addWidget(self.widget)
def __init__(self, parent=None): super(SummarySection, self).__init__(parent) self.text_edit_summary = QTextEdit() self.text_edit_summary.setReadOnly(True) self.addTab(self.text_edit_summary, "Output") self.ball_grid = BallGrid(30, 30, 2) self.addTab(self.ball_grid, "Led View") self.tab_summary = SummaryTab() self.addTab(self.tab_summary, "Summary") #some private fields, keep track of accumulated summary data self.current_ip = 0 #we take reply data for ips in order self.sent_packets = 0 self.received_packets = 0 self.average_delay = 0
def create_text_input( self, parent, read_only=False, password=False, handle_enter=False, multi_line=False, align="left" ): """ Returns an adapted single or mutli line text input control. """ if multi_line: control = QTextEdit(check_parent(parent)) else: control = QLineEdit(check_parent(parent)) control.setAlignment(horizontal_alignment_styles[align] | Qt.AlignVCenter) if password: control.setEchoMode(QLineEdit.Password) control.setReadOnly(read_only) return control_adapter_for(control)
class SummarySection(QTabWidget): """ Represents the summary section. Takes reply data from main ui and updates it's tabs Keeps track of cumulative summary data. """ def __init__(self, parent=None): super(SummarySection, self).__init__(parent) self.text_edit_summary = QTextEdit() self.text_edit_summary.setReadOnly(True) self.addTab(self.text_edit_summary, "Output") self.ball_grid = BallGrid(30, 30, 2) self.addTab(self.ball_grid, "Led View") self.tab_summary = SummaryTab() self.addTab(self.tab_summary, "Summary") #some private fields, keep track of accumulated summary data self.current_ip = 0 #we take reply data for ips in order self.sent_packets = 0 self.received_packets = 0 self.average_delay = 0 def setIPs(self, ips): #this indicates the start of a new ping, could be treated #as a pingStarted signal self.current_ip = 0 self.sent_packets = 0 self.received_packets = 0 self.average_delay = 0 self.text_edit_summary.clear() self.ball_grid.layoutForIps(ips) self.tab_summary.zeroOut() def takeReplyData(self, replyData, sentPackets): #sent packets is passed in as extra """ Update the output text area with the replyData string representation Set proper widget states on the BallGrid Calculate summaries cumulatively and set them for display on the summary tab """ self.text_edit_summary.append(str(replyData)) packets_lost = replyData.packets_lost if packets_lost: self.ball_grid.setStateAt(self.current_ip, BallWidget.UNREACHABLE) else: self.ball_grid.setStateAt(self.current_ip, BallWidget.REACHABLE) self.current_ip += 1 self.sent_packets += sentPackets self.received_packets = self.sent_packets - replyData.packets_lost self.average_delay += (replyData.rtt / self.current_ip) #the current_ip reflects the overall number of replies summary_data = SummaryData(self.sent_packets, self.received_packets, self.average_delay) self.tab_summary.setSummaryData(summary_data) def pingingStoppedHandler(self): self.ball_grid.pingingCancelledHandler()