Example #1
0
op = ctx.op = operator()
c_data = ctx.c_data = op.value.cell()
c_data.set(4)
c_output = ctx.c_output = op.output.cell()
c_code = op.cont.code.cell()

ctx.equilibrate()
print("VALUE", c_data.data, "'" + c_code.data + "'", c_output.data)

c_data.set(5)
c_code.set("return value*3")

ctx.equilibrate()
print("VALUE", c_data.data, "'" + c_code.data + "'", c_output.data)

ed1 = ctx.ed1 = edit(c_data)
ed2 = ctx.ed2 = display(c_output)
ed1.title.cell().set("Input")
ed2.title.cell().set("Output")

ted1 = ctx.ted1 = edit(c_code)
ted1.title.cell().set("Formula editor")

meta_ted = ctx.meta_ted = edit(ted1.rc.code_start.cell())
meta_ted.title.cell().set("Meta-editor")

import os
ctx.tofile(os.path.splitext(__file__)[0] + ".seamless", backup=False)
ctx.equilibrate()
Example #2
0
    code = code[:-2]
    t = transformer(params)
    t.code.cell().set(code)
    return t

ctx = context()
ctx.c1 = cell("int").set(1)
ctx.c2 = cell("int").set(2)
ctx.t1 = add_all(ctx.c1)
ctx.t2 = add_all(ctx.c2)
ctx.t1.inp1.cell().set(10)
ctx.t2.inp1.cell().set(20)
ctx.t2.inp2.cell().set(30)

from seamless.lib.gui.basic_editor import edit
ctx.ed1 = edit(ctx.t1.outp.cell())
ctx.ed2 = edit(ctx.t2.outp.cell())

code2 = ctx.t1.macro.macro.code.replace('"inp"', '"INP"')
ctx.t1.macro.macro.update_code(code2)
print(ctx.t2.INP2)
ctx.t1.INP1.cell().set(10)
ctx.t2.INP1.cell().set(20)
ctx.t2.INP2.cell().set(30)
print(ctx.t2.outp.cell().value)

import os
ctx.tofile(os.path.splitext(__file__)[0] + ".seamless", backup=False)
#ctx.destroy()
#ctx = seamless.fromfile(os.path.splitext(__file__)[0] + ".seamless")
#ctx.c2.set(1)
Example #3
0
}
"""

ctx.silk_model = cell(("text", "code", "silk"))
ctx.silk_model.set(silk_model)
ctx.registrar.silk.register(ctx.silk_model)

ctx.n = cell("int").set(3)
ctx.mode = cell("str").set("standard")
ctx.value = cell("text")
ctx.cons = construct_silk_model(ctx.mode)
ctx.cons.value.connect(ctx.value)
ctx._validate_path()

ctx.silk_model.set(silk_model2)
#time.sleep(0.001)
ctx.equilibrate()
print(ctx.value.data)

ctx.ed_silk_model = edit(ctx.silk_model,"Silk model")
ctx._validate_path()

ctx.d_value = display(ctx.value,"Result")
ctx._validate_path()

ctx.mode.set("array")
ctx.n.connect(ctx.cons.N)

import os
ctx.tofile(os.path.splitext(__file__)[0] + ".seamless", backup=False)
Example #4
0
from seamless import context
from seamless.lib.filelink import link
from seamless.lib.itransformer import itransformer
from seamless.lib.gui.basic_display import display
from seamless.lib.gui.basic_editor import edit
ctx = context()
ctx.itf = itransformer({
    "i": {"pin": "input", "dtype": "int"},
    "outp": {"pin": "output", "dtype": "json"},
})
link(ctx.itf.code.cell(), ".", "cell-test-itransformer.ipy")
link(ctx.itf.rc.code_start.cell())
display(ctx.itf.outp.cell())
edit(ctx.itf.i.cell().set(100))
Example #5
0
op = ctx.op = operator()
c_data = ctx.c_data = op.value.cell()
c_data.set(4)
c_output = ctx.c_output = op.output.cell()
c_code = op.cont.code.cell()

ctx.equilibrate()
print("VALUE", c_data.data, "'" + c_code.data + "'", c_output.data)

c_data.set(5)
c_code.set("return value*3")

ctx.equilibrate()
print("VALUE", c_data.data, "'" + c_code.data + "'", c_output.data)

ed1 = ctx.ed1 = edit(c_data)
ed2 = ctx.ed2 = display(c_output)
ed1.title.cell().set("Input")
ed2.title.cell().set("Output")

ted1 = ctx.ted1 = edit(c_code)
ted1.title.cell().set("Formula editor")

meta_ted = ctx.meta_ted = edit(ted1.rc.code_start.cell())
meta_ted.title.cell().set("Meta-editor")

import os
ctx.tofile(os.path.splitext(__file__)[0] + ".seamless", backup=False)
ctx.equilibrate()
Example #6
0
tf = ctx.get_func_html = transformer({
    "outp": {
        "pin": "output",
        "dtype": ("text", "html")
    },
})
tf.code.cell().set("return func_html")
reg.connect("func_html", tf)
browse(tf.outp.cell())

tf = ctx.run_func = transformer({
    "i": {
        "pin": "input",
        "dtype": "int"
    },
    "outp": {
        "pin": "output",
        "dtype": "float"
    },
})
reg.connect("func", tf)
tf.code.cell().set("""
import time
start = time.time()
result = func(i)
print("func(%d) executed in %s seconds" % (i, time.time()-start))
return result
""")
display(tf.outp.cell(), "outp")
edit(tf.i.cell().set(100), "i")
Example #7
0
}
"""

ctx.silk_model = cell(("text", "code", "silk"))
ctx.silk_model.set(silk_model)
ctx.registrar.silk.register(ctx.silk_model)

ctx.n = cell("int").set(3)
ctx.mode = cell("str").set("standard")
ctx.value = cell("text")
ctx.cons = construct_silk_model(ctx.mode)
ctx.cons.value.connect(ctx.value)
ctx._validate_path()

ctx.silk_model.set(silk_model2)
#time.sleep(0.001)
ctx.equilibrate()
print(ctx.value.data)

ctx.ed_silk_model = edit(ctx.silk_model, "Silk model")
ctx._validate_path()

ctx.d_value = display(ctx.value, "Result")
ctx._validate_path()

ctx.mode.set("array")
ctx.n.connect(ctx.cons.N)

import os
ctx.tofile(os.path.splitext(__file__)[0] + ".seamless", backup=False)
Example #8
0
from seamless.lib.gui.basic_editor import edit

import tempfile, shutil

ctx = context()

#tmpdir = tempfile.mkdtemp()
tmpdir = tempfile.gettempdir()

msg = "Edit {0}: directory {1}, file {2}"

ctx.number = cell("int").set(1)
file_number = "number.txt"
title_number = "Number"
ctx.fl_number = link(ctx.number, tmpdir, file_number)
ctx.ed_number = edit(ctx.number, title_number)
print(msg.format(title_number, tmpdir, file_number))

ctx.text = cell("text").set("Lorem ipsum")
file_text = "text.txt"
title_text = "Text"
ctx.fl_text = link(ctx.text, tmpdir, file_text)
ctx.ed_text = edit(ctx.text, title_text)
print(msg.format(title_text, tmpdir, file_text))


### #shutil.rmtree(tmpdir) #TODO: make exit hook

import os
ctx.tofile(os.path.splitext(__file__)[0] + ".seamless", backup=False)