Comments (2)
Thanks for reporting, and for the reproduction.
On >= 0.5.2, the handler is being called, but I'm also seeing a bug in which the batched switch UI element is resetting after being clicked. Do you also see that?
Screencast.from.05-21-2024.03.15.14.PM.webm
from marimo.
@mrdobalina2k : Thanks for reporting, I have a fix out in #1439.
By the way, I figured out the flickering/resetting of the slider. It's because your on_change handler calls get_state()
. To fix that, use the function API for set_state
, like below:
import marimo
__generated_with = "0.6.0"
app = marimo.App()
@app.cell
def __():
import marimo as mo
return mo,
@app.cell
def __(mo):
get_state, set_state = mo.state(0)
return get_state, set_state
@app.cell
def __(mo, set_state):
def on_change(value):
# don't call `get_state` here!
set_state(lambda v: v+1)
switch = mo.ui.switch(value=True, on_change=on_change)
return on_change, switch
@app.cell
def __(switch):
switch
return
@app.cell
def __(mo, switch):
def wrap_switch(switch):
wrapped = mo.md("""
wrapped switch
{switch}""").batch(switch=switch)
return wrapped
wrapped_switch = wrap_switch(switch)
wrapped_switch
return wrap_switch, wrapped_switch
@app.cell
def __(wrapped_switch):
wrapped_switch._elements["switch"]._id
return
@app.cell
def __(wrapped_switch):
wrapped_switch.value
return
@app.cell
def __():
from marimo._runtime.context import get_context
get_context().ui_element_registry._objects
return get_context,
@app.cell
def __(get_state):
get_state()
return
if __name__ == "__main__":
app.run()
from marimo.
Related Issues (20)
- Plots return 404 when using --base-url option in docker container HOT 1
- DataFrameLike False Positive When __getattr__ Presents HOT 1
- ui.dataframe with Ibis support HOT 1
- marimo edit stops working when left open for multiple days (fd limit too low) HOT 1
- Multiple cells actions HOT 1
- Publish VSCode extension to Open VSX HOT 3
- h4 - h6 missing from TOC panel HOT 2
- Better tracebacks when running as a script
- WebSocketDisconnect (kernel not found) when using marimo edit HOT 3
- marimo.app_meta.theme HOT 3
- Hard to find notebooks in marimo homepage HOT 1
- Name of marimo notebook tab title in browser should just be the name of the file (not include filepath) HOT 1
- Can't find new marimo notebook in marimo homepage
- Update Documentation for mo.tabs to mo.ui.tabs to Remove Deprecation Warning (in documentation)
- Interpolation and LaTeX in markdown HOT 2
- Browser incompatibility for dev setup HOT 3
- Multiple tabs in a single notebook HOT 4
- Support custom base URL paths, redux (for `marimo edit`) HOT 4
- marimo server becomes unusable when several notebooks are open HOT 5
- The "Run all modified cells" button is always yellow HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marimo.