#!/usr/bin/env python """************************************************************************** ** $Id: richtext.py,v 1.1 2003/07/01 14:18:37 phil Exp $ ** ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. ** ** This file is part of an example program for TQt. This example ** program may be used, distributed and modified without limitation. ** ***************************************************************************""" import sys from PyTQt.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( TQVBox ): def __init__( self, parent = None, name = None ): TQVBox.__init__( self, parent, name ) self.setMargin( 5 ) self.view = TQTextView( self ) #self.view.setText( "This is a Test with italic stuff" ) paper = TQBrush() paper.setPixmap( TQPixmap( "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 = TQHBox( self ) buttons.setMargin( 5 ) self.bClose = TQPushButton( "&Close", buttons ) self.bPrev = TQPushButton( "<< &Prev", buttons ) self.bNext = TQPushButton( "&Next >>", buttons ) self.bPrev.setEnabled( False ) self.connect( self.bClose, SIGNAL("clicked()"), tqApp, 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 = TQApplication(sys.argv) # application object richtext = MyRichText() richtext.resize( 450, 350 ); richtext.setCaption( "TQt Example - Richtext" ) a.setMainWidget( richtext ) richtext.show() a.exec_loop() if __name__=="__main__": main(sys.argv)