I need one cell to load a file browser and open the file and another cell to plot the data. I cannot figure out how to get the 2nd cell to resolve the dependency on the first. Here is my code:
@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()