icecream4
icecream4
SSolara
Created by icecream4 on 5/14/2024 in #questions-issues
Run JS script
Thanks for the advice. I tried to do it, but nothing works so far 🙂 Perhaps one of the problems is that I run everything through the jupyter notebook. And therefore the decorator cannot find the file "No such file or directory: '/tmp/ipykernel_12567/tofront.vue'". I entered the full address, no errors were displayed, but nothing was rendered at all
4 replies
SSolara
Created by icecream4 on 4/25/2024 in #questions-issues
Initializing function.
Thank you very much. Yes, it seems to be working now, I'll go check everything 🙂
9 replies
SSolara
Created by icecream4 on 4/25/2024 in #questions-issues
Initializing function.
Hmm, thank you. I tried to rewrite my code here. And it turns out that my error is slightly different:
text = solara.reactive(None)

a_values = solara.reactive(None)
a_value = solara.reactive(None)

b_values = solara.reactive(None)
b_value = solara.reactive(None)

c_values = solara.reactive(None)
d_value = solara.reactive(None)
e_value = solara.reactive(None)
f_value = solara.reactive(None)
g_value = solara.reactive(None)

res_value = solara.reactive(None)
btn = solara.reactive(False)

def on_click():
res_value.value = a_value.value + b_value.value
btn.value = True

def collect_data():
return {
"text": "aaa",
"a": {"a":"a", "b":"b", "c":"c"},
"b": {"d":"d", "e":"e", "f":"f"},
"c": "c",
"d": "d",
"e": "e",
"f": "f",
"g": "g",
}


def f2(data):
return (data["d"], data["e"], data["f"], data["g"])


def start():
data = collect_data()

text.value = f"Default text: {data['text']}"

solara.InputText(label="Text:", value=text, continuous_update=True)

a_values.value = list(data["a"].keys())
a_value.value = a_values.value[0]

b_values.value = list(data["b"].keys())
b_value.value = b_values.value[0]

c_values.value = {i:solara.use_reactive(False) for i in data["b"]}

(d_value.value, e_value.value, f_value.value, g_value.value) = f2(data)


@solara.component
def Page():
solara.use_effect(start, dependencies=[])

solara.Select(label="Select:", value=a_value, values=a_values.value)
solara.Select(label="Select:", value=b_value, values=b_values.value)

solara.Markdown("Switch:")
toggle = [
solara.Switch(label=label, value=c_values.value[label])
for label in c_values.value]

solara.Button(label="CLICK", on_click=on_click)

if btn.value:
solara.Markdown(res_value.value)

Page()
text = solara.reactive(None)

a_values = solara.reactive(None)
a_value = solara.reactive(None)

b_values = solara.reactive(None)
b_value = solara.reactive(None)

c_values = solara.reactive(None)
d_value = solara.reactive(None)
e_value = solara.reactive(None)
f_value = solara.reactive(None)
g_value = solara.reactive(None)

res_value = solara.reactive(None)
btn = solara.reactive(False)

def on_click():
res_value.value = a_value.value + b_value.value
btn.value = True

def collect_data():
return {
"text": "aaa",
"a": {"a":"a", "b":"b", "c":"c"},
"b": {"d":"d", "e":"e", "f":"f"},
"c": "c",
"d": "d",
"e": "e",
"f": "f",
"g": "g",
}


def f2(data):
return (data["d"], data["e"], data["f"], data["g"])


def start():
data = collect_data()

text.value = f"Default text: {data['text']}"

solara.InputText(label="Text:", value=text, continuous_update=True)

a_values.value = list(data["a"].keys())
a_value.value = a_values.value[0]

b_values.value = list(data["b"].keys())
b_value.value = b_values.value[0]

c_values.value = {i:solara.use_reactive(False) for i in data["b"]}

(d_value.value, e_value.value, f_value.value, g_value.value) = f2(data)


@solara.component
def Page():
solara.use_effect(start, dependencies=[])

solara.Select(label="Select:", value=a_value, values=a_values.value)
solara.Select(label="Select:", value=b_value, values=b_values.value)

solara.Markdown("Switch:")
toggle = [
solara.Switch(label=label, value=c_values.value[label])
for label in c_values.value]

solara.Button(label="CLICK", on_click=on_click)

if btn.value:
solara.Markdown(res_value.value)

Page()
Can you please take a look at it, it seems like I'm trying to use the Switch incorrectly.
9 replies
SSolara
Created by icecream4 on 4/25/2024 in #questions-issues
Initializing function.
Yes it does, but for some reason it didn't work out for me. I made this code:
def start():
...

@solara.component
def Page():
solara.use_effect(start)
...
def start():
...

@solara.component
def Page():
solara.use_effect(start)
...
It seems that the "start" function is not called because no one reactive variable is filled.
9 replies
SSolara
Created by icecream4 on 4/25/2024 in #questions-issues
Initializing function.
Right now my code looks like this. And I don’t know how to separate initialization using data into a separate function.
import f1, а2

text = solara.reactive(None)

a_values = solara.reactive(None)
a_value = solara.reactive(None)

b_values = solara.reactive(None)
b_value = solara.reactive(None)

c_value = solara.reactive(None)
d_value = solara.reactive(None)
e_value = solara.reactive(None)
f_value = solara.reactive(None)
g_value = solara.reactive(None)

def on_click():
c_value = f1(a_value, b_value)
...

def collect_data(query_string):
# Parsing strings and get data from database
...


@solara.component
def Page():
query_string = solara.use_router().search

data = collect_data(query_string)

text.value = f"Default text: {data["text"]}"

solara.InputText(label="Text:", value=text, continuous_update=True)

a_values.value = list(data["a"].keys())
a_value.value = a_values.value[0]

b_values.value = list(data["b"].keys())
b_value.value = b_values.value[0]

(d_value.value, e_value.value, f_value.value, g_value.value) = f2(data)

solara.Select(label="Select:", value=a_value, values=a_values.value)
solara.Select(label="Select:", value=b_value, values=b_values.value)

solara.Button(label="CLICK", on_click=on_click)
...
import f1, а2

text = solara.reactive(None)

a_values = solara.reactive(None)
a_value = solara.reactive(None)

b_values = solara.reactive(None)
b_value = solara.reactive(None)

c_value = solara.reactive(None)
d_value = solara.reactive(None)
e_value = solara.reactive(None)
f_value = solara.reactive(None)
g_value = solara.reactive(None)

def on_click():
c_value = f1(a_value, b_value)
...

def collect_data(query_string):
# Parsing strings and get data from database
...


@solara.component
def Page():
query_string = solara.use_router().search

data = collect_data(query_string)

text.value = f"Default text: {data["text"]}"

solara.InputText(label="Text:", value=text, continuous_update=True)

a_values.value = list(data["a"].keys())
a_value.value = a_values.value[0]

b_values.value = list(data["b"].keys())
b_value.value = b_values.value[0]

(d_value.value, e_value.value, f_value.value, g_value.value) = f2(data)

solara.Select(label="Select:", value=a_value, values=a_values.value)
solara.Select(label="Select:", value=b_value, values=b_values.value)

solara.Button(label="CLICK", on_click=on_click)
...
9 replies
SSolara
Created by icecream4 on 4/18/2024 in #questions-issues
Image Select
Wow, awesome! Thanks a lot. This is really what I need 🔥
4 replies