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 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 license_(self): lic = QTextEdit(self) lic.setWindowFlags(Qt.Window) lic.setWindowTitle("QReduce FreeBSD License") font = lic.font() font.setFamily('') font.setFixedPitch(True) font.setKerning(0) font.setWeight(QFont.Normal) font.setItalic(False) lic.setFont(font) lic.setText( 'Copyright (c) 2009-2014 T. Sturm, 2010 C. Zengler' '<p>' 'All rights reserved.' '<p>' 'Redistribution and use in source and binary forms, with ' 'or without modification, are permitted provided that the ' 'following conditions are met:' '<ol>' '<li>Redistributions of source code must retain the relevant ' 'copyright notice, this list of conditions and the following ' 'disclaimer. ' '<p>' '<li>Redistributions in binary form must reproduce the above ' 'copyright notice, this list of conditions and the following ' 'disclaimer in the documentation and/or other materials ' 'provided with the distribution. ' '</ol>' '<p>' 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ' 'CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ' 'INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ' 'MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ' 'DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR ' 'CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ' 'SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ' 'NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ' 'LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ' 'HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ' 'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ' 'OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ' 'SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.' '</span>') lic.setReadOnly(True) w = 66 * lic.fontMetrics().width('m') h = 36 * lic.fontMetrics().height() lic.resize(w,h) lic.show() lic.raise_()
""" try: return self.__d.translate( text.encode(self.INPUT_ENCODING, errors='ignore')).decode(self.OUTPUT_ENCODING, errors='ignore') except (WindowsError, AttributeError), e: dwarn("failed to load D_JK dll, raise runtime error", e) raise RuntimeError("failed to access D_JK dll") #except UnicodeError, e: # dwarn(e) if __name__ == '__main__': # DEBUG import os os.environ[ 'PATH'] += os.pathsep + r"Z:\Local\Windows\Applications\DICO SYSTEM\TransCAT KJJK" l = Loader() l.init() #ret = l.translate(u"お花の匂い☆") ret = l.translate(u"「まあね♪スカートとはおさらばだし。ハーフパンツなんて久しぶり♪」") from PySide.QtGui import QApplication, QTextEdit a = QApplication(sys.argv) w = QTextEdit(ret) w.show() a.exec_() # EOF