本文整理汇总了Python中PySide.QtGui.QTextEdit.find方法的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit.find方法的具体用法?Python QTextEdit.find怎么用?Python QTextEdit.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QTextEdit
的用法示例。
在下文中一共展示了QTextEdit.find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EditorWindow
# 需要导入模块: from PySide.QtGui import QTextEdit [as 别名]
# 或者: from PySide.QtGui.QTextEdit import find [as 别名]
class EditorWindow(QMainWindow):
"""initialize editor"""
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 find(self, word) :
self.editor.find(self.searchbox.text(), QTextDocument.FindBackward)
def search(self, xpath):
print "test"
示例2: qNotebook
# 需要导入模块: from PySide.QtGui import QTextEdit [as 别名]
# 或者: from PySide.QtGui.QTextEdit import find [as 别名]
class qNotebook(QVBoxLayout):
def __init__(self):
QVBoxLayout.__init__(self)
self._teditor = QTextEdit()
self._teditor.setMinimumWidth(500)
self._teditor.setStyleSheet("font: 12pt \"Courier\";")
button_layout = QHBoxLayout()
self.addLayout(button_layout)
self.clear_but = qmy_button(button_layout, self.clear_all, "clear")
self.copy_but = qmy_button(button_layout, self._teditor.copy, "copy")
qmy_button(button_layout, self._teditor.selectAll, "select all")
qmy_button(button_layout, self._teditor.undo, "undo")
qmy_button(button_layout, self._teditor.redo, "redo")
search_button = qButtonWithArgumentsClass("search", self.search_for_text, {"search_text": ""})
button_layout.addWidget(search_button)
qmy_button(button_layout, self.save_as_html, "save notebook")
self.addWidget(self._teditor)
self._teditor.document().setUndoRedoEnabled(True)
self.image_counter = 0
self.image_dict = {}
self.image_data_dict = {}
def append_text(self, text):
self._teditor.append(str(text))
def search_for_text(self, search_text = " "):
self._teditor.find(search_text)
def clear_all(self):
self._teditor.clear()
self.image_dict = {}
self.image_counter = 0
# newdoc = QTextDocument()
# self._teditor.setDocument(newdoc)
def append_image(self, fig=None):
#This assumes that an image is there waiting to be saved from matplotlib
self.imgdata = StringIO.StringIO()
if fig is None:
pyplot.savefig(self.imgdata, transparent = False, format = img_format)
else:
fig.savefig(self.imgdata, transparent = False, format = img_format)
self.abuffer = QBuffer()
self.abuffer.open(QBuffer.ReadWrite)
self.abuffer.write(self.imgdata.getvalue())
self.abuffer.close()
self.abuffer.open(QBuffer.ReadOnly)
iReader = QImageReader(self.abuffer, img_format )
the_image = iReader.read()
# the_image = the_image0.scaledToWidth(figure_width)
# save the image in a file
imageFileName = "image" + str(self.image_counter) + "." + img_format
self.image_data_dict[imageFileName] = self.imgdata
self.image_counter +=1
imageFormat = QTextImageFormat()
imageFormat.setName(imageFileName)
imageFormat.setWidth(image_width)
self.image_dict[imageFileName] = the_image
#insert the image in the text document
text_doc = self._teditor.document()
text_doc.addResource(QTextDocument.ImageResource, QUrl(imageFileName), the_image)
cursor = self._teditor.textCursor()
cursor.movePosition(QTextCursor.End)
cursor.insertImage(imageFormat)
def add_image_data_resource(self, imgdata, imageFileName):
self.abuffer = QBuffer()
self.abuffer.open(QBuffer.ReadWrite)
self.abuffer.write(imgdata.getvalue())
self.abuffer.close()
self.abuffer.open(QBuffer.ReadOnly)
iReader = QImageReader(self.abuffer, img_format )
the_image = iReader.read()
# the_image = the_image0.scaledToWidth(figure_width)
# save the image in a file
# imageFileName = "image" + str(self.image_counter) + "." + img_format
self.image_data_dict[imageFileName] = imgdata
# self.image_counter +=1
imageFormat = QTextImageFormat()
imageFormat.setName(imageFileName)
imageFormat.setWidth(image_width)
self.image_dict[imageFileName] = the_image
#insert the image in the text document
text_doc = self._teditor.document()
text_doc.addResource(QTextDocument.ImageResource, QUrl(imageFileName), the_image)
def append_html_table_from_array(self, a, header_rows=0, precision = 3, caption = None, cmap = None):
nrows = len(a)
ncols = len(a[0])
#.........这里部分代码省略.........