@@ -218,6 +218,14 @@ def add_entry_or_combobox(self, value, entry_frame, path):
218
218
219
219
entry = ttk .Entry (entry_frame )
220
220
entry_config = {
221
+ ('Frame' , 'Specifications' , 'TOW min Kg' ): {
222
+ "type" : float ,
223
+ "validate" : lambda event , entry = entry , path = path : self .validate_takeoff_weight (event , entry , path ),
224
+ },
225
+ ('Frame' , 'Specifications' , 'TOW max Kg' ): {
226
+ "type" : float ,
227
+ "validate" : lambda event , entry = entry , path = path : self .validate_takeoff_weight (event , entry , path ),
228
+ },
221
229
('Battery' , 'Specifications' , 'Volt per cell max' ): {
222
230
"type" : float ,
223
231
"validate" : lambda event , entry = entry , path = path : self .validate_cell_voltage (event , entry , path ),
@@ -239,7 +247,7 @@ def add_entry_or_combobox(self, value, entry_frame, path):
239
247
"validate" : lambda event , entry = entry , path = path : self .validate_motor_poles (event , entry , path ),
240
248
},
241
249
('Propellers' , 'Specifications' , 'Diameter_inches' ): {
242
- "type" : int ,
250
+ "type" : float ,
243
251
"validate" : lambda event , entry = entry , path = path : self .validate_propeller (event , entry , path ),
244
252
},
245
253
}
@@ -267,6 +275,20 @@ def validate_combobox(self, event, path) -> bool:
267
275
combobox .configure (style = "comb_input_valid.TCombobox" )
268
276
return True
269
277
278
+ def validate_takeoff_weight (self , event , entry , path ):
279
+ is_focusout_event = event and event .type == "10"
280
+ try :
281
+ weight = float (entry .get ())
282
+ if weight < 0.01 or weight > 600 :
283
+ entry .configure (style = "entry_input_invalid.TEntry" )
284
+ raise ValueError ("Takeoff weight must be a float between 0.01 and 600" )
285
+ except ValueError as e :
286
+ if is_focusout_event :
287
+ show_error_message ("Error" , f"Invalid value '{ weight } ' for { '>' .join (list (path ))} \n { e } " )
288
+ return False
289
+ entry .configure (style = "entry_input_valid.TEntry" )
290
+ return True
291
+
270
292
def validate_cell_voltage (self , event , entry , path ): # pylint: disable=too-many-branches
271
293
"""
272
294
Validates the value of a battery cell voltage entry.
@@ -393,6 +415,12 @@ def validate_data(self): # pylint: disable=too-many-branches
393
415
fc_serial_connection [value ] = path [0 ]
394
416
entry .configure (style = "comb_input_valid.TCombobox" )
395
417
418
+ if path == ('Frame' , 'Specifications' , 'TOW min Kg' ):
419
+ if not self .validate_takeoff_weight (None , entry , path ):
420
+ invalid_values = True
421
+ if path == ('Frame' , 'Specifications' , 'TOW max Kg' ):
422
+ if not self .validate_takeoff_weight (None , entry , path ):
423
+ invalid_values = True
396
424
if path in [('Battery' , 'Specifications' , 'Volt per cell max' ), ('Battery' , 'Specifications' , 'Volt per cell low' ),
397
425
('Battery' , 'Specifications' , 'Volt per cell crit' )]:
398
426
if not self .validate_cell_voltage (None , entry , path ):
0 commit comments