本文整理汇总了Python中PySide.QtGui.QTextEdit类的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit类的具体用法?Python QTextEdit怎么用?Python QTextEdit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTextEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyMainWindow
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")
示例2: QAbstractTextDocumentLayoutTest
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)
示例3: addAction
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)
示例4: __init__
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
示例5: keyPressEvent
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)
示例6: MainWindow
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")
示例7: Console
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)
示例8: testRefcount
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)
示例9: __init__
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)
示例10: SetupComponents
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)
示例11: setupUI
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")
示例12: __init__
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)
示例13: __init__
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)
示例14: __init__
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)
示例15: focusNextPrevChild
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 )