Skip to content

Commit 4ca9025

Browse files
committed
Tune the ruler color with fixed style
1 parent 9ec0df9 commit 4ca9025

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/silx/gui/plot/tools/RulerToolButton.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
from silx.gui.plot.tools.roi import RegionOfInterestManager
4343
from silx.gui.plot.items.roi import LineROI
44+
from silx.gui.plot import items
4445

4546

4647
_logger = logging.getLogger(__name__)
@@ -54,6 +55,7 @@ def __init__(self, parent=None):
5455
[numpy.ndarray, numpy.ndarray], str
5556
]
5657
] = None
58+
self.setColor("#001122") # Only there to trig updateStyle
5759

5860
def registerFormatFunction(
5961
self,
@@ -64,6 +66,17 @@ def registerFormatFunction(
6466
"""Register a function for the formatting of the label"""
6567
self._formatFunction = fct
6668

69+
def _updatedStyle(self, event, style: items.CurveStyle):
70+
style = items.CurveStyle(
71+
color="red",
72+
gapcolor="white",
73+
linestyle=(0, (5, 5)),
74+
linewidth=style.getLineWidth())
75+
LineROI._updatedStyle(self, event, style)
76+
self._handleLabel.setColor("black")
77+
self._handleLabel.setBackgroundColor("#FFFFFF60")
78+
self._handleLabel.setZValue(1000)
79+
6780
def setEndPoints(self, startPoint: numpy.ndarray, endPoint: numpy.ndarray):
6881
super().setEndPoints(startPoint=startPoint, endPoint=endPoint)
6982
if self._formatFunction is not None:
@@ -90,9 +103,7 @@ def __init__(
90103
self,
91104
parent=None,
92105
plot=None,
93-
color: str = "yellow",
94106
):
95-
self.__color = color
96107
super().__init__(parent=parent, plot=plot)
97108
self.setCheckable(True)
98109
self._roiManager = None
@@ -143,7 +154,6 @@ def _connectPlot(self, plot):
143154
if plot is None:
144155
return
145156
self._roiManager = RegionOfInterestManager(plot)
146-
self._roiManager.setColor(self.__color) # Set the color of ROI
147157
self._roiManager.sigRoiAdded.connect(self._registerCurrentROI)
148158

149159
def _disconnectPlot(self, plot):

0 commit comments

Comments
 (0)