Example #1
0
 def stop_drag(self, _):
     if self.dragging:
         self.dragging = False
         dynamics.animate(
             Object.to_js(self.c),
             {"x": 160, "y": 160},
             {"type": dynamics.spring, "duration": 700, "friction": 280},
         )
Example #2
0
    def __init__(self):
        firebase_cfg = {
            "apiKey": "",
            "authDomain": "XYZ.firebaseapp.com",
            "databaseURL": "https://XYZ.firebaseio.com",
            "projectId": "XYZ",
            "storageBucket": "XYZ.appspot.com",
            "messagingSenderId": "",
            "appId": ""
        }

        self.firebase = js_lib("firebase")
        self.firebase.initializeApp(Object.to_js(firebase_cfg))

        self.database = self.firebase.firestore()
Example #3
0
 def save_todos(self, new, old):
     ToDoStorage.save(Object.to_py(new))
Example #4
0
 def subscribe(self, state, *args, **kwargs):
     object_storage["widgets"] = Object.to_py(state.widgets)
Example #5
0
 def test_dict(self):
     assert {"a": 1, "b": 2} == Object.from_js({"a": 1, "b": 2})
Example #6
0
 def test_array(self):
     with mock.patch.object(window.Array, "isArray", return_value=True):
         obj = Object.from_js(ArrayMock(1, 2, 3))
     assert [1, 2, 3] == obj
Example #7
0
    def test_vue(self):
        class This:
            def _isVue(self):
                return True

        assert isinstance(Object.from_js(This()), VueInstance)
Example #8
0
 def get_prop(self, item):
     from vue.bridge import Object
     props = Object.to_py(self.store.props(self.widget_id))
     return props.get(item, None)
Example #9
0
 def wrapper(*args, **kwargs):
     args = (javascript.this(), *args) if inject_vue_instance else args
     args = tuple(Object.from_js(arg) for arg in args)
     kwargs = {k: Object.from_js(v) for k, v in kwargs.items()}
     return Object.to_js(fn(*args, **kwargs))