CellRendererSpin - how to use?

Hello

I tried writing a small Hello World style application with ruby-gtk2.

After I was told that ‘list’ and ‘table’ are both spelled ‘treeview’
in GTK I was able to put together a small demo that actually allows
editing a list of text strings.

Howeveer, I cannot make the SpinButton cell renderer to display, and
there is no GTK warning or anything that would indicate there is
something wrong.

Is there some demo showing the less common cell renderers? I was
looking at the gtk-demo but it uses CellRendererText for numbers.

Thanks

Michal

Michal S. wrote:

Hello

I tried writing a small Hello World style application with ruby-gtk2.

After I was told that ‘list’ and ‘table’ are both spelled ‘treeview’
in GTK I was able to put together a small demo that actually allows
editing a list of text strings.

Howeveer, I cannot make the SpinButton cell renderer to display, and
there is no GTK warning or anything that would indicate there is
something wrong.

Is there some demo showing the less common cell renderers? I was
looking at the gtk-demo but it uses CellRendererText for numbers.

Thanks

Michal

Take a look at:

282. How to input or edit numbers in GtkTreeView with GtkCellRendererSpin? | Sample Codes

HTH,
Roy

On 23/01/2009, Roy W. [email protected] wrote:

there is no GTK warning or anything that would indicate there is
Take a look at:

282. How to input or edit numbers in GtkTreeView with GtkCellRendererSpin? | Sample Codes

Thanks for the sample. It seems they set the value property from the
model rather than the adjustment property. Although the docs seem to
indicate that either should be possible maybe it is not.

I will try a few modifications of my hello world and see how it goes.

Thanks

Michal

On 26/02/2009, Michal S. [email protected] wrote:

somewhere, and I am not aware of ever doing that.

In fact I can type an exact value and my handler sets it into the
model (I wish there was a default handler doing just that) but
whenever the value is loaded into the spinbutton it is rounded.

It’s because the renderer displays the value differently when inactive
and while editing. It can be seen by uncommenting the part with
set_digits()

The value is a plain label normally with many decimal places but the
spinbutton only has as many decimal digits as set with the digits
property thus the value is rounded when loaded into the spinbutton.

The odd things that happen here are two:

  • the renderer sets digits on the spinbutton but does not heed the
    property for the label
  • the spinbutton rounds the value when set but allows entering exact
    value manually

Thanks

Michal

Hello

On 23/01/2009, Roy W. [email protected] wrote:

Take a look at:

282. How to input or edit numbers in GtkTreeView with GtkCellRendererSpin? | Sample Codes

Thanks for this sample.

It shows clearly that the cell renderers have an undocumented property
text which also gets propagated as the value of the
GtkCellRendererSpin adjustment.

However, there is a bug somewhere that prevents me from incrementing
the spinbutton value in non-integer steps. The value gets rounded
somewhere, and I am not aware of ever doing that.

In fact I can type an exact value and my handler sets it into the
model (I wish there was a default handler doing just that) but
whenever the value is loaded into the spinbutton it is rounded.

Attaching the test program, hopefully file this time.

Thanks

Michal