Need ComboBoxEntry example

(mjb) #1

I'm having problems getting the list to show in the popup.

I've spent considerable time trying to track down an example
at the RAA, but have been unsuccessful. A ComboBox example
should work just as well for what I need.

If you have an example of either of the above, or link to
same, I'd sure appreciate it.

Thank you.

(daz) #2

mjb wrote:

I'm having problems getting the list to show in the popup.

I've spent considerable time trying to track down an example
at the RAA, but have been unsuccessful. A ComboBox example
should work just as well for what I need.

If you have an example of either of the above, or link to
same, I'd sure appreciate it.

Thank you.

Not an example, but the documentation looks pretty good.

http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3AComboBoxEntry

daz

···

--

      (You've been watching: "Guess that Toolkit" :wink:

(mjb) #3

daz wrote:

mjb wrote:

I'm having problems getting the list to show in the popup.

I've spent considerable time trying to track down an example
at the RAA, but have been unsuccessful. A ComboBox example
should work just as well for what I need.

If you have an example of either of the above, or link to
same, I'd sure appreciate it.

Thank you.

Not an example, but the documentation looks pretty good.

http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3AComboBoxEntry

daz

God, I wish. I've spent days with those docs, with no joy.

The comboboxentry displays. I can put default text in the entry box.
The popup drops down, but it has no text.

I'm not sure if I need CellRenderer or a TreeView, or what?

Here's what I've got, though it probably has a "kitchen sink" look
about it as I'm trying everything at this point:

   def set_account_list

      # set the comboentrybox "child", the entrybox text area, to...
      @account_comboentry_box.child.set_text("hi")

      @account_comboentry_box.set_text_column(0)

      # a ListStore is a type of model (of the data)
      # _this_ model has 1 column of type String
      @account_list_store_model = ListStore.new(String)

      # create a row in the model, if number is higher than the current
number of rows,
      # data is appended to the list
      @new_row_iter = @account_list_store_model.insert(80)

# new_row_iter.set_value(1, 'Apple')
      @account_list_store_model.set_value(@new_row_iter, 0, 'Apple')

      # view on the model
      @account_comboentry_box_model_view = TreeView.new(model =
@account_list_store_model)

      # guessing here
# @account_comboentry_box.set_view(@account_comboentry_box_model_view)

   end

Still looking for some example code.

Thanks

(Masao Mutoh) #4

Hi,

···

On Wed, 17 Aug 2005 03:11:14 +0900 mjb <kb6mjb@excite.com> wrote:

daz wrote:
> mjb wrote:
>
>
>>I'm having problems getting the list to show in the popup.
>>
>>I've spent considerable time trying to track down an example
>>at the RAA, but have been unsuccessful. A ComboBox example
>>should work just as well for what I need.
>>
>>If you have an example of either of the above, or link to
>>same, I'd sure appreciate it.
>>
>>Thank you.
>
>
>
> Not an example, but the documentation looks pretty good.
>
> http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3AComboBoxEntry
>
>
> daz

God, I wish. I've spent days with those docs, with no joy.

The comboboxentry displays. I can put default text in the entry box.
The popup drops down, but it has no text.

I'm not sure if I need CellRenderer or a TreeView, or what?

Still looking for some example code.

Did you try ruby-gnome2/gtk/sample/misc/combobox.rb in tar-ball ?

--
.:% Masao Mutoh<mutoh@highway.ne.jp>

(mjb) #5

Masao Mutoh wrote:

Hi,

daz wrote:

mjb wrote:

I'm having problems getting the list to show in the popup.

I've spent considerable time trying to track down an example
at the RAA, but have been unsuccessful. A ComboBox example
should work just as well for what I need.

If you have an example of either of the above, or link to
same, I'd sure appreciate it.

Thank you.

Not an example, but the documentation looks pretty good.

http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3AComboBoxEntry

daz

God, I wish. I've spent days with those docs, with no joy.

The comboboxentry displays. I can put default text in the entry box.
The popup drops down, but it has no text.

I'm not sure if I need CellRenderer or a TreeView, or what?

Still looking for some example code.

Did you try ruby-gnome2/gtk/sample/misc/combobox.rb in tar-ball ?

Probably not, I had my mental '*.rb' filter on, though, that title
would have got my attention, at least later, and I would've gone for
a tarball, for sure at that point.

One thing though...

that url can't be found. I tried a couple of derivatives of it, but
still, no go. Also, thought you might mean as part of the install, but
I don't see it there either.

Can you double check that url?

Thank you

···

On Wed, 17 Aug 2005 03:11:14 +0900 > mjb <kb6mjb@excite.com> wrote:

(daz) #6

mjb wrote:

Masao Mutoh wrote:
>
> Did you try ruby-gnome2/gtk/sample/misc/combobox.rb in tar-ball ?
>
[...]
that url can't be found. I tried a couple of derivatives of it, but
still, no go. Also, thought you might mean as part of the install, but
I don't see it there either.

Can you double check that url?

The author refers to the path within the tar-ball and it's correct.
This is the example:

#!/usr/bin/env ruby
=begin
  combobox.rb - Ruby/GTK sample script.

  Copyright (c) 2004 Ruby-GNOME2 Project Team
  This program is licenced under the same licence as Ruby-GNOME2.

  $Id: combobox.rb,v 1.2 2004/06/07 16:09:31 mutoh Exp $
=end

require 'gtk2'

Gtk.init

if str = Gtk.check_version(2, 4, 0)
  puts "This sample requires GTK+ 2.4.0 or later"
  puts str
  exit
end

window = Gtk::Window.new

···

#
# Text only
#
combo1 = Gtk::ComboBox.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]}"
end

#
# Icon and text
#
model = Gtk::ListStore.new(Gdk::Pixbuf, String)
[[Gtk::Stock::QUIT, "quit"],
[Gtk::Stock::CANCEL, "cancel"],
[Gtk::Stock::OK, "ok"]].each do |stock, name|
  iter = model.append
  iter[0] = window.render_icon(stock, Gtk::IconSize::MENU, "icon")
  iter[1] = name
end

combo2 = Gtk::ComboBox.new(model)

# column 1
renderer = Gtk::CellRendererPixbuf.new
combo2.pack_start(renderer, false)
combo2.set_attributes(renderer, :pixbuf => 0)

# column 2
renderer = Gtk::CellRendererText.new
combo2.pack_start(renderer, true)
combo2.set_attributes(renderer, :text => 1)

combo2.active = 2

combo2.signal_connect("changed") do
  p "combo2: #{combo2.active}, #{combo2.active_iter[1]}"
end

#
# Gtk::ComboBoxEntry
#
combo3 = Gtk::ComboBoxEntry.new
["foo", "bar", "fuga", "hoge"].each do |val|
  combo3.append_text(val)
end
combo3.active = 1

combo3.signal_connect("changed") do
  if combo3.active_iter
    p "combo3: #{combo3.active}, #{combo3.active_iter[0]}"
  end
end

# Show main window
vbox = Gtk::VBox.new
vbox.add(combo1).add(combo2).add(combo3)
window.add(vbox).show_all

Gtk.main

(mjb) #7

daz wrote:

mjb wrote:

Masao Mutoh wrote:

Did you try ruby-gnome2/gtk/sample/misc/combobox.rb in tar-ball ?

[...]
that url can't be found. I tried a couple of derivatives of it, but
still, no go. Also, thought you might mean as part of the install, but
I don't see it there either.

Can you double check that url?

The author refers to the path within the tar-ball and it's correct.

daz:

Thanks for taking the time and making the effort to help out.

I appreciate it.

mjb