summaryrefslogtreecommitdiffstats
path: root/examples3/menu.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples3/menu.py')
-rwxr-xr-xexamples3/menu.py102
1 files changed, 51 insertions, 51 deletions
diff --git a/examples3/menu.py b/examples3/menu.py
index baab2a6..bb3f998 100755
--- a/examples3/menu.py
+++ b/examples3/menu.py
@@ -5,7 +5,7 @@
#**
#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
#**
-#** This file is part of an example program for PyQt. This example
+#** This file is part of an example program for PyTQt. This example
#** program may be used, distributed and modified without limitation.
#**
#*****************************************************************************/
@@ -92,30 +92,30 @@ p3_xpm = [
# Auxiliary class to provide fancy menu items with different fonts.
# Used for the "bold" and "underline" menu items in the options menu.
-class MyMenuItem( QCustomMenuItem ):
+class MyMenuItem( TQCustomMenuItem ):
def __init__( self, s, f ):
- QCustomMenuItem.__init__( self )
+ TQCustomMenuItem.__init__( self )
self.string = s
self.font = f
def paint( self, p, cg, act, enabled, x, y, w, h ) :
p.setFont ( self.font )
- p.drawText( x, y, w, h, Qt.AlignLeft | Qt.AlignVCenter | Qt.ShowPrefix | Qt.DontClip, self.string )
+ p.drawText( x, y, w, h, TQt.AlignLeft | TQt.AlignVCenter | TQt.ShowPrefix | TQt.DontClip, self.string )
def sizeHint( self ):
- return QFontMetrics( self.font ).size( Qt.AlignLeft | Qt.AlignVCenter | Qt.ShowPrefix | Qt.DontClip, self.string )
+ return TQFontMetrics( self.font ).size( TQt.AlignLeft | TQt.AlignVCenter | TQt.ShowPrefix | TQt.DontClip, self.string )
# Implementation of MenuExample class
-class MenuExample( QWidget ):
+class MenuExample( TQWidget ):
def __init__( self, parent=None, name=None ):
- QWidget.__init__( self, parent, name )
- self.p1 = QIconSet( QPixmap ( p1_xpm ) )
- self.p2 = QIconSet( QPixmap ( p2_xpm ) )
- self.p3 = QIconSet( QPixmap ( p3_xpm ) )
+ TQWidget.__init__( self, parent, name )
+ self.p1 = TQIconSet( TQPixmap ( p1_xpm ) )
+ self.p2 = TQIconSet( TQPixmap ( p2_xpm ) )
+ self.p3 = TQIconSet( TQPixmap ( p3_xpm ) )
- self.printer = QPopupMenu( self )
+ self.printer = TQPopupMenu( self )
self.printer.insertTearOffHandle()
self.printer.insertItem( "&Print to printer", self.printDoc )
self.printer.insertItem( "Print to &file", self.printFile )
@@ -123,23 +123,23 @@ class MenuExample( QWidget ):
self.printer.insertSeparator()
self.printer.insertItem( "Printer &Setup", self.printerSetup )
- self.file = QPopupMenu( self )
- self.file.insertItem( self.p1, "&Open", self.open, Qt.CTRL+Qt.Key_O )
- self.file.insertItem( self.p2, "&New", self.news, Qt.CTRL+Qt.Key_N )
- self.file.insertItem( self.p3, "&Save", self.save, Qt.CTRL+Qt.Key_S )
- self.file.insertItem( "&Close", self.closeDoc, Qt.CTRL+Qt.Key_W )
+ self.file = TQPopupMenu( self )
+ self.file.insertItem( self.p1, "&Open", self.open, TQt.CTRL+TQt.Key_O )
+ self.file.insertItem( self.p2, "&New", self.news, TQt.CTRL+TQt.Key_N )
+ self.file.insertItem( self.p3, "&Save", self.save, TQt.CTRL+TQt.Key_S )
+ self.file.insertItem( "&Close", self.closeDoc, TQt.CTRL+TQt.Key_W )
self.file.insertSeparator()
- self.file.insertItem( "&Print", self.printer, Qt.CTRL+Qt.Key_P )
+ self.file.insertItem( "&Print", self.printer, TQt.CTRL+TQt.Key_P )
self.file.insertSeparator()
- self.file.insertItem( "E&xit", qApp, SLOT( "quit()" ), Qt.CTRL+Qt.Key_Q )
+ self.file.insertItem( "E&xit", qApp, SLOT( "quit()" ), TQt.CTRL+TQt.Key_Q )
- self.edit = QPopupMenu( self )
+ self.edit = TQPopupMenu( self )
undoID = self.edit.insertItem( "&Undo", self.undo )
redoID = self.edit.insertItem( "&Redo", self.redo )
self.edit.setItemEnabled( undoID, FALSE )
self.edit.setItemEnabled( redoID, FALSE )
- self.options = QPopupMenu( self )
+ self.options = TQPopupMenu( self )
self.options.insertTearOffHandle()
self.options.setCaption( "Options" )
self.options.insertItem( "&Normal Font", self.normal )
@@ -149,63 +149,63 @@ class MenuExample( QWidget ):
f = self.options.font()
f.setBold( TRUE )
self.boldID = self.options.insertItem( MyMenuItem( "Bold", f ) )
- self.options.setAccel( Qt.CTRL+Qt.Key_B, self.boldID )
+ self.options.setAccel( TQt.CTRL+TQt.Key_B, self.boldID )
self.options.connectItem( self.boldID, self.bold )
f = self.options.font()
f.setUnderline( TRUE )
self.underlineID = self.options.insertItem( MyMenuItem( "Underline", f ) )
- self.options.setAccel( Qt.CTRL+Qt.Key_U, self.underlineID )
+ self.options.setAccel( TQt.CTRL+TQt.Key_U, self.underlineID )
self.options.connectItem( self.underlineID, self.underline )
self.isBold = FALSE
self.isUnderline = FALSE
self.options.setCheckable( TRUE )
- self.help = QPopupMenu( self )
- self.help.insertItem( "&About", self.about, Qt.CTRL+Qt.Key_H )
- self.help.insertItem( "About &Qt", self.aboutQt )
+ self.help = TQPopupMenu( self )
+ self.help.insertItem( "&About", self.about, TQt.CTRL+TQt.Key_H )
+ self.help.insertItem( "About &TQt", self.aboutTQt )
- self.menu = QMenuBar( self )
+ self.menu = TQMenuBar( self )
self.menu.insertItem( "&File", self.file )
self.menu.insertItem( "&Edit", self.edit )
self.menu.insertItem( "&Options", self.options )
self.menu.insertSeparator()
self.menu.insertItem( "&Help", self.help )
- self.menu.setSeparator( QMenuBar.InWindowsStyle )
+ self.menu.setSeparator( TQMenuBar.InWindowsStyle )
- msg = QLabel( self )
+ msg = TQLabel( self )
msg.setText( "A context menu is available.\n"
"Invoke it by right-clicking or by"
" pressing the 'context' button." )
msg.setGeometry( 0, self.height() - 60, self.width(), 60 )
- msg.setAlignment( Qt.AlignCenter )
+ msg.setAlignment( TQt.AlignCenter )
- self.label = QLabel( self )
+ self.label = TQLabel( self )
self.label.setGeometry( 20, self.rect().center().y()-20, self.width()-40, 40 )
- self.label.setFrameStyle( QFrame.Box | QFrame.Raised )
+ self.label.setFrameStyle( TQFrame.Box | TQFrame.Raised )
self.label.setLineWidth( 1 )
- self.label.setAlignment( Qt.AlignCenter )
+ self.label.setAlignment( TQt.AlignCenter )
- self.connect( self, PYSIGNAL( "explain" ), self.label, SLOT( "setText(const QString &" ) )
+ self.connect( self, PYSIGNAL( "explain" ), self.label, SLOT( "setText(const TQString &" ) )
self.setMinimumSize( 100, 80 )
- self.setFocusPolicy( QWidget.ClickFocus )
+ self.setFocusPolicy( TQWidget.ClickFocus )
def contextMenuEvent(self, cmev):
- contextMenu = QPopupMenu( self )
- caption = QLabel( "<font color=darkblue><u><b>Context Menu</b></u></font>", self )
- caption.setAlignment( Qt.AlignCenter )
+ contextMenu = TQPopupMenu( self )
+ caption = TQLabel( "<font color=darkblue><u><b>Context Menu</b></u></font>", self )
+ caption.setAlignment( TQt.AlignCenter )
contextMenu.insertItem( caption )
- contextMenu.insertItem( "&New", self.news, Qt.CTRL+Qt.Key_N )
- contextMenu.insertItem( "&Open...", self.open, Qt.CTRL+Qt.Key_O )
- contextMenu.insertItem( "&Save", self.save, Qt.CTRL+Qt.Key_S )
- submenu = QPopupMenu( self )
+ contextMenu.insertItem( "&New", self.news, TQt.CTRL+TQt.Key_N )
+ contextMenu.insertItem( "&Open...", self.open, TQt.CTRL+TQt.Key_O )
+ contextMenu.insertItem( "&Save", self.save, TQt.CTRL+TQt.Key_S )
+ submenu = TQPopupMenu( self )
submenu.insertItem( "&Print to printer", self.printDoc )
submenu.insertItem( "Print to &file", self.printFile )
submenu.insertItem( "Print to fa&x", self.fax )
contextMenu.insertItem( "&Print", submenu )
- contextMenu.exec_loop( QCursor.pos() )
+ contextMenu.exec_loop( TQCursor.pos() )
def open( self ):
self.emit( PYSIGNAL( "explain" ), ( "File/Open selected", ) )
@@ -228,7 +228,7 @@ class MenuExample( QWidget ):
def normal( self ):
self.isBold = FALSE
self.isUnderline = FALSE
- font = QFont()
+ font = TQFont()
self.label.setFont( font )
self.options.setItemChecked( self.boldID, self.isBold )
self.options.setItemChecked( self.underlineID, self.isUnderline )
@@ -236,7 +236,7 @@ class MenuExample( QWidget ):
def bold( self ):
self.isBold = not self.isBold
- font = QFont()
+ font = TQFont()
font.setBold( self.isBold )
font.setUnderline( self.isUnderline )
self.label.setFont( font )
@@ -245,7 +245,7 @@ class MenuExample( QWidget ):
def underline( self ):
self.isUnderline = not self.isUnderline
- font = QFont()
+ font = TQFont()
font.setBold( self.isBold )
font.setUnderline( self.isUnderline )
self.label.setFont( font )
@@ -253,13 +253,13 @@ class MenuExample( QWidget ):
self.emit( PYSIGNAL("explain"), ( "Options/Underline selected", ))
def about( self ):
- QMessageBox.about( self, "Qt Menu Example",
- "This example demonstrates simple use of Qt menus.\n"
+ TQMessageBox.about( self, "TQt Menu Example",
+ "This example demonstrates simple use of TQt menus.\n"
"You can cut and paste lines from it to your own\n"
"programs." )
- def aboutQt( self ):
- QMessageBox.aboutQt( self, "Qt Menu Example" )
+ def aboutTQt( self ):
+ TQMessageBox.aboutTQt( self, "TQt Menu Example" )
def printDoc( self ):
self.emit( PYSIGNAL( "explain" ), ( "File/Printer/Print selected", ) )
@@ -277,10 +277,10 @@ class MenuExample( QWidget ):
self.label.setGeometry( 20, self.rect().center().y()-20, self.width()-40, 40 )
-a = QApplication( sys.argv )
+a = TQApplication( sys.argv )
m = MenuExample()
-m.setCaption( "Qt Examples - Menus" )
+m.setCaption( "TQt Examples - Menus" )
a.setMainWidget( m )
m.show()
a.exec_loop()