Forum: Ruby-Gnome 2 pop up window

5ea18917ae49c4865704ca5f61913834?d=identicon&s=25 Ben Nussbaum (bennuss)
on 2013-01-14 18:35
Im trying to make something that when you first open the program it asks
you which one you want to choose. Then you once you click on the button
it opens up that program. how do i do this?
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2013-01-17 22:20
> gem install Ruiby

> ruiby button(~Hello Mr Nussbaum~) do exit!(0) end
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2013-01-17 22:57
(...continue)

> ruiby -width 300 -height 200 \
>  "l=list(~File~); l.set_data(Dir.glob ~*.*~); \
>   buttoni('Validation') {puts l.selection;exit!(0)} "


Or for startup un ruby script :

require 'Ruiby'

def script(choice="?")
 p choice
end

Ruiby.app(:width=> 300, :height=>200, :title=> "Hello") do stack do
  l=list("Files...")
  l.set_data(Dir.glob "*.*")
  buttoni('Validation') {  script(l.selection) ; exit!(0)}
end end

For the last one, You can do that with (green) shoes too

Regards,
5ea18917ae49c4865704ca5f61913834?d=identicon&s=25 Ben Nussbaum (bennuss)
on 2013-01-18 02:24
do you know how to do it in visual ruby?
0d130f179f85401f248e6ebc2ef8292f?d=identicon&s=25 Eric C. (eric_c)
on 2013-01-19 21:40
Hi:

I would encourage you to watch the videos at:

http://visualruby.net

Also, you can read the tutorials.

The basic things you would need to do are:

1) create a new project.  This will create a "Hello World" app to start
with.

2)  Right click on the "MyClass.rb" file to edit the glade file.

3)  Delete the label that says "Hello World" and replace it with a vbox
with one cell.  Keep the name "vbox1"

4)  You code will look something like this:

def show()
  load_glade(__FILE__)
  @view = VR::ListView.new(:filename => String)
  Dir.glob("*").each do |fn|
    @view.add_row(fn)
  end
  @builder["vbox1"].add(@view)
  show_window()
end

If you add a button named "button1" you could write a handler:

def button1__clicked(*args)
  #open file here
end

Or you can use the selection method from the listview:

def view__row_activated(*args)
   #open file here
end

Again, read the tutorials and watch the videos.  It will be easy then.

Good luck,
Eric
5ea18917ae49c4865704ca5f61913834?d=identicon&s=25 Ben Nussbaum (bennuss)
on 2013-01-22 17:06
okay thank you very much! what is the difference in (*argv) and (*args)?
0d130f179f85401f248e6ebc2ef8292f?d=identicon&s=25 Eric C. (eric_c)
on 2013-01-27 07:37
*argv and *args are exactly the same.  They're just a variable name.
You could just as easily use *var1 or *x.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.