Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6251
| From | Cousin Stanley <cousinstanley@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: pyGTK identify a button |
| Date | 2011-05-25 16:22 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <irjacb$d8b$1@dont-email.me> (permalink) |
| References | <4ddcbb68$0$18241$4fafbaef@reader2.news.tin.it> |
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