snakeware

Python-based Linux distro for x86-64 and RPi
git clone git://squid-tech.com/snakeware.git
Log | Files | Refs | README

commit 50458d698c5c371284cdf195faf11d3c56a29aa3
parent 78cfdb9f75e53abdb772bb5b26e7863ff9fe6157
Author: Josh Moore <jxm5210@rit.edu>
Date:   Tue,  9 Jun 2020 16:18:42 -0400

dynbg bugs fix

Diffstat:
Msnakewm/snakebg/bgmenu.py | 7++-----
Msnakewm/wm.py | 28+++++++++++++++++-----------
2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/snakewm/snakebg/bgmenu.py b/snakewm/snakebg/bgmenu.py @@ -17,17 +17,14 @@ class SnakeBGMenu(UIWindow): # size of each menu button BSIZE = (200, 20) - # list of background modules - BGLIST = None - def __init__(self, manager): # load bg module names bgdir = os.path.dirname(os.path.abspath(__file__)) + "/backgrounds/" self.BGLIST = [] for f in os.listdir(bgdir): - if "__" in f: + if "__" in f or ".pyc" in f: continue - self.BGLIST.append(f[:-3]) + self.BGLIST.append(f.split('.')[0]) self.BGLIST = sorted(self.BGLIST) # create window diff --git a/snakewm/wm.py b/snakewm/wm.py @@ -61,6 +61,7 @@ class SnakeWM: # reference to SnakeBG object for dynamic backgrounds DYNBG = None + DYNBG_MENU = None # currently focused window FOCUS = None @@ -194,9 +195,9 @@ class SnakeWM: self.BRUSH_SURF.fill((0, 0, 0, 0)) elif event.key == pygame.K_d: # toggle dynamic background - if self.DYNBG is None: - SnakeBGMenu(self.MANAGER) - else: + if self.DYNBG is None and self.DYNBG_MENU is None: + self.DYNBG_MENU = SnakeBGMenu(self.MANAGER) + elif self.DYNBG is not None: del self.DYNBG self.DYNBG = None @@ -243,14 +244,19 @@ class SnakeWM: if event.ui_object_id == "#background_picker": self.set_bg_image(event.text) elif event.user_type == pygame_gui.UI_BUTTON_PRESSED: - if ( - "#bgmenu" in event.ui_object_id - and not "title_bar" in event.ui_object_id - and not "close_button" in event.ui_object_id - ): - selected_bg = event.ui_object_id.split(".")[1] - self.DYNBG = SnakeBG(selected_bg, TESTMODE) - self.PAINT = False + if "#bgmenu" in event.ui_object_id: + if "close_button" in event.ui_object_id: + self.DYNBG_MENU.kill() + del self.DYNBG_MENU + self.DYNBG_MENU = None + elif not "title_bar" in event.ui_object_id: + selected_bg = event.ui_object_id.split(".")[1] + self.DYNBG = SnakeBG(selected_bg, TESTMODE) + self.DYNBG_MENU.kill() + del self.DYNBG_MENU + self.DYNBG_MENU = None + + self.PAINT = False self.MANAGER.process_events(event)