Custom Cursors Not Working in Linux

I've been having difficulty getting custom cursors to display
correctly on my Linux box (RHEL 5.0). I've read elsewhere that custom
cursors don't always display correctly on Macs, but haven't seen any
complaints for Linux installs. I am using wxPython 2.8.10.1. Below
is an example application where I set the cursor to invisible, so if
it works correctly, the mouse cursor should disappear when you mouse
over the window. Custom cursors do work correctly on my WinXP box,
which is also using wxPython 2.8.10.1

*Note - In the interest of full disclosure, I didn't write this
application; I just added the custom cursor. It was lifted from a
forum some time ago, and I just think it's neat.

import wx

class CanvasItem(object):
    """A virtual base class. All child classes need to define
self.DrawMethod
and set self.type"""

    def __init__(self, parent, bbox, pen, brush):
        self.parent = parent
        self.bbox = bbox
        self.pen = pen
        self.brush = brush

    def draw(self, DC):
        DC.SetPen(self.pen)
        DC.SetBrush(self.brush)
        self.DrawMethod(DC, self.bbox)

class Oval(CanvasItem):

    def __init__(self, parent, bbox, pen, brush):
        CanvasItem.__init__(self, parent, bbox, pen, brush)

    def DrawMethod(self, dc, bbox):
        dc.DrawEllipse(bbox.x, bbox.y, bbox.width, bbox.height)

class Canvas(wx.Panel):

    # Store IDS in order by leftmost edge for more efficient collision
detections.

    def __init__(self, parent=None,id=wx.ID_ANY, pos =
wx.DefaultPosition,

size=wx.DefaultSize,style=wx.TAB_TRAVERSAL,name="panel"):
        wx.Panel.__init__(self,parent,id,pos,size,style,name)
        self.IDS = []
        self.Bind(wx.EVT_PAINT, self.OnPaint)

    def OnPaint(self,event):
        DC = wx.PaintDC(self)
        for ID in self.IDS:
            ID.draw(DC)

    def create_oval(self, x0,y0,x1,y1,outline="black", fill="",
stipple="",
                    width=1,style=wx.SOLID):
        print "Creating oval:",
x0,y0,x1,y1,outline,fill,stipple,width,style
        pen = wx.Pen(outline.upper(),width,style)
        if not fill:
            fill = "BLACK"
            style=wx.TRANSPARENT
        elif stipple == "":
            fill = outline.upper()
            style = wx.SOLID

        else:
            fill = outline.upper()
            style = wx.CROSS_HATCH # need to fix this with bitmap
stippling?!
        brush = wx.Brush(fill,style)
        self.IDS.append(Oval(self, wx.Rect(x0,y0,x1,y1), pen, brush))

app = wx.PySimpleApp(0)
app.frame = wx.Frame(parent=None, id=-1, size=(300,400))
app.frame.canvas = Canvas(parent=app.frame)
for i in range(10,300,10):
    app.frame.canvas.create_oval(10,10,i,i)

myCursor= wx.StockCursor(wx.CURSOR_BLANK)
app.frame.SetCursor(myCursor)

app.frame.Show()
app.MainLoop()

Try app.frame.canvas.SetCursor

···

On 10/19/09 3:14 PM, Mears wrote:

I've been having difficulty getting custom cursors to display
correctly on my Linux box (RHEL 5.0). I've read elsewhere that custom
cursors don't always display correctly on Macs, but haven't seen any
complaints for Linux installs. I am using wxPython 2.8.10.1. Below
is an example application where I set the cursor to invisible, so if
it works correctly, the mouse cursor should disappear when you mouse
over the window. Custom cursors do work correctly on my WinXP box,
which is also using wxPython 2.8.10.1

app = wx.PySimpleApp(0)
app.frame = wx.Frame(parent=None, id=-1, size=(300,400))
app.frame.canvas = Canvas(parent=app.frame)
for i in range(10,300,10):
     app.frame.canvas.create_oval(10,10,i,i)

myCursor= wx.StockCursor(wx.CURSOR_BLANK)
app.frame.SetCursor(myCursor)

--
Robin Dunn
Software Craftsman

Yes, that does work. Apparently, the cursor setting doesn't propagate
through the container hierarchy under Linux. I ran a couple tests
with nested panels under both Linux and Windows. In each case using
WinXP, setting the cursor on a parent panel would also update the
setting for its children. Under Linux, only the parent panel would
use the new cursor.

···

On Oct 19, 4:53 pm, Robin Dunn <ro...@alldunn.com> wrote:

Try app.frame.canvas.SetCursor

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

I also noticed that even though the system provides them, none of the
corner/diagonal arrows show up correctly under Linux. They both come
out as the move cursor (NWSE arrows).

···

On Oct 20, 9:21 am, Mears <joshuadavid...@gmail.com> wrote:

Yes, that does work. Apparently, the cursor setting doesn't propagate
through the container hierarchy under Linux. I ran a couple tests
with nested panels under both Linux and Windows. In each case using
WinXP, setting the cursor on a parent panel would also update the
setting for its children. Under Linux, only the parent panel would
use the new cursor.

On Oct 19, 4:53 pm, Robin Dunn <ro...@alldunn.com> wrote:

> Try app.frame.canvas.SetCursor

> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org

This appears to be intentional. Both types map to the same ID in src/gtk/cursor.cpp

···

On 10/20/09 9:48 AM, Mears wrote:

I also noticed that even though the system provides them, none of the
corner/diagonal arrows show up correctly under Linux. They both come
out as the move cursor (NWSE arrows).

--
Robin Dunn
Software Craftsman