From b273d58f9c41253b798a9be82d69fca4fb4ffc20 Mon Sep 17 00:00:00 2001 From: macrocosme Date: Fri, 4 Nov 2016 09:40:09 +1100 Subject: [PATCH 01/11] Adding setter for label_str Minor fix related to issue #1251 & #1271 https://github.com/vispy/vispy/pull/1271 --- vispy/scene/widgets/colorbar.py | 9 +++++++++ vispy/visuals/colorbar.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/vispy/scene/widgets/colorbar.py b/vispy/scene/widgets/colorbar.py index 84a6b3a5a3..1ce6d64aab 100644 --- a/vispy/scene/widgets/colorbar.py +++ b/vispy/scene/widgets/colorbar.py @@ -132,6 +132,15 @@ def label(self): def label(self, label): self._colorbar.label = label + @property + def label_str(self): + return self._label_str + + @label_str.setter + def label_str(self, label_str): + self._label_str = label_str + self._update() + @property def clim(self): return self._colorbar.clim diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index 18b5ad476f..5eab73e133 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -596,6 +596,15 @@ def label(self, label): self._label = label self._update() + @property + def label_str(self): + return self._label_str + + @label_str.setter + def label_str(self, label_str): + self._label_str = label_str + self._update() + @property def ticks(self): """ The vispy.visuals.TextVisual associated with the ticks From a4dbf051ae6d4b005f28f0cec53daab38e3358cb Mon Sep 17 00:00:00 2001 From: macrocosme Date: Wed, 8 Nov 2017 12:49:08 +0200 Subject: [PATCH 02/11] Adding ._colourbar. to access label_str Acting on @kmuehlbauer request --- vispy/scene/widgets/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vispy/scene/widgets/colorbar.py b/vispy/scene/widgets/colorbar.py index 1ce6d64aab..30b52b5347 100644 --- a/vispy/scene/widgets/colorbar.py +++ b/vispy/scene/widgets/colorbar.py @@ -134,7 +134,7 @@ def label(self, label): @property def label_str(self): - return self._label_str + return self._colorbar._label_str @label_str.setter def label_str(self, label_str): From bb774cf66aa435f79c0d915055be48cdb904f8a3 Mon Sep 17 00:00:00 2001 From: macrocosme Date: Wed, 8 Nov 2017 12:51:03 +0200 Subject: [PATCH 03/11] Adding ._colorbar. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acting on @kmuehlbauer’s request --- vispy/visuals/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index 5eab73e133..e6bdc78a39 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -598,7 +598,7 @@ def label(self, label): @property def label_str(self): - return self._label_str + return self._colorbar._label_str @label_str.setter def label_str(self, label_str): From d2d03e9d59a1069b78e39e79451c10c6eb06403b Mon Sep 17 00:00:00 2001 From: macrocosme Date: Wed, 8 Nov 2017 15:58:21 +0200 Subject: [PATCH 04/11] Reverting change ._colorbar As requested by @kmuehlbauer --- vispy/visuals/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index e6bdc78a39..5eab73e133 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -598,7 +598,7 @@ def label(self, label): @property def label_str(self): - return self._colorbar._label_str + return self._label_str @label_str.setter def label_str(self, label_str): From 9e56b9a33ba4090105a8ff9b4e707198596c2a0f Mon Sep 17 00:00:00 2001 From: macrocosme Date: Sun, 19 Nov 2017 19:47:46 +1100 Subject: [PATCH 05/11] Changing both setter and getter Changing to set/get using _colorbar Also includes a simple docstring --- vispy/scene/widgets/colorbar.py | 10 +++++++++- vispy/visuals/colorbar.py | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/vispy/scene/widgets/colorbar.py b/vispy/scene/widgets/colorbar.py index 30b52b5347..3685f4a834 100644 --- a/vispy/scene/widgets/colorbar.py +++ b/vispy/scene/widgets/colorbar.py @@ -134,11 +134,19 @@ def label(self, label): @property def label_str(self): + """Get the colorbar string + """ return self._colorbar._label_str @label_str.setter def label_str(self, label_str): - self._label_str = label_str + """Set the colorbar string + + Parameters + ---------- + label_str : string label to be displayed with the colorbar + """ + self._colorbar._label_str = label_str self._update() @property diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index 5eab73e133..7ef6909741 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -598,10 +598,18 @@ def label(self, label): @property def label_str(self): + """ Get the string describing the label for the colorbar + :return: Label string value (self._label_str) + """ return self._label_str @label_str.setter def label_str(self, label_str): + """ Set the string that describes the label of the colorbar + + :param label_str: string describing the colorbar + :return: + """ self._label_str = label_str self._update() From 47060e450be735389bf1db55df84f6d037828d11 Mon Sep 17 00:00:00 2001 From: Dany Vohl Date: Fri, 4 May 2018 14:44:09 -0400 Subject: [PATCH 06/11] Adding short docstrings --- vispy/visuals/colorbar.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index 7ef6909741..5d87dd3c36 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -599,16 +599,22 @@ def label(self, label): @property def label_str(self): """ Get the string describing the label for the colorbar - :return: Label string value (self._label_str) + + Returns + ------- + _label_str : str + Label string value """ return self._label_str @label_str.setter def label_str(self, label_str): """ Set the string that describes the label of the colorbar - - :param label_str: string describing the colorbar - :return: + + Parameters + ---------- + label_str : str + string describing the colorbar """ self._label_str = label_str self._update() From f15ca6f9d0f9dd98c8a8f7215484eac2b8af907b Mon Sep 17 00:00:00 2001 From: Dany Vohl Date: Fri, 4 May 2018 19:14:31 -0400 Subject: [PATCH 07/11] Adding ticks --- vispy/scene/widgets/colorbar.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vispy/scene/widgets/colorbar.py b/vispy/scene/widgets/colorbar.py index 3685f4a834..72e6c9ec02 100644 --- a/vispy/scene/widgets/colorbar.py +++ b/vispy/scene/widgets/colorbar.py @@ -148,7 +148,14 @@ def label_str(self, label_str): """ self._colorbar._label_str = label_str self._update() - + + def ticks(self): + return self._colorbar.ticks + + @ticks.setter + def ticks(self, ticks): + self._colorbar.ticks = ticks + @property def clim(self): return self._colorbar.clim From 939917d4fa266d8677a1f3792dbf24f73cce171d Mon Sep 17 00:00:00 2001 From: Dany Vohl Date: Sun, 6 May 2018 21:19:12 -0400 Subject: [PATCH 08/11] Add @property back --- vispy/scene/widgets/colorbar.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vispy/scene/widgets/colorbar.py b/vispy/scene/widgets/colorbar.py index 0922271610..fbec20dbc7 100644 --- a/vispy/scene/widgets/colorbar.py +++ b/vispy/scene/widgets/colorbar.py @@ -154,6 +154,7 @@ def label_str(self, label_str): self._colorbar._label_str = label_str self._update() + @property def ticks(self): return self._colorbar.ticks From 59a9d18d0aed644bea89152fe26d2685bdd71cb7 Mon Sep 17 00:00:00 2001 From: Dany Vohl Date: Thu, 5 Jul 2018 10:50:20 +1000 Subject: [PATCH 09/11] Remove property/setter label_str, and rename label_str to label_text --- vispy/scene/widgets/colorbar.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/vispy/scene/widgets/colorbar.py b/vispy/scene/widgets/colorbar.py index fbec20dbc7..08863ca525 100644 --- a/vispy/scene/widgets/colorbar.py +++ b/vispy/scene/widgets/colorbar.py @@ -77,7 +77,7 @@ def __init__(self, cmap, orientation, self._colorbar = ColorBarVisual(size=dummy_size, cmap=cmap, orientation=orientation, - label_str=label, clim=clim, + label_text=label, clim=clim, label_color=label_color, border_width=border_width, border_color=border_color, **kwargs) @@ -137,23 +137,6 @@ def label(self): def label(self, label): self._colorbar.label = label - @property - def label_str(self): - """Get the colorbar string - """ - return self._colorbar._label_str - - @label_str.setter - def label_str(self, label_str): - """Set the colorbar string - - Parameters - ---------- - label_str : string label to be displayed with the colorbar - """ - self._colorbar._label_str = label_str - self._update() - @property def ticks(self): return self._colorbar.ticks From 0bf9f72dcb53787ff32f29587c31e43f34d857bb Mon Sep 17 00:00:00 2001 From: Dany Vohl Date: Thu, 5 Jul 2018 10:55:29 +1000 Subject: [PATCH 10/11] Change label_str to label_text - Rename label_str to label_text - Change label setter to check for str. --- vispy/visuals/colorbar.py | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index ab2f81f2b7..931b17d94c 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -253,7 +253,7 @@ class ColorBarVisual(CompoundVisual): pos : tuple (x, y) Position where the colorbar is to be placed with respect to the center of the colorbar - label_str : str + label_text : str The label that is to be drawn with the colorbar that provides information about the colorbar. label_color : str | vispy.color.Color @@ -277,14 +277,13 @@ class ColorBarVisual(CompoundVisual): def __init__(self, cmap, orientation, size, pos=[0, 0], - label_str="", + label_text="", label_color='black', clim=(0.0, 1.0), border_width=1.0, border_color="black", **kwargs): - self._label_str = label_str self._label_color = label_color self._cmap = get_colormap(cmap) self._clim = clim @@ -292,7 +291,7 @@ def __init__(self, cmap, orientation, size, self._size = size self._orientation = orientation - self._label = TextVisual(self._label_str, color=self._label_color) + self._label = TextVisual(label_text, color=self._label_color) self._ticks = [] self._ticks.append(TextVisual(str(self._clim[0]), @@ -601,31 +600,11 @@ def label(self): @label.setter def label(self, label): - self._label = label - self._update() - - @property - def label_str(self): - """ Get the string describing the label for the colorbar - - Returns - ------- - _label_str : str - Label string value - """ - return self._label_str - - @label_str.setter - def label_str(self, label_str): - """ Set the string that describes the label of the colorbar - - Parameters - ---------- - label_str : str - string describing the colorbar - """ - self._label_str = label_str - self._update() + if isinstance(label, str): + self._label.text = label + else: + self._label = label + self._update() @property def ticks(self): From 53b5114ebb0ab45532773d246cbf5ea5e0f4eb1c Mon Sep 17 00:00:00 2001 From: Dany Vohl Date: Mon, 1 Oct 2018 21:18:00 +0200 Subject: [PATCH 11/11] Remove indentation --- vispy/visuals/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index 931b17d94c..20c80705d5 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -604,7 +604,7 @@ def label(self, label): self._label.text = label else: self._label = label - self._update() + self._update() @property def ticks(self):