SIP4 python bindings for TQt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tabdialog.py 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/usr/bin/env python
  2. """**************************************************************************
  3. ** $Id: tabdialog.py,v 1.1 2003/07/01 14:18:37 phil Exp $
  4. **
  5. ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
  6. **
  7. ** This file is part of an example program for TQt. This example
  8. ** program may be used, distributed and modified without limitation.
  9. **
  10. ***************************************************************************"""
  11. import sys
  12. from python_tqt.qt import *
  13. class TabDialog( TQTabDialog ):
  14. def __init__( self, parent=None, name=None, filename=None ):
  15. TQTabDialog.__init__( self, parent, name )
  16. self.filename = TQString( filename )
  17. self.fileinfo = TQFileInfo( filename )
  18. self.setupTab1()
  19. self.setupTab2()
  20. self.setupTab3()
  21. self.connect( self, SIGNAL("applyButtonPressed()"), tqApp, SLOT("quit()" ) )
  22. def setupTab1( self ):
  23. tab1 = TQVBox( self )
  24. tab1.setMargin( 5 )
  25. TQLabel( "Filename:", tab1 )
  26. fname = TQLineEdit( self.filename, tab1 )
  27. fname.setFocus()
  28. TQLabel( "Path:", tab1 )
  29. path = TQLabel( self.fileinfo.dirPath( True ), tab1 )
  30. path.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
  31. TQLabel( "Size:", tab1 )
  32. size = TQLabel( TQString( "%1 KB" ).arg( self.fileinfo.size() ), tab1 )
  33. size.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
  34. TQLabel( "Last Read:", tab1 )
  35. lread = TQLabel( self.fileinfo.lastRead().toString(), tab1 )
  36. lread.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
  37. TQLabel( "Last Modified:", tab1 )
  38. lmodif = TQLabel( self.fileinfo.lastModified().toString(), tab1 )
  39. lmodif.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
  40. self.addTab( tab1, "General" )
  41. def setupTab2( self ):
  42. tab2 = TQVBox( self )
  43. tab2.setMargin( 5 )
  44. bg = TQButtonGroup( 1, TQGroupBox.Horizontal, "Permissions", tab2 )
  45. readable = TQCheckBox( "Readable", bg )
  46. if self.fileinfo.isReadable() :
  47. readable.setChecked( True )
  48. writable = TQCheckBox( "Writeable", bg )
  49. if self.fileinfo.isWritable() :
  50. writable.setChecked( True )
  51. executable = TQCheckBox( "Executable", bg )
  52. if self.fileinfo.isExecutable() :
  53. executable.setChecked( True )
  54. bg2 = TQButtonGroup( 2, TQGroupBox.Horizontal, "Owner", tab2 )
  55. TQLabel( "Owner", bg2 )
  56. owner = TQLabel( self.fileinfo.owner(), bg2 )
  57. owner.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
  58. TQLabel( "Group", bg2 )
  59. group = TQLabel( self.fileinfo.group(), bg2 )
  60. group.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
  61. self.addTab( tab2, "Permissions" )
  62. def setupTab3( self ):
  63. tab3 = TQVBox( self )
  64. tab3.setMargin( 5 )
  65. tab3.setSpacing( 5 )
  66. TQLabel( TQString( "Open %1 with:" ).arg( self.filename ), tab3 )
  67. prgs = TQListBox( tab3 )
  68. for i in range( 0, 30, 1 ) :
  69. prg = TQString( "Application %1" ).arg( i )
  70. prgs.insertItem( prg )
  71. prgs.setCurrentItem( 3 )
  72. TQCheckBox( TQString( "Open files with the extension '%1' always with this application" ).arg( self.fileinfo.extension() ), tab3 )
  73. self.addTab( tab3, "Applications" )
  74. def main( args ):
  75. a = TQApplication(sys.argv)
  76. #sys.argv.append("tabdialog.py") # to test uncomment this line
  77. if len(sys.argv) < 2:
  78. filename = TQString(".")
  79. else:
  80. filename = TQString(sys.argv[1])
  81. tabdialog = TabDialog( None, "tabdialog", filename )
  82. tabdialog.resize( 450, 350 );
  83. tabdialog.setCaption( "TQt Example - Tabbed Dialog" )
  84. a.setMainWidget( tabdialog )
  85. tabdialog.show()
  86. a.exec_loop()
  87. if __name__=="__main__":
  88. main(sys.argv)