Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bskubi authored Jan 28, 2023
1 parent 4187e5a commit 5f48380
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 9 additions & 2 deletions prioritizer_fvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ def setup_marks(self):
if len(self.tasks) >= 2:
self.tasks[1].update(Task.s2m("?"))
self.fix_marks()
self.callbacks["update"]()

self.callbacks["update_todo_list"]()
if self.finished():
self.callbacks["finished"]()
elif self.ready_to_exec():
self.callbacks["execute"](self.tasks[self.exec()])
else:
self.callbacks["option"](self.tasks[self.opt(1), self.tasks[self.opt(2)]])

@classmethod
def trim_beginning_whitespace(cls, s):
Expand Down Expand Up @@ -155,7 +162,7 @@ def exec(self):
def ready_to_exec(self):
last_star = self.index(Task.s2m("*"), start_index = -1, reverse = True)
last_opt = self.index(Task.s2m("!*"), start_index = -1, reverse = True)
return last_star > last_opt
return last_star is not None and last_opt is not None and last_star > last_opt

def exec_last_unfinished_task(self):
self.tasks[self.index(Task.s2m("!$"), start_index = -1, reverse = True)].update("* # !?")
Expand Down
2 changes: 1 addition & 1 deletion prioritizer_fvp_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def report_state(self):
self.callbacks["execute"](self.tasks[self.exec()])
elif self.finished_state():
self.callbacks["finished"]()
self.callbacks["update"]()
self.callbacks["update_todo_list"]()
5 changes: 3 additions & 2 deletions prioritizer_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setup_prioritizer(self):
self.prioritizer.callbacks["option"] = self.handle_choose
self.prioritizer.callbacks["execute"] = self.handle_execute
self.prioritizer.callbacks["finished"] = self.handle_finished
self.prioritizer.callbacks["update"] = self.handle_prioritizer_update
self.prioritizer.callbacks["update_todo_list"] = self.handle_update_todo_list

if os.path.exists("jollyrather_save.txt"):
with open("jollyrather_save.txt") as f:
Expand Down Expand Up @@ -57,6 +57,7 @@ def handle_choose(self, opt1, opt2):
self.headline_label.setText("Would you rather...")
self.opt1.setText(opt1.desc)
self.opt2.setText(opt2.desc)
self.opt1.setVisible(True)
self.opt2.setVisible(True)
self.opt1.clicked.disconnect()
self.opt2.clicked.disconnect()
Expand All @@ -75,7 +76,7 @@ def handle_finished(self):
self.opt1.setVisible(False)
self.opt2.setVisible(False)

def handle_prioritizer_update(self):
def handle_update_todo_list(self):
self.todo_list.textChanged.disconnect()
cursor = self.todo_list.textCursor()
pos = cursor.position()
Expand Down

0 comments on commit 5f48380

Please sign in to comment.