Skip to content

Instantly share code, notes, and snippets.

@jsbain
Created August 3, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsbain/66e820004fd19d33cd23c50b5ef85a2d to your computer and use it in GitHub Desktop.
Save jsbain/66e820004fd19d33cd23c50b5ef85a2d to your computer and use it in GitHub Desktop.
poo_1.py
import ui
view_str='''
[ { "class" : "View", "attributes" : {
"custom_class" : "moo",
"tint_color" : "RGBA(0.0,0.5,1.0,1.0)",
"border_color" : "RGBA(0.0,0.0,0.0,1.0)",
"flex" : "" },
"frame" : "{{0, 0}, {240, 240}}", "selected" : false,
"nodes" : [ {
"class" : "View",
"attributes" : {
"class" : "View",
"name" : "view1",
"uuid" : "493BED0F-8451-4187-A384-AA7CC63971B9",
"frame" : "{{70, 70}, {100, 100}}",
"custom_class" : "goo" },
"frame" : "{{70, 70}, {100, 100}}", "selected" : false,
"nodes" : [] } ] }]
'''
def WrapInstance(obj):
class Wrapper(obj.__class__):
def __new__(cls):
return obj
return Wrapper
class goo(ui.View):
def __init__(self,*args,**kwargs):
print('goo init')
self.goo=1
class moo(ui.View):
def __init__(self,*args,**kwargs):
print('moo init')
self.moo=1
bindings={}
for k,v in globals().items():
bindings[k]=v
bindings['moo']=WrapInstance(self)
ui.load_view_str(view_str,bindings=bindings)
v = moo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment