Parcourir la source

added warning if no parent_task is selected

Nico Ruhnke il y a 2 ans
Parent
commit
b7eb8adb3d
1 fichiers modifiés avec 8 ajouts et 5 suppressions
  1. 8 5
      time_recoder/time_recoder_gui/time_recorder_gui_main.py

+ 8 - 5
time_recoder/time_recoder_gui/time_recorder_gui_main.py

@@ -99,11 +99,14 @@ def event_loop(window):
                 print('Error: Task name ' + sub_task_name + ' already used, please enter another one')
             elif sub_task_name:
                 parent_task_name = window.Element(TASK_TREE_COMBO_NAME).get()
-                parent_task_id = taskHandler.get_task_id(parent_task_name)
-                print('Adding new Sub-Task: ' + sub_task_name + ' to ' + parent_task_name.strip())
-                taskHandler.add_task(parent_task_id, sub_task_name)
-                window.Element(TASK_TREE_COMBO_NAME).update(
-                    values=taskHandler.get_task_tree_name_strings(taskHandler.root_task))
+                if parent_task_name:
+                    parent_task_id = taskHandler.get_task_id(parent_task_name)
+                    print('Adding new Sub-Task: ' + sub_task_name + ' to ' + parent_task_name.strip())
+                    taskHandler.add_task(parent_task_id, sub_task_name)
+                    window.Element(TASK_TREE_COMBO_NAME).update(
+                        values=taskHandler.get_task_tree_name_strings(taskHandler.root_task))
+                else:
+                    print('Please select a Task before adding a subtask')
 
 
 def gui_main():