# VR::TreeView

**URL:** <https://www.ruby-forum.com/t/vr-treeview/237992>\
**Category:** Ruby-Gnome 2\
**Created:** [December 10, 2013, 6:36pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992 "2013-12-10T18:36:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [December 10, 2013, 6:36pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/1 "2013-12-10T18:36:27Z")

</div>

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 method`args’ for #\<ListViewObjectsGUI:04EE4FA8 ptr=02DFA160\>  
(NameError)

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

Thanks,

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 10, 2013, 8:30pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/2 "2013-12-10T20:30:04Z")

</div>

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

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

Eric

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 10, 2013, 9:13pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/3 "2013-12-10T21:13:40Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 10, 2013, 9:24pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/4 "2013-12-10T21:24:45Z")

</div>

> home/visualruby/visualruby\_examples/treeview

I’d happy to try it out…

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 10, 2013, 9:17pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/5 "2013-12-10T21:17:35Z")

</div>

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 method`args’ 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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 11, 2013, 3:41pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/6 "2013-12-11T15:41:38Z")

</div>

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:in`load\_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)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 10, 2013, 10:28pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/7 "2013-12-10T22:28:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 12, 2013, 3:44pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/8 "2013-12-12T15:44:39Z")

</div>

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

Thanks for all the work.

Greg

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 12, 2013, 7:57pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/9 "2013-12-12T19:57:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 11, 2013, 9:13pm UTC](https://www.ruby-forum.com/t/vr-treeview/237992/10 "2013-12-11T21:13:00Z")

</div>

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
