Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Cousin Stanley Newsgroups: comp.lang.python Subject: Re: pyGTK identify a button Date: Wed, 25 May 2011 16:22:36 +0000 (UTC) Organization: A noiseless patient Spider Lines: 72 Message-ID: References: <4ddcbb68$0$18241$4fafbaef@reader2.news.tin.it> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Wed, 25 May 2011 16:22:36 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="J8M54pkfo9wqKO65xgUpMg"; logging-data="13579"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tTtBGDCFtOp9oOPXZqtvGt6euKFhzmpc=" User-Agent: XPN/1.2.6 (Street Spirit ; Linux) Cancel-Lock: sha1:30BI0nNAn8yGJ5osa6+pmmeiEp4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6251 Tracubik wrote: > Hi all, > i'm trying to write a simple windows with two button in GTK, > i need a way to identify wich button is pressed. > .... #!/usr/bin/env python import gtk def console_display( button , args ) : a0 , a1 , a2 = args print ' %s .... %s %s ' % ( a0 , a1 , a2 ) window = gtk.Window() window.set_title( "gtk.buttons.01" ) window.set_size_request( 300 , -1 ) window.set_position( gtk.WIN_POS_CENTER ) window.connect( "destroy" , gtk.main_quit ) # Create VBox and add in Window vbox = gtk.VBox() window.add( vbox ) # Create buttons dict_buttons = { 12 : [ 'OneTwo' , 'Buckle ' , 'My Shoe' ] , 34 : [ 'TreFor' , 'Shut ' , 'The Door' ] , 56 : [ 'FivSix' , 'Pick ' , 'Up Sticks' ] , 78 : [ 'SvnAte' , 'Lay ' , 'Them Straight' ] , 910 : [ 'NinTen' , 'Big ' , 'Fat Hen' ] } list_keys = dict_buttons.keys() list_keys.sort() for this_button in list_keys : this_name = dict_buttons[ this_button ][ 0 ] b = gtk.Button( this_name ) b.set_name( this_name ) b.connect( "clicked" , console_display , dict_buttons[ this_button ] ) vbox.pack_start( b ) window.show_all() gtk.main() -- Stanley C. Kitching Human Being Phoenix, Arizona