Georgios Varnavides
Georgios Varnavides
Mmarimo
Created by Georgios Varnavides on 8/21/2024 in #help-support
Marimo Islands dark mode?
Having trouble getting marimo islands to work in dark mode. The src code in useTheme.ts suggests the way to achieve this is using a "dark-mode" class in the island body, or specifying data-theme=dark in the island tag, but I haven't had any luck with either of those methods.. Any other alternatives? styling with global css seems futile too, since it's inside a shadow DOM
12 replies
Mmarimo
Created by Georgios Varnavides on 7/18/2024 in #help-support
Programmatic way to detect theme (light/dark mode)?
I reckon this might not be possible, since theme appears to be a frontend property, but is there a way to detect whether the app is displayed in light/dark mode from the python side?
6 replies
Mmarimo
Created by Georgios Varnavides on 7/13/2024 in #help-support
Recommended way for self-triggering computation / semi-infinite loop?
Is there a recommended way to trigger a cell (which mutates state) to re-run after it's done -- under some conditions? I was under the impression the following combination of switch/stop would do the trick, but it doesn't seem to be able to escape the infinite loop?
import marimo as mo
import random
import time
import marimo as mo
import random
import time
get_seconds, set_seconds = mo.state(1)
get_seconds, set_seconds = mo.state(1)
def expensive_computation():
seconds = get_seconds()
time.sleep(seconds)
set_seconds(random.randint(1,3))
def expensive_computation():
seconds = get_seconds()
time.sleep(seconds)
set_seconds(random.randint(1,3))
infinite_loop = mo.ui.switch(
False,
label="infinite loop",
)
infinite_loop
infinite_loop = mo.ui.switch(
False,
label="infinite loop",
)
infinite_loop
mo.stop(not infinite_loop.value)
expensive_computation()
mo.stop(not infinite_loop.value)
expensive_computation()
My actual use-case (https://marimo.io/p/@gvarnavides/iterative-ptychography) is less contrived. Essentially I'd like to plot the output of an iterated map at every iteration. Right now, I'm doing it with mo.ui.refresh - which works well, but I'd like a "as quick as possible" update instead of fixed time-increments (since the computation time varies with batch_size).
13 replies