PyGTK隐藏光标
问题很简单,如何使用 PyGTK 隐藏活动窗口上的光标???
这是我为了学习这个而制作的一个基本应用程序......
#!/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)
pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
color = gtk.gdk.Color()
cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
window.set_cursor(cursor)
window.connect("destroy", gtk.main_quit)
window.show_all()
app()
gtk.main()
显然它只是一个窗口,但是当我尝试运行它时。我收到这个错误。
AttributeError: 'gtk.Window' object has no attribute 'set_cursor'
看到该错误后,我意识到 gt.Window 将无法做到这一点,但 gtk.gdk.Window 可以。但是,我如何转换这个基本窗口以隐藏光标。
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
import gtk
class app:
def __init__(self):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("TestApp")
window.set_default_size(400,200)
pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
color = gtk.gdk.Color()
cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
window.set_cursor(cursor)
window.connect("destroy", gtk.main_quit)
window.show_all()
app()
gtk.main()
Obviously all it is, is just a window, however when I went to try and run it. I got this error.
AttributeError: 'gtk.Window' object has no attribute 'set_cursor'
After seeing that error I realized gt.Window won't be able to do it, but gtk.gdk.Window will. However how can I convert this basic window so it'll hide the cursor.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 PyGTK 常见问题解答中所述,您应该将光标设置在
实现
信号。如果您不等待实现
信号,gtk.gdk.window
尚未创建,因此您无法更改光标。所以,你可以这样做:
As stated in the PyGTK FAQ, you should set the cursor on the
realize
signal. If you don't wait for therealize
signal, thegtk.gdk.window
hasn't been created yet, so you can't change the cursor.So, you can do something like: