John Finlay wrote:
Ionutz Borcoman wrote:

Hi,

The reference says:

"To make the cursor invisible, use gtk.gdk.Cursor() to create a cursor
with no pixels in it."

When I try to use it, I get an error:

>>> import gtk
>>> gtk.pygtk_version
(2, 4, 1)
>>> c = gtk.gdk.Cursor()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: Usage:
  gtk.gdk.Cursor(cursor_type)
  gtk.gdk.Cursor(display, cursor_type)
  gtk.gdk.Cursor(display, pixbuf, x, y)
  gtk.gdk.Cusrsor(source, mask, fg, bg, x, y)
>>>

Any idea on what's wrong? Is this not supported in 2.4.1? Is it a bug?

TIA,

Try:

pix = gtk.gdk.Pixmap(window, 1, 1, 1)
color = gtk.gdk.Color()
cursor = gtk.gdk.Cursor(pix, pix, color, color, 0, 0)

John


Thanks, it should probably work, but I've already changed my code to:
def create_empty_cursor():
  pix_data = """/* XPM */
static char * invisible_xpm[] = {
"1 1 1 1",
"       c None",
" "};"""
  color = gtk.gdk.Color()
  pix = gtk.gdk.pixmap_create_from_data(None,
     pix_data, 1, 1, 1, color, color)
  return gtk.gdk.Cursor(pix, pix, color, color, 0, 0)

This way I don't need the window anymore and I can create the cursor
before showing the widget (in my __init__).

I guess this should go in the standard pygtk, that is, a call to
gtk.gdk.Cursor() with no arguments should return this cursor. As I said
before, I belive hiding the cursor is a common enough operation, so it
should deserve a simpler solution.

If not, your or my solution should go in the FAQ under "How do I hide
the cursor?":

How do I hide the cursor?
-------------------------

1. Create an invisible cursor with:

  pix_data = """/* XPM */
static char * invisible_xpm[] = {
"1 1 1 1",
"       c None",
" "};"""
  color = gtk.gdk.Color()
  pix = gtk.gdk.pixmap_create_from_data(None,
     pix_data, 1, 1, 1, color, color)
  invisble_cursor = gtk.gdk.Cursor(pix, pix, color, color, 0, 0)

2. When you need to hide the cursor in 'some_gtk_widget', set it to the
invisble one:

  some_gtk_widget.window.set_cursor(invisble_cursor)

3. To show again the cursor, set it to the old cursor or to the default one:

  # set the cursor to the default one
  some_gtk_widget.window.set_cursor(None)

Cheers,

--
Ionutz Borcoman
http://borco.net/

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to