From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- python/pyqt/examples3/richtext.py | 136 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 python/pyqt/examples3/richtext.py (limited to 'python/pyqt/examples3/richtext.py') diff --git a/python/pyqt/examples3/richtext.py b/python/pyqt/examples3/richtext.py new file mode 100755 index 00000000..8ec4b0b4 --- /dev/null +++ b/python/pyqt/examples3/richtext.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python + +"""************************************************************************** +** $Id$ +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of an example program for Qt. This example +** program may be used, distributed and modified without limitation. +** +***************************************************************************""" + +import sys +from qt import * + +sayings = [ + "Saying 1:
" + "


" + "Evil is that which one believes of others. It is a sin to believe evil " + "of others, but it is seldom a mistake.

" + "
-- H.L. Mencken
", + + "Saying 2:
" + "


" + "A well-used door needs no oil on its hinges.
" + "A swift-flowing steam does not grow stagnant.
" + "Neither sound nor thoughts can travel through a vacuum.
" + "Software rots if not used.

" + "These are great mysteries.


" + "
-- Geoffrey James, \"The Tao of Programming\"
", + + "Saying 3:
" + "


" + "Show business is just like high school, except you get paid.

" + "
-- Martin Mull
", + + "Saying 4:
" + "


" + "The Least Successful Executions
" + "

History has furnished us with two executioners worthy of attention. " + "The first performed in Sydney in Australia. In 1803 three attempts were " + "made to hang a Mr. Joseph Samuels. On the first two of these the rope " + "snapped, while on the third Mr. Samuels just hung there peacefully until he " + "and everyone else got bored. Since he had proved unsusceptible to capital " + "punishment, he was reprieved.

" + "

The most important British executioner was Mr. James Berry who " + "tried three times in 1885 to hang Mr. John Lee at Exeter Jail, but on each " + "occasion failed to get the trap door open." + "

In recognition of this achievement, the Home Secretary commuted " + "Lee's sentence to \"life\" imprisonment. He was released in 1917, emigrated " + "to America and lived until 1933.



" + "
-- Stephen Pile, \"The Book of Heroic Failures\"
", + + "Saying 5:
" + "


" + "If you can, help others. If you can't, at least don't hurt others.

" + "
-- the Dalai Lama
", + + "Saying 6:
" + "


" + "Television has brought back murder into the home -- where it belongs.

" + "
-- Alfred Hitchcock
", + + "Saying 7:
" + "


" + "I don't know who my grandfather was; I am much more concerned to know " + "what his grandson will be.

" + "
-- Abraham Lincoln
", + + 0 +] + +class MyRichText( QVBox ): + def __init__( self, parent = None, name = None ): + QVBox.__init__( self, parent, name ) + + self.setMargin( 5 ) + + self.view = QTextView( self ) + #self.view.setText( "This is a Test with italic stuff" ) + paper = QBrush() + paper.setPixmap( QPixmap( "marble.png" ) ) + if paper.pixmap() != 0 : + self.view.setPaper( paper ) + else : + self.view.setPaper( white ) + + self.view.setText( sayings[0] ) + self.view.setMinimumSize( 450, 250 ) + + buttons = QHBox( self ) + buttons.setMargin( 5 ) + + self.bClose = QPushButton( "&Close", buttons ) + self.bPrev = QPushButton( "<< &Prev", buttons ) + self.bNext = QPushButton( "&Next >>", buttons ) + + self.bPrev.setEnabled( False ) + + self.connect( self.bClose, SIGNAL("clicked()"), qApp, SLOT("quit()") ) + self.connect( self.bPrev, SIGNAL("clicked()"), self.prev ) + self.connect( self.bNext, SIGNAL("clicked()"), self.next ) + + self.num = 0 + + def prev( self ): + if self.num <= 0 : + return + self.num -= 1 + self.view.setText( sayings[self.num] ) + if self.num == 0 : + self.bPrev.setEnabled( False ) + self.bNext.setEnabled( True ) + + def next( self ): + self.num += 1 + if not sayings[self.num]: + return + self.view.setText( sayings[self.num] ) + if not sayings[self.num + 1]: + self.bNext.setEnabled( False ) + self.bPrev.setEnabled( True ) + +def main( args ): + a = QApplication(sys.argv) # application object + + richtext = MyRichText() + richtext.resize( 450, 350 ); + richtext.setCaption( "Qt Example - Richtext" ) + a.setMainWidget( richtext ) + richtext.show() + + a.exec_loop() + +if __name__=="__main__": + main(sys.argv) -- cgit v1.2.3