Forum: Ruby-Gnome 2 pop up window

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F239909dcf959a8adb236b056329fc8a?d=identicon&s=25 Ben N. (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?
9d2d160377d47a2144b12d36ab63126f?d=identicon&s=25 Regis d. (raubarede)
on 2013-01-17 22:20
> gem install Ruiby

> ruiby button(~Hello Mr Nussbaum~) do exit!(0) end
9d2d160377d47a2144b12d36ab63126f?d=identicon&s=25 Regis d. (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,
F239909dcf959a8adb236b056329fc8a?d=identicon&s=25 Ben N. (bennuss)
on 2013-01-18 02:24
do you know how to do it in visual ruby?
C37e335e7250698ebcc8a092a4baded3?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
F239909dcf959a8adb236b056329fc8a?d=identicon&s=25 Ben N. (bennuss)
on 2013-01-22 17:06
okay thank you very much! what is the difference in (*argv) and (*args)?
C37e335e7250698ebcc8a092a4baded3?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.
This topic is locked and can not be replied to.