Re: Destroying spin button on value change



Thanks to Paul, Havoc, and Joseph for their kind suggestions.

Alas...

PyGTK  does not wrap the ref or unref functions, but (reasonably)
manages
references as python objects referring to gtk objects are created and
destroyed.  (I think.  This is based on reading the mailing list and
observing behavior of my apps, not reading source.)  So adding a
reference is
doable and I have tried do it at several points in the handling process,
to
no avail.  I think the problem is that you either have so many
references and
no place to remove the last one after real_spin has run or not enough so

removing the last destroys the spin button between the adjustment signal

handler (where my code runs) and real_spin (in the gtk lib).

Idle add doesn't work either.   I insert the idle function in the
handler for
adjustment value changed, it still is run before real_spin.  I've tried
a
idle_add_priority with a ridiculously low priority, but still no joy.

As far as why I want to do such a crazy thing.  I'm trying to write a
character generator for a role-playing game.  I need a way to display a
list
of the character's skills, each with an adjustable skill value.  Since
having
a zero in a skill is the same as not having the skill at all, it is
logical
that reducing the skill to zero might remove the skill.  The UI I
considered
first allowed was to allow the user to select skills and press a button
to
delete it.  Unfortunately I couldn't come up with an easy and attractive
and
style/theme agnostic way to indicate that a horizontal row containing a
label
and  spin button was selected without writing a new widget.  If anyone
has a
suggestion on how to do this, I'd love to consider it.

I understand that wanting to delete a spin button from within it's own
handler is unconcentional a in many ways a Bad Idea (tm).  But it also
seems
to me to be little difference between this logically and clicking a
button
that destroys its parent dialog.  I humbly suggest perhaps sandwiching
the
code in each each of the event handlers in gtkspinbutton.c between an
gtk_ref(self) and gtk_unref(self) might be an Ok Idea, but I'm not
positive
it would help my situation and certainly don't know what other
reprecussions
it might have.  Still, FWIW.

Thanks for the once and future help.

Jay







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