David Bustos <[EMAIL PROTECTED]> writes:

> I'm trying to make a list that only appears while the pointer is over it
> and is hidden otherwise.  After playing with show(), hide(), and (un)map(),
> I'm currently trying GtkNotebook.  I've connected set_page methods to the
> {enter,leave}-notify-event signals of the notebook (see below), but when
> the clist page comes up, more enter/leave signals are emitted and the
> notebook flickers, even though I haven't enabled the
> {ENTER,LEAVE}_NOTIFY_MASK on the clist.
> 
> Now how can I prevent this, or is there a better approach?

You get notify-events not only for entering and leaving the notebook
window, but also for the child windows. So you want to switch pages
only when event.detail != NOTIFY_INFERIOR.

When the notebooks has tabs, there is one point (above the left tab in 
your example), where you get a NOTIFY_ANCESTOR and it starts looping
again, but excluding NOTIFY_ANCESTOR also doesn't give the behaviour
you want. I don't know what happens here.

If you don't need tabs for your notebook, switching on
NOTIFY_NONLINEAR (or != NOTIFY_INFERIOR) seems to work.

Btw., the definition of "notify detail" in X.h is

#define NotifyAncestor          0
#define NotifyVirtual           1
#define NotifyInferior          2
#define NotifyNonlinear         3
#define NotifyNonlinearVirtual  4
#define NotifyPointer           5
#define NotifyPointerRoot       6
#define NotifyDetailNone        7

while in GTK.py we have

NOTIFY_ANCESTOR          = 0
NOTIFY_VIRTUAL           = 1
NOTIFY_INFERIOR          = 2
NOTIFY_NONLINEAR         = 3
NOTIFY_NONLINEAR_VIRTUAL = 4
NOTIFY_UNKNOWN           = 5

Does anyone have an explanation for the difference?

> ---------------------------------------------------------------------------
> from gtk import *
> 
> w = GtkWindow()
> w.set_usize(100,200)
> w.connect('destroy', mainquit)
> 
> nb = GtkNotebook()
> nb.set_show_tabs(TRUE)
> nb.add_events(GDK.ENTER_NOTIFY_MASK | GDK.LEAVE_NOTIFY_MASK)
> w.add(nb)
> 
> nb.insert_page(GtkLabel('A page.'), GtkLabel('A tab'), 0)
> 
> clist = GtkCList(2, ('Stuff', ''))
> for i in range(5): clist.append(('item', `i`))
> nb.insert_page(clist, GtkLabel('Another tab'), 1)
> 
> nb.connect('enter-notify-event', lambda nb,event: nb.set_page(1))
> nb.connect('leave-notify-event', lambda nb,event: nb.set_page(0))
> 
> w.show_all()
> mainloop()
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to