I tried this code under kubuntu and ubuntu 10.04 (python 2.6,
wxPython 2.8), but I found meaningless RGB values (B always 0, for
example, independently from the background color). An other strange
thing that I found is that, if I substitute ClientDC with ScreenDC, it
works (obviously after a coordinate correction).
import wx
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(500, 350))
self.SetBackgroundColour(wx.BLUE)
self.dc=wx.ClientDC(self)
# Binding Events
self.Bind(wx.EVT_MOTION, self.ilmousesimuove)
self.Centre()
self.Show(True)
# Setting methods
def ilmousesimuove(self,event):
x,y=event.GetPosition()
colore = self.dc.GetPixel(x,y)
print x,y," colore: ", colore
app = wx.App()
MainWindow(None, -1, "titolo")
app.MainLoop()