From f51b752c4286e0bc1124f21912957ccbbc97a36b Mon Sep 17 00:00:00 2001 From: Josef Date: Wed, 11 Dec 2019 17:08:36 +0800 Subject: [PATCH] complete issue 9 added device constructor variables --- notiframe/Notiframe.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/notiframe/Notiframe.py b/notiframe/Notiframe.py index e24c784..cabda75 100644 --- a/notiframe/Notiframe.py +++ b/notiframe/Notiframe.py @@ -8,8 +8,8 @@ class Manager(): self.devices = [] self.manager_id = gen_id() - def add_device(self): #add parameters for Device class constructor - self.devices.append(Device()) + def add_device(self, name, resolution): #add parameters for Device class constructor + self.devices.append(Device(name, resolution)) def remove_device(self, dev_id): for dev in self.devices: @@ -19,9 +19,13 @@ class Manager(): class Device(): # Device class to contain a device's properties, layout and widgets - def __init__(self): - self.widgets = [] + def __init__(self, name, resolution): + self.name = name + self.resolution = resolution self.device_id = gen_id() + self.widgets = [] + self.layout = None + self.device_image = None class Test(): @@ -29,12 +33,11 @@ class Test(): def __init__(self): #instantiate manager class self.manager = Manager() - self.device = Device() - def test_all(self): + def test_manager(self): manager_uuid = self.manager_uuid() - device_uuid = self.device_uuid() add_device = self.add_device() + device_uuid = self.device_uuid() remove_device = self.remove_device() print("manager id is valid: " + str(manager_uuid)) @@ -48,7 +51,8 @@ class Test(): return self.is_valid_uuid(uuid_test) def device_uuid(self): - uuid_test = self.device.device_id + dev = self.manager.devices[0] + uuid_test = dev.device_id return self.is_valid_uuid(uuid_test) # Test if manager class's gen_id function produces a valid uuid @@ -61,7 +65,7 @@ class Test(): def add_device(self): len1 = len(self.manager.devices) - self.manager.add_device() + self.manager.add_device("test", (1080, 1920)) len2 = len(self.manager.devices) if len2 == len1 + 1: return True @@ -86,4 +90,4 @@ def gen_id(): test = Test() -test.test_all() +test.test_manager()