# Problem clearing elements from Gtk::ComboBox

**URL:** <https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881>\
**Category:** Ruby-Gnome 2\
**Created:** [September 25, 2006, 8:59am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881 "2006-09-25T08:59:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaVinci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@DaVinci](https://www.ruby-forum.com/u/DaVinci)\
**Post date:** [September 25, 2006, 8:59am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881/1 "2006-09-25T08:59:33Z")

</div>

Hi everybody.

I have a little problem with version 0.15 of Ruby-Gtk2. Look at this  
class:

* * *

class BotonOpciones \< Gtk::ComboBox  
def initialize(valores=nil, inicial=nil)  
super()  
aniadir\_opciones(valores, inicial) if valores  
end

```
# Esta función está separada para que se puedan cambiar las
# opciones todas las veces que sea necesario.
    def aniadir_opciones(valores,
	inicial=nil)

	model.clear	# HERE IS THE PROBLEM!!!!!!
            @valores = valores
            @valores.each do |v|
		append_text(v)
	end
	if inicial
		poner_valor(inicial)
	end
end

```

## end

When I try “model.clear”, get the error:

```
`aniadir_opciones': undefined method `clear' for
#<#<Class:0xb6750eac>:0xb66c6f90 ptr=0x85c6790> (NoMethodError)

```

It worked until 0.14 version, and API documentation doesn’t show any  
deprecation or change.

Is this a known problem? Perhaps a bug?

Thank you.

```
						David

```

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![DaVinci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@DaVinci](https://www.ruby-forum.com/u/DaVinci)\
**Post date:** [September 25, 2006, 9:17am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881/2 "2006-09-25T09:17:35Z")

</div>

have you tried having a set\_model(Gtk::ListStore) after your super() ?  
try ‘p model.inspect’ or ‘p model.methods’ before your model.clear, to  
see, if there’s a model assigned.

---

<div class="post-metadata">

**Author:** ![DaVinci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@DaVinci](https://www.ruby-forum.com/u/DaVinci)\
**Post date:** [September 25, 2006, 9:29am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881/3 "2006-09-25T09:29:36Z")

</div>

El lunes 25 de septiembre, Dobai-Pataky B.  
escribió:\> have you tried having a set\_model(Gtk::ListStore) after your super() ?

If I do that, get:

```
(eval):2:in `set_property': Class isn't supported (TypeError)

```

> try ‘p model.inspect’ or ‘p model.methods’ before your model.clear, to  
> see, if there’s a model assigned.

I think there isn’t. This is result from inspect:

```
"#<#<Class:0xb681ce58>:0xb6794058 ptr=0x85c5790>"

							David

```

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![DaVinci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@DaVinci](https://www.ruby-forum.com/u/DaVinci)\
**Post date:** [September 25, 2006, 9:45am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881/4 "2006-09-25T09:45:37Z")

</div>

El lunes 25 de septiembre, Dobai-Pataky B.  
escribió:\> set\_model(@mymodel)  
Ops! I wanted going too fast 0:)

Thank you for your ideas. Only a last question. If I destroy  
Gtk.ComboBox, is respective Gtk.ListStore destroyed?

```
							David

```

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![DaVinci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@DaVinci](https://www.ruby-forum.com/u/DaVinci)\
**Post date:** [September 25, 2006, 9:33am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881/5 "2006-09-25T09:33:36Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![DaVinci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@DaVinci](https://www.ruby-forum.com/u/DaVinci)\
**Post date:** [September 25, 2006, 9:49am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881/6 "2006-09-25T09:49:37Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![DaVinci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@DaVinci](https://www.ruby-forum.com/u/DaVinci)\
**Post date:** [September 25, 2006, 9:51am UTC](https://www.ruby-forum.com/t/problem-clearing-elements-from-gtk-combobox/69881/7 "2006-09-25T09:51:37Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
