VR::TreeView

I am playing with the ListView example and trying to turn it into a
VR::TreeView. I am unable to figure out how to add items.

in the listviewobject example rows are added
row = add_row()
row[:join] = VR::CalendarCol.new DateTime.new(1987, 5, 11, 6, 43, 0)
row[:name] = DataObject.new(“Billy Vincent”, …
row[:quote] = VR::TextCol.new “There are two ways …”

The doc says to use add_row(nil, Hash) to add a row in a TreeView.
If I try this I get
ViewCommon.rb:132:in method_missing': undefined local variable or methodargs’ for #<ListViewObjectsGUI:04EE4FA8 ptr=02DFA160>
(NameError)

What am I missing on using a Vr::TreeView?

Thanks,

I think you can just use the normal #append() method:

child = @treeview.append(parent)
child[0] = “Hello”
child[2] = “World”

Eric

Hi:

You’re right that it doesn’t work the same as the ListView. I’ve fixed
it so the treeview’s #add_row method works exactly like the ListView’s
with the exception that you must pass the parent iter argument.

I’ve updated the program. I will push it to rubygems.org later today.

Also, I’ve written a treeview demo program. It will be in:

home/visualruby/visualruby_examples/treeview

I’ve done lots of work on the program in the last few days.

Will you test it for me?

Thanks,
Eric

home/visualruby/visualruby_examples/treeview

I’d happy to try it out…

Thanks for your patience…I can get it to work … sort of…

In the ListView Example (converted to TreeView),
I can use GTK code to add a row to the tree
parent = self.model.append(nil)
parent[0] = VR::CalendarCol.new DateTime.new(2000, 1, 15, 7, 23, 0)
parent[1] = DataObject.new(“Bob Johnson”, “18458 S Beauford St.”, …
parent[2] = VR::TextCol.new “Does this Work?\n\n- Umberto Eco”

If I copy the add_row method into the Example Code and change hash to
*args I can also get it to work:
def add_row(parent, *args) <-hash changed to *args
child = model.append(parent)
(0…args.size-1).each { |i| child[i] = args[i] }
return child
end

parent = add_row(nil)
parent[0] = VR::CalendarCol.new DateTime.new(2000, 1, 15, 7, 23, 0)
parent[1] = DataObject.new(“Bob Johnson”, “18458 S Beauford St.” …
parent[2] = VR::TextCol.new “Does this Work?\n\n- Umberto Eco”

otherwise I get the error that args doesn’t exist…
ViewCommon.rb:132:in method_missing': undefined local variable or methodargs’ for #<ListViewObjectsGUI:04EE4FA8 ptr=02DFA160>
(NameError)

I am fine with using the Gtk::TreeView append, I was just trying to
understand what a “pure” VR::TreeView would look like.
Thanks,
Greg

I get an error on the gem install(file ‘lib’ not found) But that is
probably related to rdoc, and may have been there before.

When I run VR though I get an error:Failed to open file
‘./glade/VR_Main.glade’: No such file or
directory

– Warning with vrlib-0.0.33
–C:\Users\ghh\visualruby>vr
–C:/Ruby193/lib/ruby/gems/1.9.1/gems/vrlib-0.0.33/lib/GladeGUI.rb: line
–127
– Gtk-WARNING **:Unknown property: GtkMenu.ubuntu-local

C:\Users\ghh\visualruby>
C:\Users\ghh\visualruby>gem install visualruby
Fetching: vrlib-1.0.12.gem (100%)
Fetching: visualruby-1.0.12.gem (100%)
Successfully installed vrlib-1.0.12
Successfully installed visualruby-1.0.12
2 gems installed
Installing ri documentation for vrlib-1.0.12…
Installing ri documentation for visualruby-1.0.12…
file ‘lib’ not found
Installing RDoc documentation for vrlib-1.0.12…
Installing RDoc documentation for visualruby-1.0.12…
file ‘lib’ not found

C:\Users\ghh\visualruby>vr
C:/Ruby193/lib/ruby/gems/1.9.1/gems/vrlib-1.0.12/lib/GladeGUI.rb:154:in
add_fro m_file': Failed to open file './glade/VR_Main.glade': No such file or directory (GLib::FileError) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/vrlib-1.0.12/lib/GladeGUI.rb:15 4:inload_glade’
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/vrlib-1.0.12/lib/GladeGUI.rb:37
7:in show' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/visualruby-1.0.12/vr:38:in<to
p (required)>’
from C:/Ruby193/bin/vr:23:in load' from C:/Ruby193/bin/vr:23:in

C:\Users\ghh\visualruby>gem list

*** LOCAL GEMS ***


atk (2.0.2 x86-mingw32)
bigdecimal (1.1.0)
glib2 (2.0.2 x86-mingw32)
gtk2 (2.0.2 x86-mingw32)
gtksourceview2 (2.0.2 x86-mingw32)

visualruby (1.0.12, 0.1.2)
vrlib (1.0.12, 0.0.33)

It’s available now. Do this:

$gem install visualruby

You should get vr v1.0.7 or later and vrlib v1.0.4 or later.

I tried the TreeView example, and It worked just fine.

Thanks for all the work.

Greg

Hi Greg:

Thanks for finding that issue with the treeview. I had overlooked
updating that code. Please let me know anything else you find. I may
be short on time soon, but I will try to help.

Eric

Hi Greg:

Those warnings aren’t a problem. I got the lib warning before, I think
it was related to rdoc. The ubuntu-local can be ignored.

Glade spits out a big mess of warnings too.

E

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs