Skip to content

Commit

Permalink
added easy_exit_loop to pokete
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Jan 17, 2022
1 parent c552152 commit 12d9052
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 2 additions & 8 deletions pokete.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from pokete_classes.notify import notifier
from pokete_classes.achievements import achievements, AchievementOverview
from pokete_classes.event import _ev
from pokete_general_use_fns import liner, sort_vers, std_loop, parse_args
from pokete_general_use_fns import liner, sort_vers, std_loop, parse_args, easy_exit_loop
from release import VERSION, CODENAME, SAVEPATH


Expand Down Expand Up @@ -1182,13 +1182,7 @@ def detail(self, poke):
Defense: {poke.defense}
Initiative: {poke.initiative}"""))
with self.detail_box.center_add(self.map):
while True:
if _ev.get() in ["'e'", "Key.esc", "'q'"]:
_ev.clear()
break
std_loop()
time.sleep(0.05)
self.map.show()
easy_exit_loop()
self.detail_box.rem_ob(poke.ico)

def __call__(self):
Expand Down
15 changes: 12 additions & 3 deletions pokete_general_use_fns.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""General use functions for Pokete"""

import sys
import time
import release
from pokete_classes.event import _ev

Expand Down Expand Up @@ -53,10 +54,18 @@ def sort_vers(vers):
sorted([([int(j) for j in i.split(".")], i) for i in vers])]


def easy_exit_loop():
"""Loops until q or Esc are pressed"""
while True:
if _ev.get() in ["'q'", "Key.esc"]:
_ev.clear()
return
std_loop()
time.sleep(0.05)


def std_loop():
"""Standart action executed in most loops
ARGS:
_ev: Event object"""
"""Standart action executed in most loops"""
if _ev.get() == "exit":
raise KeyboardInterrupt

Expand Down

0 comments on commit 12d9052

Please sign in to comment.