DC.GetPixel() returns a wx.Colour object. I want to check that colour
and see if it's equal to some other colour.
I came up with the following:
def COLOUR(name):
c = wx.Colour()
c.SetFromName(name)
return c
.
.
.
colour = dc.GetPixel()
if colour == COLOUR('FROTZ'):
print "Colour was FROTZ"
this seems REALLY unweildly to me.
Is there an easier way to check one colour against another?
Thanks
···
--
Stand Fast,
tjg.
DC.GetPixel() returns a wx.Colour object. I want to check that colour
and see if it's equal to some other colour.
I came up with the following:
def COLOUR(name):
c = wx.Colour()
c.SetFromName(name)
return c
.
.
.
colour = dc.GetPixel()
if colour == COLOUR('FROTZ'):
print "Colour was FROTZ"
this seems REALLY unweildly to me.
Is there an easier way to check one colour against another?
Thanks
--
Stand Fast,
tjg.
Not sure what exactly you're trying for here. Do you just want to
retrieve the name
for the color, so you can do something like print "The pixel is ", pixel?
If so, use wx.TheColourDatabase.FindName. You'll need to have
pre-loaded all the colors you want to be able to find, though
(consider wx.lib.colourbd).
By the way, your COLOUR function can be replaced with wx.NamedColour
import wx
frotz = wx.Colour(100,40,208)
wx.TheColourDatabase.AddColour("frotz", frotz)
testcolor = wx.Colour(100,40,208)
wx.TheColourDatabase.FindName(testcolor)
u'FROTZ'
testcolor == wx.NamedColour("frotz")
True
···
On 7/12/05, Timothy Grant <timothy.grant@gmail.com> wrote:
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Thank you Chris,
I'm just teaching myself wxPython, and was experimenting with the drawing tools.
I quickly figured out how to change the colour of a pixel based on a
mouse click, and then I started thinking about changing the colour of
a pixel based on it's already existing colour (e.g., if the pixel is
BLUE make it GREEN, else make it PINK).
I appreciate your assitance.
···
On 7/13/05, Chris Mellon <arkanes@gmail.com> wrote:
On 7/12/05, Timothy Grant <timothy.grant@gmail.com> wrote:
> DC.GetPixel() returns a wx.Colour object. I want to check that colour
> and see if it's equal to some other colour.
>
> I came up with the following:
>
> def COLOUR(name):
> c = wx.Colour()
> c.SetFromName(name)
> return c
> .
> .
> .
> colour = dc.GetPixel()
>
> if colour == COLOUR('FROTZ'):
> print "Colour was FROTZ"
>
>
> this seems REALLY unweildly to me.
>
> Is there an easier way to check one colour against another?
>
> Thanks
>
> --
> Stand Fast,
> tjg.
Not sure what exactly you're trying for here. Do you just want to
retrieve the name
for the color, so you can do something like print "The pixel is ", pixel?
If so, use wx.TheColourDatabase.FindName. You'll need to have
pre-loaded all the colors you want to be able to find, though
(consider wx.lib.colourbd).
By the way, your COLOUR function can be replaced with wx.NamedColour
>>> import wx
>>> frotz = wx.Colour(100,40,208)
>>> wx.TheColourDatabase.AddColour("frotz", frotz)
>>>
>>> testcolor = wx.Colour(100,40,208)
>>> wx.TheColourDatabase.FindName(testcolor)
u'FROTZ'
>>> testcolor == wx.NamedColour("frotz")
True
--
Stand Fast,
tjg.