SpinButton always set to 0

In a ColumnViewColumn bind callback:

LIMITS = {
    U8Event: (0, 255),
    I8Event: (-128, 127),
    U16Event: (0, 65535),
    I16Event: (-32768, 32767),
    U32Event: (0, 4294967295),
    I32Event: (-2147483648, 2147483647),
    F32Event: (3.4e-38, 3.4e38),
}
...
elif isinstance(value, (int, float)):
            widget = Gtk.SpinButton(value=value, css_classes=["compact"])
            for type_, limits in LIMITS.items():
                if isinstance(event, type_):
                    widget.props.adjustment = Gtk.Adjustment(lower=limits[0], upper=limits[1])
...

When my ColumnViewgets populated, all the SpinButtons are set to 0 and the + / - buttons don’t work either. Interestingly, this doesn’t happen if I use a different widget like Text or Entry.

You should probably show the entire code that demonstrates the problem, not an ellipsised version - and if it works in other scenarios, show those so their differences can be analysed. Anyway, my guess is your isinstance() checks fail and you don’t set the adjustment. Some diagnostic printing of the results of your checks could help.

I have verified that the isinstance indeed works. I also set the adjustment for most of the spin buttons (yet all of them get stuck on 0). I haven’t checked if it works in other scenarios, although why wouldn’t it? Am I missing to bind some signal which causes this behavior?

You may need to set the :step-increment property of the SpinButton’s Adjustment. That defaults to 0, in which case the buttons do nothing (no step).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.