X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/28cc717d5a48c229d8d09ef9ece751949074ae5d..bda4b4c6849c375679b39a55e257dedf39a8ba90:/wxPython/src/_colour.i diff --git a/wxPython/src/_colour.i b/wxPython/src/_colour.i index 9934bfca23..23ddd08c3c 100644 --- a/wxPython/src/_colour.i +++ b/wxPython/src/_colour.i @@ -95,9 +95,10 @@ public: "Returns the Alpha value.", ""); DocDeclStr( - bool , Ok(), + bool , IsOk(), "Returns True if the colour object is valid (the colour has been initialised with RGB values).", ""); + %pythoncode { Ok = IsOk } DocDeclStr( void , Set(byte red, byte green, byte blue, byte alpha=wxALPHA_OPAQUE), @@ -109,11 +110,12 @@ initialised with RGB values).", ""); SetRGB); DocDeclStrName( - void , InitFromName(const wxString& colourName), + void , Set(const wxString& colourName), "Sets the RGB intensity values using a colour name listed in ``wx.TheColourDatabase``.", "", SetFromName); + DocDeclStr( wxString , GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const, "Return the colour as a string. Acceptable flags are: @@ -161,6 +163,7 @@ is returned if the pixel is invalid (on X, unallocated).", ""); %extend { + KeepGIL(Get); DocAStr(Get, "Get() -> (r, g, b)", "Returns the RGB intensity values as a tuple.", ""); @@ -170,7 +173,7 @@ is returned if the pixel is invalid (on X, unallocated).", ""); int green = -1; int blue = -1; int alpha = wxALPHA_OPAQUE; - if (self->Ok()) { + if (self->IsOk()) { red = self->Red(); green = self->Green(); blue = self->Blue(); @@ -184,6 +187,7 @@ is returned if the pixel is invalid (on X, unallocated).", ""); return rv; } + KeepGIL(GetRGB); DocStr(GetRGB, "Return the colour as a packed RGB value", ""); unsigned long GetRGB() { @@ -196,10 +200,16 @@ is returned if the pixel is invalid (on X, unallocated).", ""); asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead") def __str__(self): return str(self.Get(True)) def __repr__(self): return 'wx.Colour' + str(self.Get(True)) - def __nonzero__(self): return self.Ok() + def __len__(self): return len(self.Get()) + def __getitem__(self, index): return self.Get()[index] + def __nonzero__(self): return self.IsOk() __safe_for_unpickling__ = True def __reduce__(self): return (Colour, self.Get(True)) } + + %property(Pixel, GetPixel, doc="See `GetPixel`"); + %property(RGB, GetRGB, SetRGB, doc="See `GetRGB` and `SetRGB`"); + }; %pythoncode {