diff --git a/epdlib/Layout.ipynb b/epdlib/Layout.ipynb index 7fef086..7d146d6 100644 --- a/epdlib/Layout.ipynb +++ b/epdlib/Layout.ipynb @@ -2,33 +2,31 @@ "cells": [ { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[NbConvertApp] Converting notebook Layout.ipynb to python\n", - "[NbConvertApp] Writing 15300 bytes to Layout.py\n" - ] - } - ], - "source": [ - "!jupyter-nbconvert --to python --template python_clean Layout.ipynb" - ] + "outputs": [], + "source": [] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "%load_ext autoreload\n", - "%autoreload 2\n", - "\n", - "%reload_ext autoreload" - ] + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] }, { "cell_type": "code", @@ -44,24 +42,64 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [], "source": [ "try:\n", " from . import constants\n", " from . import version\n", "except ImportError as e:\n", " import constants\n", - " import version\n", - " \n", - " \n", + " import version" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ "try: \n", " from . import Block as Block\n", "except ImportError as e:\n", " import Block as Block" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 6, @@ -71,6 +109,22 @@ "logger = logging.getLogger(__name__)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 7, @@ -98,6 +152,22 @@ " return decorator" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 8, @@ -359,934 +429,264 @@ " \n", " if not isinstance(update, dict):\n", " raise TypeError('update must be of type `dict`')\n", - " \n", + "\n", + " unknown_keys = {}\n", " for key, val in update.items():\n", " if key in self.blocks:\n", " self.blocks[key].update(val)\n", " else:\n", - " logging.debug(f'\"{key}\" is not a recognized block, skipping')\n", + " unknown_keys[key] = val\n", + " # logging.debug(f'\"{key}\" is not a recognized block, skipping')\n", + "\n", + " if len(unknown_keys) > 0:\n", + " logging.debug(f'{len(unknown_keys)} unrecognized keys were provided, but not used')\n", + " \n", " \n", " def concat(self):\n", " self.image = Image.new(self.mode, self.resolution, 'white')\n", " if self.blocks:\n", " for b in self.blocks:\n", " self.image.paste(self.blocks[b].image, self.blocks[b].abs_coordinates)\n", - " return self.image \n", - " " + " return self.image " ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "DEBUG:root:NO MASTER LAYOUT YET\n", - "DEBUG:root:[[----checking default values for layout----]\n", - "DEBUG:root:section: [------------l_head------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"relative: False\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [------------r_head------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [------------number------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [---------small_number---------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [-------------text-------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:[[....calculating layouts....]]\n", - "INFO:root:section: [............l_head............]\n", - "DEBUG:root:resolution: (300, 200)\n", - "DEBUG:root:width: 0.5, height: 0.1\n", - "DEBUG:root:area: (150, 20), padded_area: (150, 20)\n", - "DEBUG:root:absolute coordinates provided\n", - "DEBUG:root:block coordinates: (0, 0)\n", - "INFO:root:section: [............r_head............]\n", - "DEBUG:root:resolution: (300, 200)\n", - "DEBUG:root:width: 0.5, height: 0.1\n", - "DEBUG:root:area: (150, 20), padded_area: (150, 20)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (150, 0)\n", - "INFO:root:section: [............number............]\n", - "DEBUG:root:resolution: (300, 200)\n", - "DEBUG:root:width: 0.6, height: 0.4\n", - "DEBUG:root:area: (180, 80), padded_area: (180, 80)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (0, 20)\n", - "INFO:root:section: [.........small_number.........]\n", - "DEBUG:root:resolution: (300, 200)\n", - "DEBUG:root:width: 0.4, height: 0.5\n", - "DEBUG:root:area: (120, 100), padded_area: (120, 100)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (180, 20)\n", - "INFO:root:section: [.............text.............]\n", - "DEBUG:root:resolution: (300, 200)\n", - "DEBUG:root:width: 1, height: 0.4\n", - "DEBUG:root:area: (300, 80), padded_area: (300, 80)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (0, 100)\n", - "DEBUG:root:layout config: resolution, (300, 200), force_onebit: False, mode: 1\n", - "INFO:root:[[____SETTING SECTION BLOCKS____]]\n", - "INFO:root:setting section: [____________l_head____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 14\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: WHITE\n", - "INFO:root:using WaveShare color: WHITE\n", - "DEBUG:root:converting \"(255, 255, 255)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (150, 20)\n", - "DEBUG:root:padded area: [150, 20]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 14\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 14\n", - "DEBUG:root:calculated average character width: 8.095070422535212\n", - "DEBUG:root:maximum characters per line: 19\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (41, 15)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (10, 4)\n", - "INFO:root:setting section: [____________r_head____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 14\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: RED\n", - "INFO:root:using WaveShare color: RED\n", - "DEBUG:root:converting \"(255, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "WARNING:root:fill and bkground are identical for this block\n", - "DEBUG:root:block area: (150, 20)\n", - "DEBUG:root:padded area: [150, 20]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 14\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 14\n", - "DEBUG:root:calculated average character width: 8.095070422535212\n", - "DEBUG:root:maximum characters per line: 19\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (41, 15)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (15, 2)\n", - "INFO:root:setting section: [____________number____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:x target size reached\n", - "DEBUG:root:calculated font size: 47\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: WHITE\n", - "INFO:root:using WaveShare color: WHITE\n", - "DEBUG:root:converting \"(255, 255, 255)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (180, 80)\n", - "DEBUG:root:padded area: [180, 80]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 47\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 47\n", - "DEBUG:root:calculated average character width: 26.60764587525151\n", - "DEBUG:root:maximum characters per line: 7\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (133, 48)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (5, 21)\n", - "INFO:root:setting section: [_________small_number_________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:x target size reached\n", - "DEBUG:root:calculated font size: 31\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: GREEN\n", - "INFO:root:using WaveShare color: GREEN\n", - "DEBUG:root:converting \"(0, 255, 0)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLUE\n", - "INFO:root:using WaveShare color: BLUE\n", - "DEBUG:root:converting \"(0, 0, 255)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (120, 100)\n", - "DEBUG:root:padded area: [120, 100]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 31\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 31\n", - "DEBUG:root:calculated average character width: 17.618963782696177\n", - "DEBUG:root:maximum characters per line: 7\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (87, 32)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (13, 42)\n", - "INFO:root:setting section: [_____________text_____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 19\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "DEBUG:root:set fill: ORANGE\n", - "INFO:root:using WaveShare color: ORANGE\n", - "DEBUG:root:converting \"(255, 128, 0)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (300, 80)\n", - "DEBUG:root:padded area: [300, 80]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 19\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 19\n", - "DEBUG:root:calculated average character width: 10.86317907444668\n", - "DEBUG:root:maximum characters per line: 28\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (54, 20)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (69, 10)\n", - "DEBUG:root:NO MASTER LAYOUT YET\n", - "DEBUG:root:[[----checking default values for layout----]\n", - "DEBUG:root:section: [------------l_head------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"relative: False\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [------------r_head------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [------------number------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [---------small_number---------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [-------------text-------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:[[....calculating layouts....]]\n", - "INFO:root:section: [............l_head............]\n", - "DEBUG:root:resolution: (800, 400)\n", - "DEBUG:root:width: 0.5, height: 0.1\n", - "DEBUG:root:area: (400, 40), padded_area: (400, 40)\n", - "DEBUG:root:absolute coordinates provided\n", - "DEBUG:root:block coordinates: (0, 0)\n", - "INFO:root:section: [............r_head............]\n", - "DEBUG:root:resolution: (800, 400)\n", - "DEBUG:root:width: 0.5, height: 0.1\n", - "DEBUG:root:area: (400, 40), padded_area: (400, 40)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (400, 0)\n", - "INFO:root:section: [............number............]\n", - "DEBUG:root:resolution: (800, 400)\n", - "DEBUG:root:width: 0.6, height: 0.4\n", - "DEBUG:root:area: (480, 160), padded_area: (480, 160)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (0, 40)\n", - "INFO:root:section: [.........small_number.........]\n", - "DEBUG:root:resolution: (800, 400)\n", - "DEBUG:root:width: 0.4, height: 0.5\n", - "DEBUG:root:area: (320, 200), padded_area: (320, 200)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (480, 40)\n", - "INFO:root:section: [.............text.............]\n", - "DEBUG:root:resolution: (800, 400)\n", - "DEBUG:root:width: 1, height: 0.4\n", - "DEBUG:root:area: (800, 160), padded_area: (800, 160)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (0, 200)\n", - "DEBUG:root:layout config: resolution, (800, 400), force_onebit: False, mode: 1\n", - "INFO:root:[[____SETTING SECTION BLOCKS____]]\n", - "INFO:root:setting section: [____________l_head____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 30\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: WHITE\n", - "INFO:root:using WaveShare color: WHITE\n", - "DEBUG:root:converting \"(255, 255, 255)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (400, 40)\n", - "DEBUG:root:padded area: [400, 40]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 30\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 30\n", - "DEBUG:root:calculated average character width: 16.991700201207244\n", - "DEBUG:root:maximum characters per line: 24\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (86, 30)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (294, 0)\n", - "INFO:root:setting section: [____________r_head____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 30\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: RED\n", - "INFO:root:using WaveShare color: RED\n", - "DEBUG:root:converting \"(255, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "WARNING:root:fill and bkground are identical for this block\n", - "DEBUG:root:block area: (400, 40)\n", - "DEBUG:root:padded area: [400, 40]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 30\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 30\n", - "DEBUG:root:calculated average character width: 16.991700201207244\n", - "DEBUG:root:maximum characters per line: 24\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (86, 30)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (91, 4)\n", - "INFO:root:setting section: [____________number____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 122\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: WHITE\n", - "INFO:root:using WaveShare color: WHITE\n", - "DEBUG:root:converting \"(255, 255, 255)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (480, 160)\n", - "DEBUG:root:padded area: [480, 160]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 122\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 122\n", - "DEBUG:root:calculated average character width: 69.14662977867204\n", - "DEBUG:root:maximum characters per line: 7\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (347, 124)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (96, 33)\n", - "INFO:root:setting section: [_________small_number_________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:x target size reached\n", - "DEBUG:root:calculated font size: 84\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: GREEN\n", - "INFO:root:using WaveShare color: GREEN\n", - "DEBUG:root:converting \"(0, 255, 0)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLUE\n", - "INFO:root:using WaveShare color: BLUE\n", - "DEBUG:root:converting \"(0, 0, 255)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (320, 200)\n", - "DEBUG:root:padded area: [320, 200]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 84\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 84\n", - "DEBUG:root:calculated average character width: 47.55860160965795\n", - "DEBUG:root:maximum characters per line: 7\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (238, 86)\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (34, 26)\n", - "INFO:root:setting section: [_____________text_____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 40\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: ORANGE\n", - "INFO:root:using WaveShare color: ORANGE\n", - "DEBUG:root:converting \"(255, 128, 0)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (800, 160)\n", - "DEBUG:root:padded area: [800, 160]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 40\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 40\n", - "DEBUG:root:calculated average character width: 22.62575452716298\n", - "DEBUG:root:maximum characters per line: 35\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (113, 41)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (129, 54)\n", - "DEBUG:root:[[----checking default values for layout----]\n", - "DEBUG:root:section: [------------l_head------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"relative: False\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [------------r_head------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [------------number------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [---------small_number---------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:section: [-------------text-------------]\n", - "DEBUG:root:adding \"font_size: None\"\n", - "DEBUG:root:adding \"maxchar: None\"\n", - "DEBUG:root:adding \"dimensions: None\"\n", - "DEBUG:root:adding \"padding: 0\"\n", - "DEBUG:root:[[....calculating layouts....]]\n", - "INFO:root:section: [............l_head............]\n", - "DEBUG:root:resolution: (100, 40)\n", - "DEBUG:root:width: 0.5, height: 0.1\n", - "DEBUG:root:area: (50, 4), padded_area: (50, 4)\n", - "DEBUG:root:absolute coordinates provided\n", - "DEBUG:root:block coordinates: (0, 0)\n", - "INFO:root:section: [............r_head............]\n", - "DEBUG:root:resolution: (100, 40)\n", - "DEBUG:root:width: 0.5, height: 0.1\n", - "DEBUG:root:area: (50, 4), padded_area: (50, 4)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (50, 0)\n", - "INFO:root:section: [............number............]\n", - "DEBUG:root:resolution: (100, 40)\n", - "DEBUG:root:width: 0.6, height: 0.4\n", - "DEBUG:root:area: (60, 16), padded_area: (60, 16)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (0, 4)\n", - "INFO:root:section: [.........small_number.........]\n", - "DEBUG:root:resolution: (100, 40)\n", - "DEBUG:root:width: 0.4, height: 0.5\n", - "DEBUG:root:area: (40, 20), padded_area: (40, 20)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (60, 4)\n", - "INFO:root:section: [.............text.............]\n", - "DEBUG:root:resolution: (100, 40)\n", - "DEBUG:root:width: 1, height: 0.4\n", - "DEBUG:root:area: (100, 16), padded_area: (100, 16)\n", - "DEBUG:root:calculating block position from relative positions\n", - "DEBUG:root:block coordinates: (0, 20)\n", - "DEBUG:root:layout config: resolution, (100, 40), force_onebit: False, mode: 1\n", - "INFO:root:[[____SETTING SECTION BLOCKS____]]\n", - "INFO:root:setting section: [____________l_head____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 2\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: WHITE\n", - "INFO:root:using WaveShare color: WHITE\n", - "DEBUG:root:converting \"(255, 255, 255)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (50, 4)\n", - "DEBUG:root:padded area: [50, 4]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 2\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "l.layout: (300, 200)\n", - "l_head\n", - " a: (150, 20)\n", - " c: (0, 0)\n", - "r_head\n", - " a: (150, 20)\n", - " c: (150, 0)\n", - "number\n", - " a: (180, 80)\n", - " c: (0, 20)\n", - "small_number\n", - " a: (120, 100)\n", - " c: (180, 20)\n", - "text\n", - " a: (300, 80)\n", - " c: (0, 100)\n", - "\n", - "\n", - "p.layout: (800, 400)\n", - "l_head\n", - " a: (400, 40)\n", - " c: (0, 0)\n", - "r_head\n", - " a: (400, 40)\n", - " c: (400, 0)\n", - "number\n", - " a: (480, 160)\n", - " c: (0, 40)\n", - "small_number\n", - " a: (320, 200)\n", - " c: (480, 40)\n", - "text\n", - " a: (800, 160)\n", - " c: (0, 200)\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 2\n", - "DEBUG:root:calculated average character width: 1.1174547283702214\n", - "DEBUG:root:maximum characters per line: 45\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (7, 3)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (42, 0)\n", - "INFO:root:setting section: [____________r_head____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 2\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: RED\n", - "INFO:root:using WaveShare color: RED\n", - "DEBUG:root:converting \"(255, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "WARNING:root:fill and bkground are identical for this block\n", - "DEBUG:root:block area: (50, 4)\n", - "DEBUG:root:padded area: [50, 4]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 2\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 2\n", - "DEBUG:root:calculated average character width: 1.1174547283702214\n", - "DEBUG:root:maximum characters per line: 45\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (7, 3)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (37, 0)\n", - "INFO:root:setting section: [____________number____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 12\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: WHITE\n", - "INFO:root:using WaveShare color: WHITE\n", - "DEBUG:root:converting \"(255, 255, 255)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (60, 16)\n", - "DEBUG:root:padded area: [60, 16]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 12\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 12\n", - "DEBUG:root:calculated average character width: 6.839788732394366\n", - "DEBUG:root:maximum characters per line: 9\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (34, 13)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (21, 0)\n", - "INFO:root:setting section: [_________small_number_________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:x target size reached\n", - "DEBUG:root:calculated font size: 10\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: GREEN\n", - "INFO:root:using WaveShare color: GREEN\n", - "DEBUG:root:converting \"(0, 255, 0)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: BLUE\n", - "INFO:root:using WaveShare color: BLUE\n", - "DEBUG:root:converting \"(0, 0, 255)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (40, 20)\n", - "DEBUG:root:padded area: [40, 20]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 10\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 10\n", - "DEBUG:root:calculated average character width: 5.714285714285714\n", - "DEBUG:root:maximum characters per line: 7\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (30, 10)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (4, 0)\n", - "INFO:root:setting section: [_____________text_____________]\n", - "DEBUG:root:scaling font size\n", - "DEBUG:root:y target size reached\n", - "DEBUG:root:calculated font size: 3\n", - "DEBUG:root:setting block type: TextBlock\n", - "DEBUG:root:set bkground: BLACK\n", - "INFO:root:using WaveShare color: BLACK\n", - "DEBUG:root:converting \"(0, 0, 0)\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:converting \"None\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0}\n", - "DEBUG:root:converting \"0\" to mode: 1\n", - "DEBUG:root:using 0\n", - "DEBUG:root:border config: {'fill': 0, 'width': 0}\n", - "DEBUG:root:set fill: ORANGE\n", - "INFO:root:using WaveShare color: ORANGE\n", - "DEBUG:root:converting \"(255, 128, 0)\" to mode: 1\n", - "DEBUG:root:using 255\n", - "DEBUG:root:checking fill and background color\n", - "DEBUG:root:block area: (100, 16)\n", - "DEBUG:root:padded area: [100, 16]\n", - "DEBUG:root:creating Block\n", - "DEBUG:root:resetting font to match size 3\n", - "DEBUG:root:calculating maximum characters for font ('Open Sans', 'Regular') at size 3\n", - "DEBUG:root:calculated average character width: 1.824195171026157\n", - "DEBUG:root:maximum characters per line: 55\n", - "DEBUG:root:formatting string: NONE\n", - "DEBUG:root:text size: (8, 4)\n", - "DEBUG:root:pasting using random coordinates\n", - "DEBUG:root:paste coordinates: (1, 5)\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "l.layout: (300, 200)\n", - "l_head\n", - " a: (150, 20)\n", - " c: (0, 0)\n", - "r_head\n", - " a: (150, 20)\n", - " c: (150, 0)\n", - "number\n", - " a: (180, 80)\n", - " c: (0, 20)\n", - "small_number\n", - " a: (120, 100)\n", - " c: (180, 20)\n", - "text\n", - " a: (300, 80)\n", - " c: (0, 100)\n", - "\n", - "\n", - "p.layout: (100, 40)\n", - "l_head\n", - " a: (50, 4)\n", - " c: (0, 0)\n", - "r_head\n", - " a: (50, 4)\n", - " c: (50, 0)\n", - "number\n", - " a: (60, 16)\n", - " c: (0, 4)\n", - "small_number\n", - " a: (40, 20)\n", - " c: (60, 4)\n", - "text\n", - " a: (100, 16)\n", - " c: (0, 20)\n" - ] - } - ], "source": [ - "# from random import randint, choice\n", - "# from IPython.display import display\n", - "# from time import sleep\n", - "# bogus_layout = {\n", - "# 'l_head': { \n", - "# 'type': 'TextBlock',\n", - "# 'image': None,\n", - "# 'max_lines': 1,\n", - "# 'width': .5,\n", - "# 'height': .1,\n", - "# 'abs_coordinates': (0, 0),\n", - "# 'rand': True,\n", - "# 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", - "# 'bkground': 'BLACK',\n", - "# 'fill': 'WHITE'\n", - "# },\n", - "# 'r_head': { \n", - "# 'type': 'TextBlock',\n", - "# 'image': None,\n", - "# 'max_lines': 1,\n", - "# 'width': .5,\n", - "# 'height': .1,\n", - "# 'abs_coordinates': (None, 0),\n", - "# 'relative': ('l_head', 'r_head'),\n", - "# 'rand': True,\n", - "# 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", - "# 'bkground': 'RED',\n", - "# 'fill': 'BLACK'\n", - "# },\n", - "\n", - "# 'number': {\n", - "# 'type': 'TextBlock',\n", - "# 'image': None,\n", - "# 'max_lines': 1,\n", - "# 'width': .6,\n", - "# 'height': .4,\n", - "# 'abs_coordinates': (0, None),\n", - "# 'relative': ('number', 'l_head'),\n", - "# 'rand': True,\n", - "# 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", - "# },\n", - "# 'small_number': {\n", - "# 'type': 'TextBlock',\n", - "# 'image': None,\n", - "# 'max_lines': 1,\n", - "# 'width': .4,\n", - "# 'height': .5,\n", - "# 'abs_coordinates': (None, None),\n", - "# 'relative': ('number', 'l_head'),\n", - "# 'rand': True,\n", - "# 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", - "# 'fill': 'BLUE',\n", - "# 'bkground': 'GREEN',\n", - "# 'rgb_support': True\n", - "# },\n", - "# 'text': {\n", - "# 'abs_coordinates': (0, None),\n", - "# 'relative': ('text', 'number'),\n", - "# 'type': 'TextBlock',\n", - "# 'image': None,\n", - "# 'max_lines': 3,\n", - "# 'height': .4,\n", - "# 'width': 1,\n", - "# 'rand': True,\n", - "# 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", - "# 'fill': 'ORANGE',\n", - "# 'bkground': 'BLACK',\n", - "# 'rgb_support': True\n", - "# }\n", - "# }\n", - "\n", - "\n", - "# # config = {\n", - "# # 'resolution': [300, 200],\n", - "# # 'max_priority': 1,\n", - "# # 'refresh_rate': 2,\n", - "# # 'update_function': bogus_plugin,\n", - "# # 'layout': bogus_layout,\n", - "# # 'screen_mode': 'RGB',\n", - "# # 'plugin_timeout': 5,\n", - "# # 'name': 'Bogus',\n", - "# # 'foo': 'bar',\n", - "# # 'spam': False\n", - "# # }\n", - "\n", - "\n", - "# # Plugin.update_function = bogus_plugin\n", - "\n", - "# logger.root.setLevel('DEBUG')\n", - "\n", - "# l = Layout(resolution=(300, 200))\n", - "# l.layout = bogus_layout\n", - "# p = Layout(resolution=(800, 400))\n", - "# p.layout = bogus_layout\n", - "\n", - "\n", - "# # for i in range(5):\n", - "# # .resolution = (randint(300, 800), randint(300, 600))\n", - "# # logging.info(f'plugin resolution set to: {p.resolution}')\n", - "# # p.layout_obj = None\n", - "# # p.layout = bogus_layout\n", - "# # for s in bogus_layout:\n", - "# # colors = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'BLACK', 'WHITE']\n", - "# # fill = choice(colors)\n", - "# # colors.remove(fill)\n", - "# # bkground = choice(colors)\n", - "# # p.layout_obj.update_block_props(block=s, props={'bkground': bkground, 'fill': fill}, force_recalc=True)\n", - "\n", - "# # print('trying to update plugin')\n", - "# # p.force_update()\n", - "# # print('displaying image')\n", - "# # display(p.image)\n", - "# # # print('sleep for 1 second')\n", - "# # sleep(1)\n", - "\n", - "\n", - "# print(f'l.layout: {l.resolution}')\n", - "# for k, v in l.blocks.items():\n", - "# print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')\n", - " \n", - "# print(f'\\n\\np.layout: {p.resolution}')\n", - "# for k, v in p.blocks.items():\n", - "# print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')\n", - "\n", - "# p.resolution = (100, 40)\n", - "\n", - "# p._master_layout\n", - "\n", - "# print(f'l.layout: {l.resolution}')\n", - "# for k, v in l.blocks.items():\n", - "# print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')\n", - " \n", - "# print(f'\\n\\np.layout: {p.resolution}')\n", - "# for k, v in p.blocks.items():\n", - "# print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')" + "from random import randint, choice\n", + "from IPython.display import display\n", + "from time import sleep\n", + "bogus_layout = {\n", + " 'l_head': { \n", + " 'type': 'TextBlock',\n", + " 'image': None,\n", + " 'max_lines': 1,\n", + " 'width': .5,\n", + " 'height': .1,\n", + " 'abs_coordinates': (0, 0),\n", + " 'rand': True,\n", + " 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", + " 'bkground': 'BLACK',\n", + " 'fill': 'WHITE'\n", + " },\n", + " 'r_head': { \n", + " 'type': 'TextBlock',\n", + " 'image': None,\n", + " 'max_lines': 1,\n", + " 'width': .5,\n", + " 'height': .1,\n", + " 'abs_coordinates': (None, 0),\n", + " 'relative': ('l_head', 'r_head'),\n", + " 'rand': True,\n", + " 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", + " 'bkground': 'RED',\n", + " 'fill': 'BLACK'\n", + " }," + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lines_to_next_cell": 2 + }, + "source": [ + " 'number': {\n", + " 'type': 'TextBlock',\n", + " 'image': None,\n", + " 'max_lines': 1,\n", + " 'width': .6,\n", + " 'height': .4,\n", + " 'abs_coordinates': (0, None),\n", + " 'relative': ('number', 'l_head'),\n", + " 'rand': True,\n", + " 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", + " },\n", + " 'small_number': {\n", + " 'type': 'TextBlock',\n", + " 'image': None,\n", + " 'max_lines': 1,\n", + " 'width': .4,\n", + " 'height': .5,\n", + " 'abs_coordinates': (None, None),\n", + " 'relative': ('number', 'l_head'),\n", + " 'rand': True,\n", + " 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", + " 'fill': 'BLUE',\n", + " 'bkground': 'GREEN',\n", + " 'rgb_support': True\n", + " },\n", + " 'text': {\n", + " 'abs_coordinates': (0, None),\n", + " 'relative': ('text', 'number'),\n", + " 'type': 'TextBlock',\n", + " 'image': None,\n", + " 'max_lines': 3,\n", + " 'height': .4,\n", + " 'width': 1,\n", + " 'rand': True,\n", + " 'font': '../fonts/Open_Sans/OpenSans-Regular.ttf',\n", + " 'fill': 'ORANGE',\n", + " 'bkground': 'BLACK',\n", + " 'rgb_support': True\n", + " }\n", + "}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lines_to_next_cell": 2 + }, + "source": [ + "# config = {\n", + "# 'resolution': [300, 200],\n", + "# 'max_priority': 1,\n", + "# 'refresh_rate': 2,\n", + "# 'update_function': bogus_plugin,\n", + "# 'layout': bogus_layout,\n", + "# 'screen_mode': 'RGB',\n", + "# 'plugin_timeout': 5,\n", + "# 'name': 'Bogus',\n", + "# 'foo': 'bar',\n", + "# 'spam': False\n", + "# }" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plugin.update_function = bogus_plugin" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "logger.root.setLevel('DEBUG')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lines_to_next_cell": 2 + }, + "source": [ + "l = Layout(resolution=(300, 200))\n", + "l.layout = bogus_layout\n", + "p = Layout(resolution=(800, 400))\n", + "p.layout = bogus_layout" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# for i in range(5):\n", + "# .resolution = (randint(300, 800), randint(300, 600))\n", + "# logging.info(f'plugin resolution set to: {p.resolution}')\n", + "# p.layout_obj = None\n", + "# p.layout = bogus_layout\n", + "# for s in bogus_layout:\n", + "# colors = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'BLACK', 'WHITE']\n", + "# fill = choice(colors)\n", + "# colors.remove(fill)\n", + "# bkground = choice(colors)\n", + "# p.layout_obj.update_block_props(block=s, props={'bkground': bkground, 'fill': fill}, force_recalc=True)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lines_to_next_cell": 2 + }, + "source": [ + "# print('trying to update plugin')\n", + "# p.force_update()\n", + "# print('displaying image')\n", + "# display(p.image)\n", + "# # print('sleep for 1 second')\n", + "# sleep(1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "print(f'l.layout: {l.resolution}')\n", + "for k, v in l.blocks.items():\n", + " print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "print(f'\\n\\np.layout: {p.resolution}')\n", + "for k, v in p.blocks.items():\n", + " print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "p.resolution = (100, 40)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "p._master_layout" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "print(f'l.layout: {l.resolution}')\n", + "for k, v in l.blocks.items():\n", + " print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "print(f'\\n\\np.layout: {p.resolution}')\n", + "for k, v in p.blocks.items():\n", + " print(f'{k}\\n a: {v.area}\\n c: {v.abs_coordinates}')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/epdlib/Layout.py b/epdlib/Layout.py index 1b00c85..ec0ef8f 100644 --- a/epdlib/Layout.py +++ b/epdlib/Layout.py @@ -1,5 +1,17 @@ -#!/usr/bin/env python3 -# coding: utf-8 +# --- +# jupyter: +# jupytext: +# text_representation: +# extension: .py +# format_name: light +# format_version: '1.5' +# jupytext_version: 1.16.1 +# kernelspec: +# display_name: epdlib-AIMLabQa +# language: python +# name: epdlib-aimlabqa +# --- + @@ -24,8 +36,8 @@ except ImportError as e: import constants import version - - + + try: from . import Block as Block except ImportError as e: @@ -323,12 +335,18 @@ def update_contents(self, update=None): if not isinstance(update, dict): raise TypeError('update must be of type `dict`') - + + unknown_keys = {} for key, val in update.items(): if key in self.blocks: self.blocks[key].update(val) else: - logging.debug(f'"{key}" is not a recognized block, skipping') + unknown_keys[key] = val + # logging.debug(f'"{key}" is not a recognized block, skipping') + + if len(unknown_keys) > 0: + logging.debug(f'{len(unknown_keys)} unrecognized keys were provided, but not used') + def concat(self): self.image = Image.new(self.mode, self.resolution, 'white') @@ -336,7 +354,7 @@ def concat(self): for b in self.blocks: self.image.paste(self.blocks[b].image, self.blocks[b].abs_coordinates) return self.image - + @@ -462,7 +480,7 @@ def concat(self): # print(f'l.layout: {l.resolution}') # for k, v in l.blocks.items(): # print(f'{k}\n a: {v.area}\n c: {v.abs_coordinates}') - + # print(f'\n\np.layout: {p.resolution}') # for k, v in p.blocks.items(): # print(f'{k}\n a: {v.area}\n c: {v.abs_coordinates}') @@ -474,7 +492,7 @@ def concat(self): # print(f'l.layout: {l.resolution}') # for k, v in l.blocks.items(): # print(f'{k}\n a: {v.area}\n c: {v.abs_coordinates}') - + # print(f'\n\np.layout: {p.resolution}') # for k, v in p.blocks.items(): # print(f'{k}\n a: {v.area}\n c: {v.abs_coordinates}') diff --git a/epdlib/version.py b/epdlib/version.py index 489eabe..b7d0672 100644 --- a/epdlib/version.py +++ b/epdlib/version.py @@ -1 +1 @@ -__version__="0.6.5.1" +__version__="0.6.5.2"