Skip to content

Commit

Permalink
FEATURE: component editor, automaticaly update old vehicle_components…
Browse files Browse the repository at this point in the history
….json files
  • Loading branch information
amilcarlucas committed May 20, 2024
1 parent 2d0597f commit 2fcf42d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions MethodicConfigurator/frontend_tkinter_component_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ def __init__(self, version, local_filesystem: LocalFilesystem=None):
style.configure("entry_input_invalid.TEntry", fieldbackground="red")
style.configure("entry_input_valid.TEntry", fieldbackground="white")

def update_json_data(self):
super().update_json_data()
if 'Components' not in self.data:
self.data['Components'] = {}
if 'Battery' not in self.data['Components']:
self.data['Components']['Battery'] = {}
if 'Specifications' not in self.data['Components']['Battery']:
self.data['Components']['Battery']['Specifications'] = {}
if 'Chemistry' not in self.data['Components']['Battery']['Specifications']:
self.data['Components']['Battery']['Specifications']['Chemistry'] = "Lipo"

def set_vehicle_type_and_version(self, vehicle_type: str, version: str):
self.data['Components']['Flight Controller']['Firmware']['Type'] = vehicle_type
entry = self.entry_widgets[('Flight Controller', 'Firmware', 'Type')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,18 @@ def __init__(self, version, local_filesystem: LocalFilesystem=None):
self.scroll_frame = ScrollFrame(self.root)
self.scroll_frame.pack(side="top", fill="both", expand=True)

self.update_json_data()

self.__populate_frames()

self.save_button = ttk.Button(self.root, text="Save data and start configuration", command=self.save_data)
show_tooltip(self.save_button, "Save component data and start parameter value configuration and tuning.")
self.save_button.pack(pady=7)

def update_json_data(self): # should be overwritten in child classes
if 'Format version' not in self.data:
self.data['Format version'] = 1

def __populate_frames(self):
"""
Populates the ScrollFrame with widgets based on the JSON data.
Expand Down

0 comments on commit 2fcf42d

Please sign in to comment.