Get help from the marimo community

Home
Members
Georgios Varnavides
G
Georgios Varnavides
Offline, last seen 4 weeks ago
Joined November 25, 2024
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
11 comments
G
M
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?
5 comments
M
G
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?

Plain Text
import marimo as mo
import random
import time


Plain Text
get_seconds, set_seconds = mo.state(1)


Plain Text
def expensive_computation():
    seconds = get_seconds()
    time.sleep(seconds)
    set_seconds(random.randint(1,3))


Plain Text
infinite_loop = mo.ui.switch(
    False,
    label="infinite loop",
)
infinite_loop

Plain Text
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 comments
G
A
M