Hello,
I am using GTK3 ruby 2.5. My problem I want do delete the list.
I already checked: remove_all, and combobox.model.clear
but nothing works.
How can I delete the Textlist.
Cheers
#!/usr/bin/env ruby
require "gtk3"
require "pry"
if str = Gtk.check_version(3, 10, 7)
puts "This sample requires GTK+ 3.10.7 or later"
puts str
exit
end
window = Gtk::Window.new("Gtk::ComboBox sample")
window.signal_connect("destroy") {Gtk.main_quit}
···
#
# Text only
#
combo1 = Gtk::ComboBoxText.new
["foo", "bar", "fuga", "hoge"].each do |val|
combo1.append_text(val)
end
combo1.active = 1
combo1.signal_connect("changed") do
p "combo1: #{combo1.active}, #{combo1.active_iter[0]}"
combo1.active = 1
end
# Show main window
vbox = Gtk::Box.new(:vertical)
vbox.add(combo1)
window.add(vbox).show_all
Gtk.main
Hi,
In <5d4b5cbc-7eaa-92e3-7a16-60b51afbeb4f@unitybox.de>
"GTK3 ruby comboboxtext: remove text items" on Sat, 27 Oct 2018 20:45:33 +0200,
···
ulli bei Unity <upahermann@unitybox.de> wrote:
I am using GTK3 ruby 2.5. My problem I want do delete the list.
I already checked: remove_all, and combobox.model.clear
but nothing works.
The following works for me:
----
#!/usr/bin/env ruby
require "gtk3"
if str = Gtk.check_version(3, 10, 7)
puts "This sample requires GTK+ 3.10.7 or later"
puts str
exit
end
window = Gtk::Window.new("Gtk::ComboBox sample")
window.signal_connect("destroy") {Gtk.main_quit}
#
# Text only
#
combo1 = Gtk::ComboBoxText.new
["foo", "bar", "fuga", "hoge"].each do |val|
combo1.append_text(val)
end
combo1.active = 1
combo1.signal_connect("changed") do
# p "combo1: #{combo1.active}, #{combo1.active_iter[0]}"
if combo1.model.iter_first
combo1.active = 1
end
end
combo1.model.clear
# Show main window
vbox = Gtk::Box.new(:vertical)
vbox.add(combo1)
window.add(vbox).show_all
Gtk.main
----
Thanks,
--
kou