Initial commit for release v2.0.0
A lot of work-in-progress and far from complete. Lots of improvements related to user-friendliness, fully new web-UI. Better infrastructure.... more coming soon
This commit is contained in:
		| @@ -10,14 +10,16 @@ class inkycal_module(metaclass=abc.ABCMeta): | ||||
|       callable(subclass.generate_image) or | ||||
|       NotImplemented) | ||||
|  | ||||
|   def __init__(self, section_size, section_config): | ||||
|   def __init__(self, section_config): | ||||
|     # Initializes base module | ||||
|     # sets properties shared amongst all sections | ||||
|     self.config = section_config | ||||
|     self.width, self.height = section_size | ||||
|     self.fontsize = 12 | ||||
|     self.margin_x = 0.02 | ||||
|     self.margin_y = 0.05 | ||||
|     self.width, self.height = section_config['size'] | ||||
|  | ||||
|     self.padding_left = self.padding_right = self.config["padding_x"] | ||||
|     self.padding_top = self.padding_bottom = self.config["padding_y"] | ||||
|  | ||||
|     self.fontsize = self.config["fontsize"] | ||||
|     self.font = ImageFont.truetype( | ||||
|       fonts['NotoSans-SemiCondensed'], size = self.fontsize) | ||||
|  | ||||
| @@ -56,3 +58,33 @@ class inkycal_module(metaclass=abc.ABCMeta): | ||||
|     # Generate image for this module with specified parameters | ||||
|     raise NotImplementedError( | ||||
|       'The developers were too lazy to implement this function') | ||||
|  | ||||
|   @classmethod | ||||
|   def get_config(cls): | ||||
|     # Get the config of this module for the web-ui | ||||
|     # Do not change | ||||
|     try: | ||||
|  | ||||
|       if hasattr(cls, 'requires'): | ||||
|         for each in cls.requires: | ||||
|           if not "label" in cls.requires[each]: | ||||
|             raise Exception("no label found for {}".format(each)) | ||||
|  | ||||
|       if hasattr(cls, 'optional'): | ||||
|         for each in cls.optional: | ||||
|           if not "label" in cls.optional[each]: | ||||
|             raise Exception("no label found for {}".format(each)) | ||||
|  | ||||
|       conf = { | ||||
|         "name": cls.__name__, | ||||
|         "name_str": cls.name, | ||||
|         "requires": cls.requires if hasattr(cls, 'requires') else {}, | ||||
|         "optional": cls.optional if hasattr(cls, 'optional') else {}, | ||||
|         } | ||||
|       return conf | ||||
|     except: | ||||
|       raise Exception( | ||||
|         'Ohoh, something went wrong while trying to get the config of this module') | ||||
|  | ||||
|  | ||||
|    | ||||
|   | ||||
		Reference in New Issue
	
	Block a user