Skip to content

Commit

Permalink
UI improvements:
Browse files Browse the repository at this point in the history
* Small minor fixex / changes in UI and improved imports
  • Loading branch information
DocGarbanzo committed Nov 12, 2023
1 parent 8de6e56 commit be542f1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
5 changes: 2 additions & 3 deletions donkeycar/management/ui/car_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,15 @@
size_hint_y: None
height: common_height
spacing: layout_pad_x
ProgressBar:
id: push_bar
RoundedButton:
id: send_pilots
multiline: False
text: 'Push pilots'
on_release:
self.disabled = True
root.send_pilot()
ProgressBar:
id: push_bar
# value: root.push_bar

BackgroundBoxLayout:
size_hint_y: 0.75
Expand Down
2 changes: 1 addition & 1 deletion donkeycar/management/ui/pilot_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions donkeycar/management/ui/train_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions donkeycar/management/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit be542f1

Please sign in to comment.