0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

fix(ring): enable_auto_updates(True) do not reset properties of already setup bars

This commit is contained in:
2024-06-05 20:01:59 +02:00
parent d44b1cf8b1
commit a2abad344f
3 changed files with 28 additions and 6 deletions

View File

@ -1890,7 +1890,7 @@ class Ring(RPCBase):
"""
@rpc_call
def set_min_max_values(self, min_value: "int", max_value: "int"):
def set_min_max_values(self, min_value: "int | float", max_value: "int | float"):
"""
None
"""

View File

@ -49,7 +49,7 @@ class RingConfig(ConnectionConfig):
description="Background color for the progress bars. Can be tuple (R, G, B, A) or string HEX Code.",
)
index: int | None = Field(0, description="Index of the progress bar. 0 is outer ring.")
line_width: int | None = Field(5, description="Line widths for the progress bars.")
line_width: int | None = Field(10, description="Line widths for the progress bars.")
start_position: int | None = Field(
90,
description="Start position for the progress bars in degrees. Default is 90 degrees - corespons to "

View File

@ -118,7 +118,7 @@ class SpiralProgressBar(BECConnector, QWidget):
# For updating bar behaviour
self._auto_updates = True
self._rings = []
self._rings = None
if num_bars is not None:
self.config.num_bars = max(
@ -211,6 +211,7 @@ class SpiralProgressBar(BECConnector, QWidget):
self._reindex_rings()
if self.config.color_map:
self.set_colors_from_map(self.config.color_map)
del ring
self.update()
def _reindex_rings(self):
@ -269,9 +270,30 @@ class SpiralProgressBar(BECConnector, QWidget):
num_bars = max(
self.config.min_number_of_bars, min(num_bars, self.config.max_number_of_bars)
)
if num_bars != self.config.num_bars:
self.config.num_bars = num_bars
self.initialize_bars()
current_num_bars = self.config.num_bars
if num_bars > current_num_bars:
for i in range(current_num_bars, num_bars):
new_ring_config = RingConfig(
widget_class="Ring", index=i, start_positions=90 * 16, directions=-1
)
self.config.rings.append(new_ring_config)
new_ring = Ring(parent_progress_widget=self, config=new_ring_config)
self._rings.append(new_ring)
elif num_bars < current_num_bars:
for i in range(current_num_bars - 1, num_bars - 1, -1):
self.remove_ring(i)
self.config.num_bars = num_bars
if self.config.color_map:
self.set_colors_from_map(self.config.color_map)
base_line_width = self._rings[0].config.line_width
self.set_line_widths(base_line_width)
self.update()
def set_value(self, values: int | list, ring_index: int = None):
"""