# GTK ListBox?

**URL:** <https://www.ruby-forum.com/t/gtk-listbox/115967>\
**Category:** Ruby\
**Created:** [October 1, 2007, 2:56am UTC](https://www.ruby-forum.com/t/gtk-listbox/115967 "2007-10-01T02:56:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarazed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed8c4c/32.png) [@tarazed](https://www.ruby-forum.com/u/tarazed)\
**Post date:** [October 1, 2007, 2:56am UTC](https://www.ruby-forum.com/t/gtk-listbox/115967/1 "2007-10-01T02:56:35Z")

</div>

Greetings Ruby gurus

I have recently started using ruby (cool!) and have written a couple of  
simple programs with Ruby/Tk interfaces. They work fine but I have been  
unable to access Tk without using a barrow load of global variables,  
which  
goes against the grain. Ruby/GTK allows encapsulation of the gui within  
a  
class which is what I want but I am having difficulties with gtk2, also  
a  
new area for me. There does not seem to be a ListBox widget,  
specifically a  
scrolling listbox. This is a fundamental type of widget I would have  
thought; it is not mentioned in any of the documentation that is  
available  
from standard sources and using strings and grep on gtk2.so returns  
nothing for listbox. Googling does not return anything useful except to  
indicate that most other gui toolkits have something of the kind. I do  
not know enough about ruby or GTK to attempt coding a listbox myself so  
does anybody know where in the ruby domain such a thing may be found?

Apologies for the fact that this is not a coding question. If I cannot  
find a listbox implementation I shall have to abandon GTK, which I  
prefer  
because I work under GNOME. wxWidgets installed but resisted all  
attempts  
to run it.

---

<div class="post-metadata">

**Author:** ![tarazed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed8c4c/32.png) [@tarazed](https://www.ruby-forum.com/u/tarazed)\
**Post date:** [October 1, 2007, 7:22am UTC](https://www.ruby-forum.com/t/gtk-listbox/115967/2 "2007-10-01T07:22:11Z")

</div>

Len L. wrote:

> … I am having difficulties with gtk2, also a  
> new area for me. There does not seem to be a ListBox widget

Nearly everything about Gtk is hard - debugging esp - but…

For a simple list or table you use TreeView with a ListStore.

If you’re looking for a non-editable equivalent to Windows’  
ComboBox, consider using an OptionMenu. That’s the X equivalent,  
which is where Gtk takes its inspiration. Or construct a  
composite widget using a text box, an arrow button, and a  
drop-down containing a scrolling TreeView (whew).

Clifford H…

---

<div class="post-metadata">

**Author:** ![tarazed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed8c4c/32.png) [@tarazed](https://www.ruby-forum.com/u/tarazed)\
**Post date:** [October 1, 2007, 8:55am UTC](https://www.ruby-forum.com/t/gtk-listbox/115967/3 "2007-10-01T08:55:55Z")

</div>

On Mon, 01 Oct 2007 15:18:26 +1000, Clifford H. wrote:

> ----- snip ------  
> For a simple list or table you use TreeView with a ListStore.
> 
> If you’re looking for a non-editable equivalent to Windows’  
> ComboBox, consider using an OptionMenu. That’s the X equivalent,  
> which is where Gtk takes its inspiration. Or construct a  
> composite widget using a text box, an arrow button, and a  
> drop-down containing a scrolling TreeView (whew).

Yes, I noted TreeView and ListStore but that seemed too complicated for  
such a basic operation as list and select (optional). Thanks for the  
suggestion.

I suspect that it will have to be Tk in the end - 15 years of  
experience.  
Just need to figure out why encapsulation does not work. Examples from  
documentation (Pickaxe?) do not work as published.

Len

---

<div class="post-metadata">

**Author:** ![tarazed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed8c4c/32.png) [@tarazed](https://www.ruby-forum.com/u/tarazed)\
**Post date:** [October 1, 2007, 9:50pm UTC](https://www.ruby-forum.com/t/gtk-listbox/115967/4 "2007-10-01T21:50:20Z")

</div>

On Mon, 01 Oct 2007 06:52:11 +0000, Len L. wrote:

> > ----- snipped again ------

Apologies for answering my own post. Had another go with wxWidgets.  
Installed the ruby gem and copied the installed files to the site\_ruby  
directory. All is well - and wxRuby has a listbox. This might help  
somebody as green as me.

Len
