我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用PyQt4.QtGui.QPlainTextEdit()。
def setupUi(self, DebugDialog): DebugDialog.setObjectName(_fromUtf8("DebugDialog")) DebugDialog.setWindowModality(QtCore.Qt.ApplicationModal) DebugDialog.resize(564, 547) self.verticalLayout = QtGui.QVBoxLayout(DebugDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.frame = QtGui.QFrame(DebugDialog) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName(_fromUtf8("frame")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.frame) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.textEdit = QtGui.QPlainTextEdit(self.frame) self.textEdit.setUndoRedoEnabled(False) self.textEdit.setReadOnly(True) self.textEdit.setPlainText(_fromUtf8("")) self.textEdit.setObjectName(_fromUtf8("textEdit")) self.verticalLayout_2.addWidget(self.textEdit) self.verticalLayout.addWidget(self.frame) self.retranslateUi(DebugDialog) QtCore.QMetaObject.connectSlotsByName(DebugDialog)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(400, 300) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName("verticalLayout") self.textview = QtGui.QPlainTextEdit(Dialog) self.textview.setObjectName("textview") self.verticalLayout.addWidget(self.textview) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(Dialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(400, 300) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.textview = QtGui.QPlainTextEdit(Dialog) self.textview.setObjectName(_fromUtf8("textview")) self.verticalLayout.addWidget(self.textview) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(Dialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def __JournalEntry(self, parent): """Set up QPlainTextEdit. This function create a Plain Text Editor as the input for the user. The size of this widget scales along with the window size. """ self.journalEntry = QtGui.QPlainTextEdit(parent.centralWidget) sizePolicy = QtGui.QSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.journalEntry.sizePolicy().hasHeightForWidth()) self.journalEntry.setSizePolicy(sizePolicy) self.journalEntry.setMinimumSize(QtCore.QSize(200, 600)) self.journalEntry.setObjectName(_fromUtf8("journalEntry"))
def __init__(self, parent=None): super(GetMany, self).__init__(parent) layout = QtGui.QVBoxLayout(self) layout.addWidget(QtGui.QLabel('Enter Coordinates')) self.text = QtGui.QPlainTextEdit() self.text.setPlainText('Enter list of coordinates separated by spaces or commas. west lat.,' \ + ' north lon., east lat., south lon. ...') layout.addWidget(self.text) # OK and Cancel buttons buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) self.setWindowTitle('SIREN - worldwindow (' + fileVersion() + ") - List of Coordinates")
def setupUi(self): Form = self Form.setObjectName(_fromUtf8("Form")) Form.resize(800, 600) self.frame = QtGui.QFrame(Form) self.frame.setGeometry(QtCore.QRect(10, 10, 781, 581)) self.frame.setFrameShape(QtGui.QFrame.Box) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName(_fromUtf8("frame")) self.label = QtGui.QLabel(self.frame) self.label.setGeometry(QtCore.QRect(10, 10, 261, 21)) font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setObjectName(_fromUtf8("label")) self.ms_data_text = QtGui.QPlainTextEdit(self.frame) self.ms_data_text.setGeometry(QtCore.QRect(10, 40, 761, 531)) self.ms_data_text.setReadOnly(True) self.ms_data_text.setOverwriteMode(False) self.ms_data_text.setObjectName(_fromUtf8("ms_data_text")) self.retranslateUi() QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self): Form = self Form.setObjectName(_fromUtf8("Form")) Form.resize(400, 150) self.frame = QtGui.QFrame(Form) self.frame.setGeometry(QtCore.QRect(9, 9, 381, 131)) self.frame.setFrameShape(QtGui.QFrame.Box) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName(_fromUtf8("frame")) self.label = QtGui.QLabel(self.frame) self.label.setGeometry(QtCore.QRect(10, 10, 241, 21)) font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setObjectName(_fromUtf8("label")) self.cl_command_text = QtGui.QPlainTextEdit(self.frame) self.cl_command_text.setGeometry(QtCore.QRect(10, 40, 361, 81)) self.cl_command_text.setObjectName(_fromUtf8("cl_command_text")) self.cl_command_button = QtGui.QPushButton(self.frame) self.cl_command_button.setGeometry(QtCore.QRect(214, 10, 151, 23)) self.cl_command_button.setObjectName(_fromUtf8("cl_command_button")) self.retranslateUi() QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(800, 600) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.plainTextEdit = QtGui.QPlainTextEdit(self.centralwidget) self.plainTextEdit.setGeometry(QtCore.QRect(10, 30, 551, 111)) self.plainTextEdit.setReadOnly(True) self.plainTextEdit.setObjectName(_fromUtf8("plainTextEdit")) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, who, desc='', parent=None): super(Description, self).__init__(parent) layout = QtGui.QVBoxLayout(self) layout.addWidget(QtGui.QLabel('Set Description for ' + who)) self.text = QtGui.QPlainTextEdit() self.text.setPlainText(desc) layout.addWidget(self.text) # OK and Cancel buttons buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) self.setWindowTitle('SIREN - Save Scenario')
def __init__(self, *args): QtWidgets.QPlainTextEdit.__init__(self, *args) self.setFrameStyle(QtWidgets.QFrame.NoFrame) self.zoomWheelEnabled = 0 self.highlight() #self.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap) self.cursorPositionChanged.connect(self.highlight)
def wheelEvent(self, event, forward=True): if event.modifiers() == QtCore.Qt.ControlModifier: if self.zoomWheelEnabled == 1: if event.delta() == 120: self.zoom_in() elif event.delta() == -120: self.zoom_out() event.ignore() QtWidgets.QPlainTextEdit.wheelEvent(self, event)
def setWrap(self, state): if state == 0: self.edit.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap) else: self.edit.setLineWrapMode(QtWidgets.QPlainTextEdit.WidgetWidth)
def setReadOnlyStyle(self, state): if state == 1: mainWindowBgColor = QtWidgets.QPalette().color(QtWidgets.QPalette.Window) self.setStyleSheet('QPlainTextEdit[readOnly="true"] { background-color: %s;} QFrame {border: 0px}' % mainWindowBgColor.name() ) self.setHighlight(0) else: self.setStyleSheet('') self.setHighlight(1)
def __init__(self, *args): QtGui.QPlainTextEdit.__init__(self, *args) self.setFrameStyle(QtGui.QFrame.NoFrame) self.zoomWheelEnabled = 0 self.highlight() #self.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap) self.cursorPositionChanged.connect(self.highlight)
def setWrap(self, state): if state == 0: self.edit.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap) else: self.edit.setLineWrapMode(QtGui.QPlainTextEdit.WidgetWidth)
def setReadOnlyStyle(self, state): if state == 1: mainWindowBgColor = QtGui.QPalette().color(QtGui.QPalette.Window) self.setStyleSheet('QPlainTextEdit[readOnly="true"] { background-color: %s;} QFrame {border: 0px}' % mainWindowBgColor.name() ) self.setHighlight(0) else: self.setStyleSheet('') self.setHighlight(1)
def __init__(self): """Initialize a Text File widget""" super().__init__() # Other attributes... self.infoBox = InfoBox(widget=self.controlArea) self.sendButton = SendButton( widget=self.controlArea, master=self, callback=self.sendData, infoBoxAttribute='infoBox', ) # LTTL.Input object (token that will be sent). self.segmentation = Input(text=u'') # GUI... # Text Field... gui.separator( widget=self.controlArea, height=3, ) self.editor = QPlainTextEdit() self.editor.setPlainText(self.textFieldContent.decode('utf-8')) self.controlArea.layout().addWidget(self.editor) self.editor.textChanged.connect(self.sendButton.settingsChanged) gui.separator( widget=self.controlArea, height=3, ) self.setMinimumWidth(250) # Send button... self.sendButton.draw() # Info box... self.infoBox.draw() self.sendButton.sendIf()
def __init__(self, parent): super(QPlainTextEditLogger, self).__init__() self.widget = QtGui.QPlainTextEdit(parent) self.widget.setReadOnly(True)
def setupUi(self, contentsDialog): contentsDialog.setObjectName(_fromUtf8("contentsDialog")) contentsDialog.resize(300, 268) self.verticalLayout = QtGui.QVBoxLayout(contentsDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.contentsBox = QtGui.QPlainTextEdit(contentsDialog) self.contentsBox.setPlainText(_fromUtf8("")) self.contentsBox.setObjectName(_fromUtf8("contentsBox")) self.verticalLayout.addWidget(self.contentsBox) self.retranslateUi(contentsDialog) QtCore.QMetaObject.connectSlotsByName(contentsDialog)
def __init__(self, in_file, parent=None): self.in_file = in_file try: s = open(self.in_file, 'r').read() bits = s.split('\n') ln = 0 for lin in bits: if len(lin) > ln: ln = len(lin) ln2 = len(bits) except: if self.in_file[self.in_file.rfind('.'):] == '.ini': s = '' else: s = '' ln = 36 ln2 = 5 QtGui.QDialog.__init__(self, parent) self.saveButton = QtGui.QPushButton(self.tr('&Save')) self.cancelButton = QtGui.QPushButton(self.tr('Cancel')) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(self.saveButton) buttonLayout.addWidget(self.cancelButton) self.connect(self.saveButton, QtCore.SIGNAL('clicked()'), self, QtCore.SLOT('accept()')) self.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self, QtCore.SLOT('reject()')) self.widget = QtGui.QPlainTextEdit() highlight = inisyntax.IniHighlighter(self.widget.document()) if sys.platform == 'linux2': self.widget.setFont(QtGui.QFont('Ubuntu Mono 13', 12)) else: self.widget.setFont(QtGui.QFont('Courier New', 12)) fnt = self.widget.fontMetrics() ln = (ln + 5) * fnt.maxWidth() ln2 = (ln2 + 4) * fnt.height() screen = QDesktopWidget().availableGeometry() if ln > screen.width() * .67: ln = int(screen.width() * .67) if ln2 > screen.height() * .67: ln2 = int(screen.height() * .67) self.widget.resize(ln, ln2) self.widget.setPlainText(s) layout = QtGui.QVBoxLayout() layout.addWidget(self.widget) layout.addLayout(buttonLayout) self.setLayout(layout) self.setWindowTitle('SIREN - Edit - ' + self.in_file[self.in_file.rfind('/') + 1:]) size = self.geometry() self.setGeometry(1, 1, ln + 10, ln2 + 35) size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) self.widget.show()