ztimesbtn = mo.ui.button(value = False, on_click=lambda value: not value, label="Show answer") ztimeslst = [mo.md( r""" Note that $\Bbb Z$ is not a group if we instead take the operation to be multiplication. In this example, we do have a set and operation. The operation is associative. In fact, there is even an identity element! It is """), ztimesbtn]
if ztimesbtn.value: mo.vstack(ztimeslst + [mo.md(r""" 1. """)]) else: mo.vstack(ztimeslst)
mo.md( r""" Just as with propositions: """ ) mo.callout(mo.md(r""" Two sentences, $\alpha$ and $\beta$, are **equivalent** """))
some_endpoint, some_endpoint_button
. Is it possible to implement it in one cell and/or avoid exposing button variable?@app.cell def _(config, private): admin_projects, admin_projects_button = private.request('GET', f'/admin/user/{config.user_id}/projects') admin_projects return admin_projects, admin_projects_button @app.cell def _(admin_projects, admin_projects_button): admin_projects.run(admin_projects_button) return
private.request()
returns (Request, mo.ui.run_button)
tuple:def request(self, method, url, *, json = None): return ( Request( method, f'{self.base_url}{url}', json=json, auth=self.auth, timeout=self.timeout, client=self, ), mo.ui.run_button(label='send'), )
Request.run()
uses mo.stop
and mo.status.spinner
:def run(self, button): mo.stop(not button.value, mo.md('press *send* ☝️')) with mo.status.spinner(subtitle='Loading...') as _spinner: response = self.send() return response
I'm looking for a way, any way, to highlight text in markdown in marimo, be able to right click or press a button, and add a comment to the highlighted text.
Is this possible in marimo?
@app.cell def _(mo, np): def handle_file_select(info): global img for f in info: img = np.load(f.path)["arr_0"] mo.ui.file_browser( initial_path="/mnt/notchpeak/transfer/new_worms/", on_change=handle_file_select, multiple=False, ) return img @app.cell def _(plt, img): if img is not None: plt.imshow(img) plt.tight_layout() plt.show()
My personal use case of Marimo so far has been to add notebooks to existing python codebases. This has been working really well since the notebook code can easily import my own code from outside the notebook. However, this doesn't seem compatible with the WASM export functionality at the moment. It seems like the WASM export functionality simply takes the code explicitly defined in the notebook and converts it to WASM via pyodide, but really, in my use case I'd need the export to pass all of my python source code to pyodide so that my notebook actually works.
Here's a minimal example:
# test_file.py def test_external_func() -> str: return "Some string from external func!"
# TestExternal.py import marimo __generated_with = "0.11.5" app = marimo.App(width="medium") @app.cell def _(): import marimo as mo return (mo,) @app.cell def _(): from test_file import test_external_func test_external_func() return (test_external_func,) if __name__ == "__main__": app.run()
The above notebook runs as expected when invoked via marimo edit TestExternal.py
:
But fails when run as a WASM export:
I know that there's been a recent addition to support loading data files into the WASM export. Is there any analogous way to include additional python code that I have locally (not just 3rd party libraries on pypi)?
ScriptConfigManager
always has filename set to the dir where I start marimo from