[PyKDE] ~QStatusBar() doesn't work

cheng cheng at innoverse.com
Tue Oct 9 00:48:25 BST 2001


1.  I tried to use the command ~QStatusBar(); however, it doesn't work.  I
can clear the message that's on the statusbar only.

2.  For the toolbar, if I put the code in the class, it works.  However, if
I put the code in the function, the toolbar doesn't show up.

Following is my code:

#!/usr/bin/env python

import sys, string
from qt import *

TRUE  = 1
FALSE = 0

fileopen = [
'    16    13        5            1',
'. c #040404',
'# c #808304',
'a c None',
'b c #f3f704',
'c c #f3f7f3',
'aaaaaaaaa...aaaa',
'aaaaaaaa.aaa.a.a',
'aaaaaaaaaaaaa..a',
'a...aaaaaaaa...a',
'.bcb.......aaaaa',
'.cbcbcbcbc.aaaaa',
'.bcbcbcbcb.aaaaa',
'.cbcb...........',
'.bcb.#########.a',
'.cb.#########.aa',
'.b.#########.aaa',
'..#########.aaaa',
'...........aaaaa'
]


class MenuExample( QMainWindow ):
  def __init__( self ):
      QMainWindow.__init__(self,None, 'example application main window',
Qt.WDestructiveClose)

      self.toolbar = QPopupMenu( self )
      self.standardID = self.toolbar.insertItem( "Standard Buttons" )
      self.toolbar.connectItem( self.standardID, self.standard )
      self.EliminateID = self.toolbar.insertItem( "'Eliminate' Buttons" )
      self.toolbar.connectItem( self.EliminateID, self.eliminateButton )

      self.isEliminate = FALSE
      self.isStandard = FALSE
      self.toolbar.setCheckable( TRUE )

      self.view = QPopupMenu( self )
      #CHECK_PTR( self.options )
      self.menuBar().insertItem ( "View", self.view )
      self.view.insertItem( "Toolbars",  self.toolbar )
      self.barID = self.view.insertItem( "Status Bar" )
      self.view.connectItem( self.barID, self.statusbar )

      self.isBar = FALSE
      self.view.setCheckable( TRUE )

      self.e = QMultiLineEdit( self, 'editor' )
      self.e.setFocus()
      self.setCentralWidget(self.e)

      self.resize(600,350)
      self.setMinimumSize( 620, 330 )

  def statusbar( self ):
    self.isBar = not self.isBar
    self.view.setItemChecked( self.barID, self.isBar )
    if self.isBar == TRUE:
      self.statusBar().message('Ready',2000)
    elif self.isBar == FALSE:
      self.statusBar().clear()
      ~QStatusBar()

  def standard( self ):
    self.isStandard = not self.isStandard
    self.toolbar.setItemChecked( self.standardID, self.isStandard )

    self.fileTools = QToolBar(self,'file operations')

    self.openIcon = QPixmap(fileopen)
    self.fileOpen = QToolButton(self.openIcon,'Open

File',QString.null,self.bold,self.fileTools,'open file')
    self.fileOpen.setAutoRaise( TRUE )


  def eliminateButton( self ):
    self.isEliminate = not self.isEliminate
    self.toolbar.setItemChecked( self.EliminateID, self.isEliminate )
    self.emit ( PYSIGNAL( "explain" ), ( "standard", ) )

  def bold( self ):
    self.isBold = not self.isBold
    self.view.setItemChecked( self.boldID, self.isBold )
    self.emit ( PYSIGNAL( "explain" ), ( "view/Bold selected", ) )

a = QApplication( sys.argv )
m = MenuExample()
m.setCaption( 'MenuExample' )
m.show()
a.connect( a, SIGNAL('lastWindowClosed()'), a, SLOT('quit()') )
a.exec_loop()


Thank you.

Cheng





More information about the PyQt mailing list