Closes #29 Widget get_image method

master
Josef Dabrowski 6 years ago
parent 43902ee635
commit 798782a17c

@ -3,6 +3,7 @@ from collections import namedtuple
import uuid import uuid
import os import os
import toml import toml
from PIL import Image
mydir = os.path.dirname(os.path.abspath(__file__)) mydir = os.path.dirname(os.path.abspath(__file__))
@ -52,6 +53,19 @@ class Manager():
with open(path, "w+") as config_file: with open(path, "w+") as config_file:
config_file.write(toml.dumps({'devices': preserved_data})) config_file.write(toml.dumps({'devices': preserved_data}))
def render(self):
"""
Render a canvas image from the present data
"""
pass
def pull_latest(self):
"""
Pull the latest network data requested by each widget
"""
pass
class Device(): class Device():
""" """
@ -101,6 +115,15 @@ class Device():
""" """
self.widgets.append(widget) self.widgets.append(widget)
def remove_widget(self, widget_id):
"""
Removes a widget from the device's widget list
"""
for widg in self.widgets:
if widg.widget_id == widget_id:
self.widgets.remove(widg)
break
class Widget(): class Widget():
""" """
Widget class to hold properties common to all widgets. Widget class to hold properties common to all widgets.
@ -165,10 +188,25 @@ class BasicTextWidget(Widget):
return_state['w_type'] = 'BasicTextWidget' return_state['w_type'] = 'BasicTextWidget'
return return_state return return_state
def __init__(self, position, dimensions, widget_id, text): def __init__(self, position, dimensions, widget_id, text, font_size, font):
super().__init__(position, dimensions, widget_id) super().__init__(position, dimensions, widget_id)
self.text = text self.text = text
self.font_size = font_size
self.font = None
def get_image(self):
"""
Returns a widget image via the cache or render method. For now just returns example black image
"""
img = Image.new('1', (self.dimensions[0], self.dimensions[1]), 0) #255 black
return img
def render(self):
"""
Render an image of the widget from the present data
"""
pass
# Global Functions # Global Functions
# #

Loading…
Cancel
Save