diff options
Diffstat (limited to 'examples2/addressbook.py')
-rwxr-xr-x | examples2/addressbook.py | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/examples2/addressbook.py b/examples2/addressbook.py index d7316e3..e151996 100755 --- a/examples2/addressbook.py +++ b/examples2/addressbook.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# A port to PyQt of the application example from Qt v2.x. +# A port to PyTQt of the application example from TQt v2.x. import sys, string @@ -76,10 +76,10 @@ fileprint = [ 'dd...........ddd' ] -class ABCentralWidget( QWidget ): +class ABCentralWidget( TQWidget ): def __init__( self, *args ): - apply( QWidget.__init__, (self, ) + args ) - self.mainGrid = QGridLayout( self, 2, 1, 5, 5 ) + apply( TQWidget.__init__, (self, ) + args ) + self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 ) self.setupTabWidget() self.setupListView() @@ -91,16 +91,16 @@ class ABCentralWidget( QWidget ): if not self.listView.firstChild(): return - f = QFile( filename ) + f = TQFile( filename ) if not f.open( IO_WriteOnly ): return - t = QTextStream( f ) + t = TQTextStream( f ) - #it = QListViewItemIterator( self.listView ) + #it = TQListViewItemIterator( self.listView ) while not t.eof(): - item = QListViewItem( self.listView ) + item = TQListViewItem( self.listView ) for i in range (0, 4): t << item.text( i ) << '\n' #for it in it.current(): @@ -113,14 +113,14 @@ class ABCentralWidget( QWidget ): def load( self, filename ): self.listView.clear() - f = QFile( filename ) + f = TQFile( filename ) if not f.open( IO_ReadOnly ): return - t = QTextStream( f ) + t = TQTextStream( f ) while not t.eof(): - item = QListViewItem( self.listView ) + item = TQListViewItem( self.listView ) for i in range (0, 4): item.setText( i, t.readLine() ) @@ -128,53 +128,53 @@ class ABCentralWidget( QWidget ): def setupTabWidget( self ): - self.tabWidget = QTabWidget( self ) + self.tabWidget = TQTabWidget( self ) - self.input = QWidget( self.tabWidget ) - self.grid1 = QGridLayout( self.input, 2, 5, 5, 5 ) + self.input = TQWidget( self.tabWidget ) + self.grid1 = TQGridLayout( self.input, 2, 5, 5, 5 ) - self.liFirstName = QLabel( 'First &Name', self.input ) + self.liFirstName = TQLabel( 'First &Name', self.input ) self.liFirstName.resize( self.liFirstName.sizeHint() ) self.grid1.addWidget( self.liFirstName, 0, 0 ) - self.liLastName = QLabel( '&Last Name', self.input ) + self.liLastName = TQLabel( '&Last Name', self.input ) self.liLastName.resize( self.liLastName.sizeHint() ) self.grid1.addWidget( self.liLastName, 0, 1 ) - self.liAddress = QLabel( '&Address', self.input ) + self.liAddress = TQLabel( '&Address', self.input ) self.liAddress.resize( self.liAddress.sizeHint() ) self.grid1.addWidget( self.liAddress, 0, 2 ) - self.liEMail = QLabel( '&E-Mail', self.input ) + self.liEMail = TQLabel( '&E-Mail', self.input ) self.liEMail.resize( self.liEMail.sizeHint() ) self.grid1.addWidget( self.liEMail, 0, 3 ) - self.add = QPushButton( '&Add', self.input ) + self.add = TQPushButton( '&Add', self.input ) self.add.resize( self.add.sizeHint() ) self.grid1.addWidget( self.add, 0, 4 ) self.connect( self.add, SIGNAL( 'clicked()' ), self.addEntry ) - self.iFirstName = QLineEdit( self.input ) + self.iFirstName = TQLineEdit( self.input ) self.iFirstName.resize( self.iFirstName.sizeHint() ) self.grid1.addWidget( self.iFirstName, 1, 0 ) self.liFirstName.setBuddy( self.iFirstName ) - self.iLastName = QLineEdit( self.input ) + self.iLastName = TQLineEdit( self.input ) self.iLastName.resize( self.iLastName.sizeHint() ) self.grid1.addWidget( self.iLastName, 1, 1 ) self.liLastName.setBuddy( self.iLastName ) - self.iAddress = QLineEdit( self.input ) + self.iAddress = TQLineEdit( self.input ) self.iAddress.resize( self.iAddress.sizeHint() ) self.grid1.addWidget( self.iAddress, 1, 2 ) self.liAddress.setBuddy( self.iAddress ) - self.iEMail = QLineEdit( self.input ) + self.iEMail = TQLineEdit( self.input ) self.iEMail.resize( self.iEMail.sizeHint() ) self.grid1.addWidget( self.iEMail, 1, 3 ) self.liEMail.setBuddy( self.iEMail ) - self.change = QPushButton( '&Change', self.input ) + self.change = TQPushButton( '&Change', self.input ) self.change.resize( self.change.sizeHint() ) self.grid1.addWidget( self.change, 1, 4 ) self.connect( self.change, SIGNAL( 'clicked()' ), self.changeEntry ) @@ -183,46 +183,46 @@ class ABCentralWidget( QWidget ): # -------------------------------------- - self.search = QWidget( self ) - self.grid2 = QGridLayout( self.search, 2, 5, 5, 5 ) + self.search = TQWidget( self ) + self.grid2 = TQGridLayout( self.search, 2, 5, 5, 5 ) - self.cFirstName = QCheckBox( 'First &Name', self.search ) + self.cFirstName = TQCheckBox( 'First &Name', self.search ) self.cFirstName.resize( self.cFirstName.sizeHint() ) self.grid2.addWidget( self.cFirstName, 0, 0 ) self.connect( self.cFirstName, SIGNAL( 'clicked()' ), self.toggleFirstName ) - self.cLastName = QCheckBox( '&Last Name', self.search ) + self.cLastName = TQCheckBox( '&Last Name', self.search ) self.cLastName.resize( self.cLastName.sizeHint() ) self.grid2.addWidget( self.cLastName, 0, 1 ) self.connect( self.cLastName, SIGNAL( 'clicked()' ), self.toggleLastName ) - self.cAddress = QCheckBox( '&Address', self.search ) + self.cAddress = TQCheckBox( '&Address', self.search ) self.cAddress.resize( self.cAddress.sizeHint() ) self.grid2.addWidget( self.cAddress, 0, 2 ) self.connect( self.cAddress, SIGNAL( 'clicked()' ), self.toggleAddress ) - self.cEMail = QCheckBox( '&E-Mail', self.search ) + self.cEMail = TQCheckBox( '&E-Mail', self.search ) self.cEMail.resize( self.cEMail.sizeHint() ) self.grid2.addWidget( self.cEMail, 0, 3 ) self.connect( self.cEMail, SIGNAL( 'clicked()' ), self.toggleEMail ) - self.sFirstName = QLineEdit( self.search ) + self.sFirstName = TQLineEdit( self.search ) self.sFirstName.resize( self.sFirstName.sizeHint() ) self.grid2.addWidget( self.sFirstName, 1, 0 ) - self.sLastName = QLineEdit( self.search ) + self.sLastName = TQLineEdit( self.search ) self.sLastName.resize( self.sLastName.sizeHint() ) self.grid2.addWidget( self.sLastName, 1, 1 ) - self.sAddress = QLineEdit( self.search ) + self.sAddress = TQLineEdit( self.search ) self.sAddress.resize( self.sAddress.sizeHint() ) self.grid2.addWidget( self.sAddress, 1, 2 ) - self.sEMail = QLineEdit( self.search ) + self.sEMail = TQLineEdit( self.search ) self.sEMail.resize( self.sEMail.sizeHint() ) self.grid2.addWidget( self.sEMail, 1, 3 ) - self.find = QPushButton( '&Find', self.search ) + self.find = TQPushButton( '&Find', self.search ) self.find.resize( self.find.sizeHint() ) self.grid2.addWidget( self.find, 1, 4 ) self.connect( self.find, SIGNAL( 'clicked()' ), self.findEntries ) @@ -238,15 +238,15 @@ class ABCentralWidget( QWidget ): self.mainGrid.addWidget( self.tabWidget, 0, 0 ) def setupListView( self ): - self.listView = QListView( self ) + self.listView = TQListView( self ) self.listView.addColumn( 'First Name' ) self.listView.addColumn( 'Last Name' ) self.listView.addColumn( 'Address' ) self.listView.addColumn( 'E-Mail' ) - self.listView.setSelectionMode( QListView.Extended ) + self.listView.setSelectionMode( TQListView.Extended ) - self.connect( self.listView, SIGNAL( 'clicked( QListViewItem* )' ), self.itemSelected ) + self.connect( self.listView, SIGNAL( 'clicked( TQListViewItem* )' ), self.itemSelected ) self.mainGrid.addWidget( self.listView, 1, 0 ) self.listView.setAllColumnsShowFocus( TRUE ) @@ -255,7 +255,7 @@ class ABCentralWidget( QWidget ): def addEntry( self ): if not self.iFirstName.text().isEmpty() or not self.iLastName.text().isEmpty() or \ not self.iAddress.text().isEmpty() or not self.iEMail.text().isEmpty() : - self.item = QListViewItem( self.listView ) + self.item = TQListViewItem( self.listView ) self.item.setText( 0, self.iFirstName.text() ) self.item.setText( 1, self.iLastName.text() ) self.item.setText( 2, self.iAddress.text() ) @@ -332,7 +332,7 @@ class ABCentralWidget( QWidget ): self.listView.clearSelection() return - it = QListViewItemIterator( self.listView ) + it = TQListViewItemIterator( self.listView ) for it in it.current() : select = TRUE @@ -369,38 +369,38 @@ class ABCentralWidget( QWidget ): it.current().repaint() -class ABMainWindow(QMainWindow): +class ABMainWindow(TQMainWindow): def __init__( self ): - QMainWindow.__init__( self, None, 'example addressbook application' ) + TQMainWindow.__init__( self, None, 'example addressbook application' ) - self.filename = QString.null + self.filename = TQString.null self.setupMenuBar() self.setupFileTools() self.setupStatusBar() self.setupCentralWidget() def setupMenuBar( self ): - self.file = QPopupMenu( self ) + self.file = TQPopupMenu( self ) self.menuBar().insertItem( '&File', self.file ) - openIcon = QIconSet( QPixmap( fileopen ) ) - self.file.insertItem( 'New', self.fileNew, Qt.CTRL + Qt.Key_N ) - self.file.insertItem( openIcon, 'Open', self.fileOpen, Qt.CTRL + Qt.Key_O ) + openIcon = TQIconSet( TQPixmap( fileopen ) ) + self.file.insertItem( 'New', self.fileNew, TQt.CTRL + TQt.Key_N ) + self.file.insertItem( openIcon, 'Open', self.fileOpen, TQt.CTRL + TQt.Key_O ) self.file.insertSeparator() - saveIcon = QIconSet( QPixmap( filesave ) ) - self.file.insertItem( saveIcon, 'Save', self.fileSave, Qt.CTRL + Qt.Key_S ) + saveIcon = TQIconSet( TQPixmap( filesave ) ) + self.file.insertItem( saveIcon, 'Save', self.fileSave, TQt.CTRL + TQt.Key_S ) self.file.insertItem( 'Save As...', self.fileSaveAs ) self.file.insertSeparator() - printIcon = QIconSet( QPixmap( fileprint ) ) - self.file.insertItem( printIcon, 'Print...', self.filePrint, Qt.CTRL + Qt.Key_P ) + printIcon = TQIconSet( TQPixmap( fileprint ) ) + self.file.insertItem( printIcon, 'Print...', self.filePrint, TQt.CTRL + TQt.Key_P ) self.file.insertSeparator() - #self.file.insertItem( 'Close', self.closeWindow, Qt.CTRL + Qt.Key_W ) - self.file.insertItem('Close', self, SLOT('close()'), Qt.CTRL+Qt.Key_W) - self.file.insertItem( 'Quit', qApp, SLOT( 'quit()' ), Qt.CTRL + Qt.Key_Q ) + #self.file.insertItem( 'Close', self.closeWindow, TQt.CTRL + TQt.Key_W ) + self.file.insertItem('Close', self, SLOT('close()'), TQt.CTRL+TQt.Key_W) + self.file.insertItem( 'Quit', qApp, SLOT( 'quit()' ), TQt.CTRL + TQt.Key_Q ) def setupFileTools( self ): pass - #self.fileTools = QToolBar( self, 'file operations' ) + #self.fileTools = TQToolBar( self, 'file operations' ) def setupStatusBar( self ): self.statusBar().message( "Ready", 2000 ) @@ -418,7 +418,7 @@ class ABMainWindow(QMainWindow): pass def fileOpen( self ): - fn = QFileDialog.getOpenFileName( QString.null, QString.null, self ) + fn = TQFileDialog.getOpenFileName( TQString.null, TQString.null, self ) if not fn.isEmpty(): self.filename = fn self.view.load( self.filename ) @@ -431,7 +431,7 @@ class ABMainWindow(QMainWindow): self.view.save( self.filename ) def fileSaveAs( self ): - fn = QFileDialog.getSaveFileName( QString.null, QString.null, self ) + fn = TQFileDialog.getSaveFileName( TQString.null, TQString.null, self ) if not fn.isEmpty(): self.filename = fn self.fileSave @@ -440,7 +440,7 @@ class ABMainWindow(QMainWindow): pass -a = QApplication( sys.argv ) +a = TQApplication( sys.argv ) mw = ABMainWindow() #mw.setupMenuBar() |