From be542f145f61a651d7287d4aa1713a4f5395fca6 Mon Sep 17 00:00:00 2001 From: DocGarbanzo Date: Sun, 12 Nov 2023 22:35:38 +0000 Subject: [PATCH] UI improvements: * Small minor fixex / changes in UI and improved imports --- donkeycar/management/ui/car_screen.kv | 5 ++--- donkeycar/management/ui/pilot_screen.kv | 2 +- donkeycar/management/ui/train_screen.py | 24 +++++++++++++----------- donkeycar/management/ui/ui.py | 8 +++----- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/donkeycar/management/ui/car_screen.kv b/donkeycar/management/ui/car_screen.kv index 84896bff4..b9cf36c30 100644 --- a/donkeycar/management/ui/car_screen.kv +++ b/donkeycar/management/ui/car_screen.kv @@ -103,6 +103,8 @@ size_hint_y: None height: common_height spacing: layout_pad_x + ProgressBar: + id: push_bar RoundedButton: id: send_pilots multiline: False @@ -110,9 +112,6 @@ on_release: self.disabled = True root.send_pilot() - ProgressBar: - id: push_bar - # value: root.push_bar BackgroundBoxLayout: size_hint_y: 0.75 diff --git a/donkeycar/management/ui/pilot_screen.kv b/donkeycar/management/ui/pilot_screen.kv index 909b21172..2342589db 100644 --- a/donkeycar/management/ui/pilot_screen.kv +++ b/donkeycar/management/ui/pilot_screen.kv @@ -187,7 +187,7 @@ screen: root DataPanel: id: data_in - font_color: [0, 1, 0, 1] + font_color: [0.3, 0.8, 0.3, 1] screen: root record: root.current_record dual_mode: True diff --git a/donkeycar/management/ui/train_screen.py b/donkeycar/management/ui/train_screen.py index 46b5bb4de..706e56d33 100644 --- a/donkeycar/management/ui/train_screen.py +++ b/donkeycar/management/ui/train_screen.py @@ -90,6 +90,9 @@ class TransferSelector(BoxLayout, FileChooserBase): class ConfigViewerPopup(Popup): + """ Popup to view the config that was saved in the model database as part + of the training.""" + config = ObjectProperty() def _config_to_dict(self): @@ -107,7 +110,7 @@ def _config_to_dict(self): cfg_list = json.loads(s) except Exception as e: Logger.error(f'Failed json read of config: {e}') - assert isinstance(cfg_list, list), "Dejsonised config should be list" + assert isinstance(cfg_list, list), "De-jsonised config should be list" return dict(cfg_list) def fill_grid(self): @@ -194,7 +197,7 @@ def on_dataframe(self, obj, dataframe): self.plot_dataframe(dataframe) if self.dataframe.empty: return - pilot_names = list(self.dataframe['Name'].values) + pilot_names = self.dataframe['Name'].values.tolist() self.ids.transfer_spinner.values \ = ['Choose transfer model'] + pilot_names self.ids.select_spinner.values = pilot_names @@ -205,24 +208,23 @@ def plot_dataframe(self, df, selected_cols=None): grid.clear_widgets() # only set column chooser labels on initialisation when selected_cols # is not passed in. otherwise project df to selected columns - if selected_cols is not None: - df = df[selected_cols] + df1 = df[selected_cols] if selected_cols is not None else df - num_cols = len(df.columns) - rows = len(df) + num_cols = len(df1.columns) + rows = len(df1) grid.cols = num_cols - for i, col in enumerate(df.columns): + for i, col in enumerate(df1.columns): lab = BackgroundLabel(text=f"[b]{col}[/b]", markup=True) lab.size = lab.texture_size grid.add_widget(lab) - if col in ('Pilot', 'Comment'): - grid.cols_minimum |= {i: 100} + # if col in ('Pilot', 'Comment'): + # grid.cols_minimum |= {i: 100} for row in range(rows): for col in range(num_cols): - cell = df.iloc[row][col] - if df.columns[col] == 'Time': + cell = df1.iloc[row][col] + if df1.columns[col] == 'Time': cell = datetime.datetime.fromtimestamp(cell) cell = cell.strftime("%Y-%m-%d %H:%M:%S") cell = str(cell) diff --git a/donkeycar/management/ui/ui.py b/donkeycar/management/ui/ui.py index eeea9fbb9..2612daaca 100644 --- a/donkeycar/management/ui/ui.py +++ b/donkeycar/management/ui/ui.py @@ -2,16 +2,16 @@ from kivy.logger import Logger, LOG_LEVELS from kivy.clock import Clock from kivy.app import App +from kivy.properties import StringProperty from kivy.uix.boxlayout import BoxLayout from kivy.lang.builder import Builder from kivy.core.window import Window -from kivy.uix.screenmanager import Screen from donkeycar.management.ui.car_screen import CarScreen from donkeycar.management.ui.pilot_screen import PilotScreen from donkeycar.management.ui.train_screen import TrainScreen from donkeycar.management.ui.tub_screen import TubScreen -from common import * +from common import AppScreen Logger.setLevel(LOG_LEVELS["info"]) @@ -45,16 +45,14 @@ def initialise(self, event): def build(self): # the builder returns the screen manager dm = Builder.load_file(os.path.join(os.path.dirname(__file__), 'ui.kv')) - Window.bind(on_request_close=self.on_request_close) Clock.schedule_once(self.initialise) return dm - def on_request_close(self, *args): + def on_stop(self, *args): tub = self.root.ids.tub_screen.ids.tub_loader.tub if tub: tub.close() Logger.info("Good bye Donkey") - return False def main():