Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6251
| 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 <cousinstanley@gmail.com> |
| 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 | <irjacb$d8b$1@dont-email.me> (permalink) |
| 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 |
Show key headers only | View raw
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pyGTK identify a button Tracubik <affdfsdfdsfsd@b.com> - 2011-05-25 10:18 +0200
Re: pyGTK identify a button Claudiu Nicolaie CISMARU <claudiu@virtuamagic.com> - 2011-05-25 11:44 +0300
Re: pyGTK identify a button Tracubik <affdfsdfdsfsd@b.com> - 2011-05-25 10:51 +0200
Re: pyGTK identify a button Claudiu Nicolaie CISMARU <claudiu@virtuamagic.com> - 2011-05-25 12:19 +0300
Re: pyGTK identify a button Chris Angelico <rosuav@gmail.com> - 2011-05-25 18:58 +1000
Re: pyGTK identify a button Cousin Stanley <cousinstanley@gmail.com> - 2011-05-25 16:22 +0000
Re: pyGTK identify a button Alister Ware <alister.ware@ntlworld.com> - 2011-05-26 17:50 +0000
csiph-web