From 70f0c81fcc31a9cd2c392541b7c9097cbb6b9438 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 30 Dec 2022 19:34:55 +0100 Subject: [PATCH] New argument to not generate certain modules --- main.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index aa67d9a..2c7e410 100644 --- a/main.py +++ b/main.py @@ -45,7 +45,7 @@ class WidgetPlacement: self.kwargs = kwargs -def main(only_on_coming_evt=False): +def main(only_on_coming_evt=False, ignore_module=[]): image = Image.new('1', (480, 800), 255) #image = Image.new('L', (480, 800), 'white') draw = ImageDraw.Draw(image) @@ -118,6 +118,10 @@ def main(only_on_coming_evt=False): last_height = 0 last_y = 0 for s in shape: + if s.module.__name__ in ignore_module: + logging.info("Skip module " + s.module.__name__ + ", as requested by arguments") + continue + try: x,y = s.position if y < 0: @@ -150,11 +154,12 @@ def main(only_on_coming_evt=False): image.paste(mod, (0, 580-mod.height-5), mod) # températures - from modules.weather import WeatherTemperatureModule - if mod.height > 260: - image.paste(WeatherTemperatureModule().draw_module(config, 480, 200 - mod.height+260), (0, 580 + mod.height-260)) - else: - image.paste(WeatherTemperatureModule().draw_module(config, 480, 200), (0, 580)) + if "WeatherTemperatureModule" not in ignore_module: + from modules.weather import WeatherTemperatureModule + if mod.height > 260: + image.paste(WeatherTemperatureModule().draw_module(config, 480, 200 - mod.height+260), (0, 580 + mod.height-260)) + else: + image.paste(WeatherTemperatureModule().draw_module(config, 480, 200), (0, 580)) fnt = ImageFont.truetype(config.fnt_R_path, 11) draw.text( @@ -184,9 +189,11 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='E-ink status generator.') + parser.add_argument('--ignore-module', '-I', nargs="*", default=[], + help='Ignore the given modules') parser.add_argument('--only-on-coming-evt', '-O', action='store_const', const=True, help='Refresh screen only if there is upcoming event') args = parser.parse_args() - main(args.only_on_coming_evt) + main(args.only_on_coming_evt, args.ignore_module)