Re: Notebook focus

On Wed, 2003-04-16 at 04:54, Philippe Camus wrote:
Okay, I can't make it work... I'm not experienced enough to program
complicated GUI! I wish users would be happy with command-line programs!

hehe, i know what you mean.

i suggest a different approach.

in my experience, walking the widget hierarchy to find a particular
widget turns out to be black magic that you later regret, as it makes it
painful for you to *change* that hierarchy later.  also, the code is not
robust against changes --- say there's a malicious theme engine that
embeds every widget in a sunken frame because they think it looks
better; now you're screwed.

when creating all the widgets in a notebook page, set up their
associations before moving on to create the next page.  for things that
must be associated outside a page, store the reference to that widget in
a distinct variable.

take advantage of perl's closures and lexicals to keep the scope sane
for your callbacks.  also keep in mind that in gtk-perl you can pass any
number of data items to a callback like

   $object->signal_connect (name => sub {}, LIST);

these sorts of tricks help you avoid the need to walk the tree.

hope that helps.

(i'd be more specific but i'd have to see your whole program to know
what it is that you're trying to do, rather than the specific code that
doesn't work.)

muppet <scott asofyet org>

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