PyQT picture display
Jim
jimb417 at NO*
Fri Sep 6 22:40:39 EDT 2002
Hello to all,
I've a widget with three buttons and a label. I want to display a JPEG
picture when either of the first two buttons is clicked. When I run the
code below, the widget displays on screen but when either button is clicked,
the picture does not appear( the text in the label disappears as it should
). Can anyone tell me what I'm doing wrong here?
Thanks,
Jim
from qt import *
import sys
class Picts(QWidget):
def __init__( self, parent = None, name = None ):
QWidget.__init__( self, parent, name )
global Picture1
global Picture2
Picture1 = QPixmap( "!Pict1.jpg" )
Picture2 = QPixmap( "!Pict2.jpg" )
self.label = QLabel( "Click to see a picture!", self )
self.label.setGeometry( 50, 50, 300, 300 )
button1 = QPushButton( "Picture 1",self )
button1.setGeometry( 10, 10, 80, 30 )
button2 = QPushButton( "Picture 2",self )
button2.setGeometry( 100, 10, 80, 30 )
button3 = QPushButton( "Quit", self )
button3.setGeometry( 190, 10, 80, 30 )
self.connect( button1, SIGNAL( "clicked()" ), self.setPicture1 )
self.connect( button2, SIGNAL( "clicked()" ), self.setPicture2 )
self.connect( button3, SIGNAL( "clicked()" ), qApp, SLOT( "quit()" ) )
def setPicture1( self ):
self.label.setPixmap( Picture1 )
def setPicture2( self ):
self.label.setPixmap( Picture2 )
app = QApplication( sys.argv )
w = Picts()
w.setGeometry( 100, 100, 500, 500 )
app.setMainWidget( w )
w.show()
app.exec_loop()
--
Registered Linux User #269187
http://counter.li.org
More information about the Python-list
mailing list