Forum: Ruby-Gnome 2 pop up window

Posted by 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?
Posted by Regis d'Aubarede (raubarede)
on 2013-01-17 22:20
> gem install Ruiby

> ruiby button(~Hello Mr Nussbaum~) do exit!(0) end
Posted by 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,
Posted by Ben Nussbaum (bennuss)
on 2013-01-18 02:24
do you know how to do it in visual ruby?
Posted by 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
Posted by Ben Nussbaum (bennuss)
on 2013-01-22 17:06
okay thank you very much! what is the difference in (*argv) and (*args)?
Posted by 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 (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.