New argument to not generate certain modules

This commit is contained in:
nemunaire 2022-12-30 19:34:55 +01:00
parent 0644bdc68f
commit 70f0c81fcc

21
main.py
View File

@ -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)