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.

# Start of code
def run_pygi():
    from gi.repository import Gtk
    from gi.repository import Gdk

    def disable_cb(widget):
        widget.set_sensitive(False)
        cursor = Gdk.Cursor(Gdk.CursorType.WATCH)
        widget.get_window().set_cursor(cursor)

    win = Gtk.Window()
    win.resize(400, 400)
    win.set_title("PyGI example")
    win.connect('delete-event', Gtk.main_quit)

    b1 = Gtk.Button('Disable me')
    b1.connect('clicked', disable_cb)
    b2 = Gtk.Button('I do nothing')
    box = Gtk.VBox()
    box.pack_start(b1, False, False, 0)
    box.pack_start(b2, False, False, 0)
    win.add(box)
    win.show_all()

    Gtk.main()

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)

    win = gtk.Window()
    win.resize(400, 400)
    win.set_title("PyGTK example")
    win.connect('delete-event', gtk.main_quit)

    b1 = gtk.Button('Disable me')
    b1.connect('clicked', disable_cb)
    b2 = gtk.Button('I do nothing')
    box = gtk.VBox()
    box.pack_start(b1, False, False, 0)
    box.pack_start(b2, False, False, 0)
    win.add(box)
    win.show_all()

    gtk.main()

import sys
if "-p" in sys.argv:
    run_pygtk()
else:
    run_pygi()
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to