Op 11-03-13 15:49, Neil Muller schreef:
On 11 March 2013 00:37, Timo <timomli...@gmail.com> wrote:
I seem to be unable to change the cursor on one widget only, not an entire
window. How is this done? Below is a testscript which I thought was the
right way.
Run normal to use PyGI, run with -p argument for PyGTK. Both act the same.
def run_pygtk():
import gtk
def disable_cb(widget):
widget.set_sensitive(False)
cursor = gtk.gdk.Cursor(gtk.gdk.WATCH)
widget.window.set_cursor(cursor)
This works for widgets which have their own gtk.gdkWindows. It's
mentioned in the gtk docs that this isn't always the case, and several
widgets will return their parent's gtk.gdk.Window. You can check for
this using the get_has_window method.
Thanks for that. I did read that part, but foolishly assumed it were
just those few mentioned widgets which don't have a GdkWindow. In my
real life application, I have stuff packed into a frame=>alignment=>box
and neither of those have a GdkWindow.
The get_has_window method comes in handy!
Cheers,
Timo
One approach is to stuff the buttons inside an EventBox, since that
will definitely provide it's own gtk.gdk.Window - something along the
lines of:
def run_pygtk():
import gtk
def disable_cb(widget, eventbox):
widget.set_sensitive(False)
cursor = gtk.gdk.Cursor(gtk.gdk.WATCH)
eventbox.window.set_cursor(cursor)
win = gtk.Window()
win.resize(400, 400)
win.set_title("PyGTK example")
win.connect('delete-event', gtk.main_quit)
eventbox = gtk.EventBox()
b1 = gtk.Button('Disable me')
b1.connect('clicked', disable_cb, eventbox)
eventbox.add(b1)
b2 = gtk.Button('I do nothing')
box = gtk.VBox()
box.pack_start(eventbox, False, False, 0)
box.pack_start(b2, False, False, 0)
win.add(box)
win.show_all()
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/