Skip to content

Commit d00f115

Browse files
Fix "." being evaluated as a string in calibration tab.
1 parent 44f060c commit d00f115

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

BabbleApp/calib_settings_widget.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,24 @@ def render(self, window, event, values):
255255
for count2, element2 in enumerate(element1):
256256
if values[element2] != "":
257257
value = values[element2]
258-
if is_valid_float_input(value):
258+
if is_valid_float_input(value): # Returns true if a single decimal point. Therefore we need to make sure value can be converted to a float by assuming a dot implies a leading 0.
259+
if value == ".":
260+
valid_float = 0.
261+
values[element2] = valid_float
262+
window[element2].update(valid_float)
259263
value = float(values[element2])
260264
if float(self.array[count1][count2]) != value:
261265
self.array[count1][count2] = value
262266
changed = True
263267
else:
264-
value = float(value[:-1])
265-
window[element2].update(value)
266-
values[element2] = value
268+
trimmed_value = value[:-1]
269+
if trimmed_value == '': # If we get an empty string, don't try to convert to float.
270+
window[element2].update(trimmed_value)
271+
values[element2] = trimmed_value
272+
else:
273+
value = float(trimmed_value)
274+
window[element2].update(value)
275+
values[element2] = value
267276

268277
if event == self.gui_reset_min:
269278
for count1, element1 in enumerate(self.shape):

0 commit comments

Comments
 (0)