@Webmaster4o, I was just experimenting with your module livejson. But appears you are handling all a lot of data types as lists. The below code was just testing. But if you uncomment the font attr in the dict, d the code fails. A list is returned instead of a tuple. Do you think this is a oversight or does your module need to be like this: You can see I just try to save some constants/recipes in the file.
sorry, this example points to my version of livejson which has been downloaded. livejson is a module written by @Webmaster4o
import ui
import clipboard
import os, sys
root_dir = os.path.expanduser('~/Documents')
import_path = root_dir + "/MyProjects/wrench/from Working Copy/livejson/"
sys.path.append(import_path)
import livejson
_themes = ['Dawn', 'Tomorrow', 'Solarized Light',
'Solarized Dark', 'Cool Glow', 'Gold', 'Tomorrow Night', 'Oceanic',
'Editorial']
d = \
{
'frame': (10, 10, 100, 32),
'bg_color': 'purple',
'tint_color' : 'white',
'border_width':.5,
'title': 'HELLO',
'corner_radius':3,
#'font': ('Avenir Next Condensed', 18),
}
def make_btn(**kwargs):
btn = ui.Button(name = 'btn')
for k, v in kwargs.items():
if hasattr(btn, k):
setattr(btn, k, v)
return btn
class LiveJSON(object):
def __init__(self, fspec, *args, **kwargs):
self.fspec = fspec
self.db = None
self.open()
def open(self):
self.db = livejson.Database(self.fspec)
def set(self, name, data):
self.db[name] = data
def get(self, name):
return self.db[name]
class MyClass(ui.View):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if __name__ == '__main__':
w, h = 600, 800
f = (0, 0, w, h)
lj = LiveJSON('some_info.json')
lj.set('themes', _themes)
t = lj.get('themes')
x = dict(d)
lj.set('std_btn', x)
print(t, type(t), len(t))
for th in t:
print(th)
print(lj.get('std_btn'))
mc = MyClass(frame = f, bg_color = 'white')
btn = make_btn(**lj.get('std_btn'))
mc.add_subview(btn)
mc.present('sheet', animated = False)