Просмотр исходного кода

added warning if no parent_task is selected

Nico Ruhnke 2 лет назад
Родитель
Сommit
b7eb8adb3d
1 измененных файлов с 8 добавлено и 5 удалено
  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():