On Fri, 18 Jul 2003 11:10:17 +0800
James Henstridge <[EMAIL PROTECTED]> threw this fish to the penguins:

> george young wrote:
> 
> >[gtk-2.2.2, pygtk-1.99.16, python-2.3b2]
> >
> >I want to briefly change my app's cursor to a 'watch' or some such while it's
> >thinking hard.  I have a zillion widgets, so it seems like changing cursor
> >for one of them is not likely to be right.  From the FAQ, entry 5.6:
> >
> >   http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq05.006.htp
> >
> >I found a reference to:
> >   http://www.daa.com.au/pipermail/pygtk/2000-October/000435.html
> >
> >wherein it's explained how to create an "input_only" window overlaying
> >my entire app and change that window's cursor.  Unfortunately, I can't get
> >this hack to work.  It calls for:
> >
> >   gtk.gdk_window_new(gdk_window, attribs)
> >
> >but I can't figure out how to get a new gdk window.  Here's the code 
> >[partially adjusted for gtk2]
> >
> >  gdk_window = my_gtkwindow.get_window()
> >  attribs = { 'wmclass': gtk.gdk.INPUT_ONLY,
> >              'window_type': gtk.gdk.WINDOW_CHILD,
> >              'event_mask': 0,
> >              'x': 0,
> >              'y': 0,
> >              'width': gtk.gdk.screen_width(),
> >              'height': gtk.gdk.screen_height() }
> >  cursor_win = gtk.gdk_window_new(gdk_window, attribs)  ??????
> >  gdk_cursor = gtk.cursor_new(get.gdk.WATCH)
> >  cursor_win.set_cursor(gdk_cursor)
> >  cursor_win._show()
> >
> >
> >Am I completely off base here?
> >  
> >
> Note that if a window doesn't have a cursor set on it, then it will 
> inherit its parent window's cursor (remember that almost every widget 
> has a window, not just the toplevel gtk.Window).
> 
> So if you set the cursor on your toplevel gtk.Window, all the child 
> widgets will inherit it too.

Thanks, that did the trick.  I did have to add a gtk.flush() for the new
cursor to appear right away.

I would like to suggest a change to the FAQ (5.6).  The get_window function
doesn't seem to work anymore (in 1.99.16), I had to use the "window" data
attribute.  And cursor_new becomes gdk.Cursor().  May I suggest:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
...
To change it for a button, 


 b = GtkButton()
 watch = gtk.Cursor(gtk.gdk.WATCH)
 gdkwin = b.window
 gdkwin.set_cursor(watch)
 
 #If your application goes directly to lengthy non-graphics activities,
 #you may need a "gtk.gdk.flush()" after the set_cursor.]

 And to change it back to normal:
...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
-- 
 I cannot think why the whole bed of the ocean is
 not one solid mass of oysters, so prolific they seem. Ah,
 I am wandering! Strange how the brain controls the brain!
        -- Sherlock Holmes in "The Dying Detective"
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to