How to use the persistent.document.Ex function in persistent

To help you get started, we’ve selected a few persistent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asrp / guitktk / examples / line_demo.py View on Github external
def rectangle1(topleft, botright):
    topleft = topleft["value"]
    bottomright = botright["value"]
    if (topleft >= bottomright).all():
        topleft, bottomright = bottomright, topleft
    topright = P(bottomright[0], topleft[1])
    bottomleft = P(topleft[0], bottomright[1])
    newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
                   p_topright=topright, p_botleft=bottomleft, children = [
        Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
        Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
        Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
        Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
    ])
    return newnode
github asrp / guitktk / examples / line_demo.py View on Github external
def grab_point():
    root = doc[doc["selection"]["root"]]
    for child, transform in root.dfs():
        if child.name == "point" and\
           collide(child, doc["editor.mouse_xy"], transform=transform, tolerance=8):
            doc["editor.drag_start"] = doc["editor.mouse_txy"]
            doc["editor.grabbed"] = child["id"]
            child.transforms["editor"] = Ex("('translate', `editor.mouse_txy - `editor.drag_start)", calc='on first read')
            return True
    return False
github asrp / guitktk / examples / line_demo.py View on Github external
def add_line_start():
    line = Node("line", p_start=doc["editor.mouse_txy"],
                p_end=doc["editor.mouse_txy"])
    doc["drawing"].append(Node("path", fill_color=None, children=[line]))
    doc["editor.drag_start"] = doc["editor.mouse_txy"]
    doc["editor.grabbed"] = line[1]["id"]
    line[1].transforms["editor"] = Ex("('translate', `editor.mouse_txy - `editor.drag_start)", calc='on first read')
github asrp / guitktk / examples / line_demo.py View on Github external
def rectangle1(topleft, botright):
    topleft = topleft["value"]
    bottomright = botright["value"]
    if (topleft >= bottomright).all():
        topleft, bottomright = bottomright, topleft
    topright = P(bottomright[0], topleft[1])
    bottomleft = P(topleft[0], bottomright[1])
    newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
                   p_topright=topright, p_botleft=bottomleft, children = [
        Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
        Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
        Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
        Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
    ])
    return newnode
github asrp / guitktk / examples / line_demo.py View on Github external
def rectangle1(topleft, botright):
    topleft = topleft["value"]
    bottomright = botright["value"]
    if (topleft >= bottomright).all():
        topleft, bottomright = bottomright, topleft
    topright = P(bottomright[0], topleft[1])
    bottomleft = P(topleft[0], bottomright[1])
    newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
                   p_topright=topright, p_botleft=bottomleft, children = [
        Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
        Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
        Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
        Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
    ])
    return newnode
github asrp / guitktk / examples / line_demo.py View on Github external
def add_visualize():
    assert(len(doc["selection"]) == 1)
    node = doc["selection.0.ref"]
    pdocument.scope['visualize_cb'] = visualize_cb
    doc['editor.callbacks.visualize'] = Ex('visualize_cb(`%s)' % node['id'])
github asrp / guitktk / examples / line_demo.py View on Github external
def rectangle1(topleft, botright):
    topleft = topleft["value"]
    bottomright = botright["value"]
    if (topleft >= bottomright).all():
        topleft, bottomright = bottomright, topleft
    topright = P(bottomright[0], topleft[1])
    bottomleft = P(topleft[0], bottomright[1])
    newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
                   p_topright=topright, p_botleft=bottomleft, children = [
        Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
        Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
        Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
        Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
    ])
    return newnode