Re: GtkAdjustment and GtkSpinButton question



-- Matthew Weier OPhinney <matthew-lists weierophinney net> wrote
(on Wednesday, 13 August 2003, 07:56 PM -0400):
-- Ross McFarland <rwmcfa1 neces com> wrote
(on Wednesday, 13 August 2003, 12:36 PM -0400):
Matthew Weier OPhinney said:
I'm trying to create a GtkSpinButton, and having a slight problem.

i've got some code that uses a spin button as you are that seems to work. i
know this sounds stupid, but verify that the values you're passing in for
min/max/val are correct. failing that i guess i'd need some example code that
exhibits the problem to help any more.

Here's what I've got going. I'm pulling data from an XML file using
XML::DOM. To ensure that I'm getting integers to pass to
Gtk2::SpinButton's max and min values, I'm using something like:

    my $min = int($node->getAttribute('min'));
    my $max = int($node->getAttribute('max'));
    my $val = $option->{int_value}; # this is already an integer
    my $step = $node->getAttribute('step');

    ($step) ? $step = int($step) : $step = 1;

    my $spin = Gtk2:SpinButton->new_with_range($min, $max, $step);
    $spin->set_value($val);
      ^^^^^^^^^^^^^^^^^^^^^^^
What's most odd is that I've got the following setup:

    $spin->signal_connect(
        value-changed => sub { $self->check_widget($option) }
    );

The 'check_widget' method of this class checks to see if the 'revert'
button has been pressed, and, if so, calls:
    
    $spin->set_value($option->{int_value});

to set the value of the spin button, and this *works* -- i.e., the value
of the spin button gets set to the value that had been saved for that
option.

HOWEVER, calling the same code *BEFORE* the widget is displayed (and
with the same value) doesn't work. Odd. Any ideas, anyone?

-- 
Matthew Weier O'Phinney
http://weierophinney.net/matthew/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]