From: "Joel F." Date: 2011-02-16T05:54:38+09:00 Subject: Re: program to rename files : improvements What up Gio, In your post subject you should mention that you're using Gtk so that someone with Gtk experience will be likely to respond. I've never used it so I can't help you with your problem (1) However, as for changing your code... If you follow this link the first method you see might be helpful: http://www.ruby-doc.org/core/classes/Object.html#M001029 Let's consider this code segment from your app: @chkBtnReplace1 = CheckButton.new("Replace") layout.put(@chkBtnReplace1, 20, 80) @chkBtnReplace1.signal_connect("clicked") do |w| on_clicked(w) end @chkBtnReplace2 = CheckButton.new("Replace") layout.put(@chkBtnReplace2, 20, 120) @chkBtnReplace2.signal_connect("clicked") do |w| on_clicked(w) end ... If I wanted to get bonus crazy ruby points, I might do something like this instead: (1..4).each do |i| buttonName = "@chkBtnReplace" + i self.instance_variable_set(buttonName, CheckButton.new("Replace")) button = self.instance_variable_get(buttonName) layout.put(button, 20, 40 + i*40) button.signal_connect("clicked" do |w| on_clicked(w) end end The Object class in Ruby is pretty cool and is worth reading through. I'm not very experienced but it looks like "instance_variable_set" returns the object that it sets, so you might be able to shorten the instance variable stuff to: button = self.instance_variable_set(buttonName, CheckButton.new("Replace")) <3 joel -- Posted via http://www.ruby-forum.com/.