Created
August 3, 2016 15:19
-
-
Save jsbain/66e820004fd19d33cd23c50b5ef85a2d to your computer and use it in GitHub Desktop.
poo_1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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