fix window resize issue

This commit is contained in:
Matthias@Dell 2023-10-22 13:37:09 +02:00 committed by matthias@arch
parent 17d9d1df43
commit abdf937968

View File

@ -125,7 +125,7 @@ class Sorter:
self.pressed_key = self.window.getkey() # wait until user presses something self.pressed_key = self.window.getkey() # wait until user presses something
# check for quit, skip or undo # check for quit, skip, undo or open
if self.pressed_key in self.settings: if self.pressed_key in self.settings:
if self.settings[self.pressed_key] == "quit": if self.settings[self.pressed_key] == "quit":
self.quit(f"Key '{self.pressed_key}' pressed. Canceling image sorting") self.quit(f"Key '{self.pressed_key}' pressed. Canceling image sorting")
@ -145,10 +145,11 @@ class Sorter:
continue continue
elif settings[self.pressed_key] == "open": elif settings[self.pressed_key] == "open":
try: try:
subprocess.run(['xdg-open', self.image]) subprocess.run(['xdg-open', self.image], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
self.message = "Opening with xdg-open" self.message = "Opening with xdg-open"
except Exception as e: except Exception as e:
print(f"open: Error: {e}") print(f"open: Error: {e}")
continue
# move to folder # move to folder
elif self.pressed_key in self.keys: elif self.pressed_key in self.keys:
@ -167,6 +168,7 @@ class Sorter:
Draw lines and text Draw lines and text
""" """
self.window.erase() self.window.erase()
self.win_y, self.win_x = self.window.getmaxyx()
# lines # lines
self.window.hline(self.win_y - FOOTER_HEIGHT, FOOTER_LEFT, '=', self.win_x) self.window.hline(self.win_y - FOOTER_HEIGHT, FOOTER_LEFT, '=', self.win_x)
@ -237,14 +239,16 @@ class Sorter:
return new_path return new_path
def quit(self, message = ""): def quit(self, message = ""):
self.window.clear()
self.window.refresh()
c.endwin()
print(message) print(message)
print(f"Quitting imgsort {version}") print(f"Quitting imgsort {version}")
exit(0) exit(0)
def __del__(self):
self.window.clear()
self.window.refresh()
c.endwin()
def main(): def main():