PyGTK Hide Cursor

前端 未结 1 336
醉话见心
醉话见心 2021-01-21 16:50

The question is simple how can I hide the cursor on an active window using PyGTK???

Here\'s a basic app I made to learn this...

#!/usr/bin/env python

im         


        
相关标签:
1条回答
  • 2021-01-21 17:42

    As stated in the PyGTK FAQ, you should set the cursor on the realize signal. If you don't wait for the realize signal, the gtk.gdk.window hasn't been created yet, so you can't change the cursor.

    So, you can do something like:

    #!/usr/bin/env python
    
    import gtk
    
    class app:
    
      def __init__(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_title("TestApp")
        window.set_default_size(400,200)
        window.connect("realize", self.realize_cb)
        window.connect("destroy", gtk.main_quit)    
        window.show_all()
    
      def realize_cb(self, widget):
        pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
        color = gtk.gdk.Color()
        cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
        widget.window.set_cursor(cursor)
    
    app()
    gtk.main()
    
    0 讨论(0)
提交回复
热议问题