Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #4064
| From | jake kaiden <jakekaiden@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Ruby Gtk2 and signal_connect method |
| Date | Sat, 7 May 2011 07:39:50 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 56 |
| Message-ID | <2a021cce7c48eff89cbddcf07e321fbb@ruby-forum.com> (permalink) |
| References | <14fe31c992d1702a259c05ab9ba0b550@ruby-forum.com> |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1304772005 56835 65.111.164.187 (7 May 2011 12:40:05 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Sat, 7 May 2011 12:40:05 +0000 (UTC) |
| In-Reply-To | <14fe31c992d1702a259c05ab9ba0b550@ruby-forum.com> |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 382774 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <2a021cce7c48eff89cbddcf07e321fbb@ruby-forum.com> |
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.dougwise.org!feed.ac-versailles.fr!talisker.lacave.net!lacave.net!not-for-mail |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:4064 |
Show key headers only | View raw
hi Silkmoth,
i use gtk2 quite a bit, and have found that the "Gnome 2" section of
this forum (under "Misc" on the top right,) is extremely helpful - and
is probably a better place to post questions about gtk2.
in answer to your question - you could try something like this, which
will give you the filename of the file within the event box you click
on. i've used images in my example rather than icons, but you should
get the idea....
######
require 'gtk2'
win = Gtk::Window.new()
@table = Gtk::Table.new(0, 0, false)
@left = -1
@top = 0
img0 = Gtk::Image.new("konichiwa.jpeg") #change these, obviously
img1 = Gtk::Image.new("ride.png")
img2 = Gtk::Image.new("TradyBlix.png")
img3 = Gtk::Image.new("arm.png")
my_imgs = [img0, img1, img2, img3]
my_imgs.collect{|img|
ebox = Gtk::EventBox.new()
ebox.add(img)
ebox.signal_connect("button_press_event"){p img.file} #or something
more interesting
@left = @left + 1
@top = @top + 1 if @left == 2 #change this,
@left = 0 if @left == 2 #and this, to define the number of columns in
your table
@right = @left + 1
@bottom = @top + 1
@table.resize(@right, @bottom)
@table.attach_defaults(ebox, @left, @right, @top, @bottom)
}
win.add @table
win.show_all
win.signal_connect("destroy"){Gtk.main_quit}
Gtk.main
##############
...
-j
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar | Unroll thread
Ruby Gtk2 and signal_connect method Silkmoth Silkmoth <phasme@gmx.fr> - 2011-05-06 14:09 -0500 Re: Ruby Gtk2 and signal_connect method jake kaiden <jakekaiden@yahoo.com> - 2011-05-07 07:39 -0500
csiph-web