From 55c51b25701a5d1cee025592a3b947ee435be06e Mon Sep 17 00:00:00 2001 From: Mesalu Date: Mon, 13 Aug 2018 22:03:29 -0700 Subject: [PATCH] Fix #957 (#960) Round RGB values to integers for creating the `wx.Colour` (cherry picked from commit 5c68798d0ceaaf569a09a69179a46f3ad831bb09) --- CHANGES.rst | 8 ++++++-- wx/lib/colourchooser/pycolourchooser.py | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index dccadcbb..729df9c4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -33,7 +33,7 @@ Changes in this release include the following: * Switch wx.lib.plot to issue deprecation warnings with PlotPendingDeprecation so it doesn't have to enable all warnings to get them to be shown by default. (#902) - + * Added a Python 3.7 builder on Fedora 28. (#925) * Fix the object ownership transfer for wx.Menu.Insert() (#931) @@ -60,7 +60,7 @@ Changes in this release include the following: * Fix missing parameter tool_id in wx.lib.agw.ribbon.toolbar.RibbonToolBar.AddToggleTool. (#947) -* Add a step to wx.Config.ReadInt to attempt converting from long to int +* Add a step to wx.Config.ReadInt to attempt converting from long to int under python2. (#384) * Add virtual behavior for wx.RichTextCtrl and wx.TextCtrl's Copy/Cut/Paste methods @@ -68,6 +68,10 @@ Changes in this release include the following: * Fix IO type in wx.lib.agw.thumbnailctrl (#959) +* Fix type error that would occur using pycolourchooser. (#957) + + + 4.0.3 "The show must go on. (Die show-stoppers! Die!)" ------------------------------------------------------ * 25-June-2018 diff --git a/wx/lib/colourchooser/pycolourchooser.py b/wx/lib/colourchooser/pycolourchooser.py index cd50de73..bd082412 100644 --- a/wx/lib/colourchooser/pycolourchooser.py +++ b/wx/lib/colourchooser/pycolourchooser.py @@ -363,9 +363,11 @@ class PyColourChooser(wx.Panel): # Allow values to go full range from 0 to 255 r, g, b = colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2]) - r *= 255.0 - g *= 255.0 - b *= 255.0 + round_tenths = lambda x: int(x + 0.5) + + r = round_tenths(r * 255.0) + g = round_tenths(g * 255.0) + b = round_tenths(b * 255.0) return wx.Colour(r, g, b)