Cold Sunshine
Cold Sunshine
SSolara
Created by Cold Sunshine on 7/26/2024 in #questions-issues
Finding size of image in figure
I have a solara component with a single figure, an image. But the image I have set is autoresizing and I would like to get the size of the image or maybe the container that holds it. Any ideas?
2 replies
SSolara
Created by Cold Sunshine on 7/15/2024 in #questions-issues
Wish to have Select components within Row arranged side-by-side.
Hello, Currently I have a side bar to store my controls. In my main window, I have a map. Rather than having the controls in the sidebar, I would like to have the components in my control section side by side across the top. But row stills stacks components on top of each other: import solara import solara.lab import datetime end_date = datetime.date.today() @solara.component def Page(): # Default date range date_range = solara.use_reactive((end_date - datetime.timedelta(days=-7), end_date))
with solara.AppBar(): with solara.AppBarTitle(): with solara.Row(style={"background-color": "transparent", "align-items": "center"}): solara.HTML(tag="img", attributes={"src": "https://picsum.photos/400/200", "style": "height: 40px"}) solara.Text("Cool Viewer") solara.v.Spacer() solara.Button(label="Quit", on_click = lambda: None)
with solara.Row(): Control(date_range)
with solara.Column(align = 'center'): View() @solara.component def Control(date_range): solara.Select('control 1', value = 'where', values = ['here', 'there', 'everywhere']) # Component to change to desired data range solara.lab.InputDateRange(date_range, sort=True) solara.Select('control 3', value = 'type', values = ['fast', 'slow', 'broken'])

@solara.component def View(): solara.Text(f'Map takes up whole area')
3 replies
SSolara
Created by Cold Sunshine on 7/12/2024 in #questions-issues
Gracefully exiting kernel when users closes UI page
How do you gracefully kill the current kernel when I close the UI web page? Currently, the kernel keeps running and I have to cntl-c to shut it down. From the documentation, it seems that I must shutdown the websocket. Please forgive my ignorance, but how does one go about doing that within solara? Or am I barking up the wrong tree?
6 replies
SSolara
Created by Cold Sunshine on 7/8/2024 in #questions-issues
InputDateRange question
UI/solara newbie question Greetings. I am trying to use the solara InputDateRange component but I am having a problem. I set the default values w/ use_reactive(), I have InputDateRange component to alter/update the date range, and a separate part that actually uses the values. My problem is that when I make a change of dates, my app fails before I can set the end date - i.e. only the first date gets set. Below is a toy version of my code: import solara import solara.lab import pendulum as pdl end_date = pdl.Date(2023, 8, 8) @solara.component def Page(): # Default date range date_range = solara.use_reactive(tuple([end_date.subtract(days=7), end_date]))
with solara.AppBar(): with solara.AppBarTitle(): with solara.Row(style={"background-color": "transparent", "align-items": "center"}): solara.HTML(tag="img", attributes={"src": "https://picsum.photos/400/200", "style": "height: 40px"}) solara.Text("Cool Viewer") solara.v.Spacer() solara.Button(label="Quit", on_click = lambda: None)
with solara.Sidebar(): Control(date_range)
with solara.Column(align = 'center'): View(date_range) @solara.component def Control(date_range): # Component to change to desired data range solara.lab.InputDateRange(date_range, sort=True)

@solara.component def View(date_range): # where the date range actually gets used start_date = date_range.value[0] end_date = date_range.value[1] print(start_date, end_date) ~~~~~~~~ This fails with the following error: end_date = date_range.value[1] ~~~~^^^ IndexError: tuple index out of range What am I doing wrong? Thanks
13 replies
SSolara
Created by Cold Sunshine on 7/2/2024 in #questions-issues
Using plotly.express to create scatterplot_mapbox, map displays but animation does not work
I am creating a map with scatterplot_mapbox, I can create a map with my desired points plotted. However, animation does not work (buttons appear but do not function). I have run the exact same code in a jupyter notebook and the animation works. Any tips on getting the animation working? Code: fig = px.scatter_mapbox(plot_data, lat='lat', lon='lon', #z='Magnitude', center=dict(lat=start_lat, lon=start_lon), zoom=1, width = 1200, height = 600, animation_frame='datetime', mapbox_style="open-street-map", # category_orders={ # 'Date':list(plot_data['datetime']) # }, text = 'm', color = 'm', ) #fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0}) #fig.show() solara.FigurePlotly(fig) Thank you for reading.
2 replies