-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the panel preloader solution (progress bar, etc.)? #487
Comments
Similar/simpler question - how does someone add a javascript callback to a panel Button? Bokeh solution is straight forward: from bokeh.models.widgets import Button
from bokeh.io import show
from bokeh.models import CustomJS
button = Button(callback=CustomJS(code='console.log("Hello browser")'))
show(button) I cannot figure out the |
Hi all, |
We have a hacky solution that falls outside of what we could figure out with panel. Since our panel app is sitting within a larger flask app, we had a but more freedom but basically we used Javascript to do it. We did this:
|
This PR should solve your primary problem : #665
Else something like that could do the trick: import panel as pn
pn.extension()
cd_code ="""
if (!target.remaining_time){
target.margin = [5, 10]
target.width = 200
target.remaining_time = 1000*10 //10s
target.text = ((target.remaining_time)/1000.).toString() + ' s remaining'
var x = setInterval(() => {
if(target.remaining_time > 1000) {
target.remaining_time = target.remaining_time - 1000
target.text = ((target.remaining_time)/1000.).toString() + ' s remaining'
} else {
target.text = ''
target.margin = [0, 0, 0, 0]
target.width = 0
target.remaining_time = 0
clearInterval(x)
}
}, 1000);
}
"""
b = pn.widgets.Button(name='Click me')
t = pn.widgets.StaticText(value='', width=0, width_policy='fixed', margin=0)
b.jslink(t,code={'clicks':cd_code})
pn.Row(b, t) |
Thank you for the jslink solution, @xavArtley. This works nicely for my use case. Great work! |
We are using Panel to serve data retrieved in real-time from a database. The user clicks on a Run button and a query gets executed against a database and returns results so it can be displayed in the browser. (For our company's internal use).
Some queries can take several seconds to run. we would like to first display a spinner or a progress bar, or at least a "please wait" html element when someone clicks on the button, which disappears once the page is updated with a table of the data (or other visualization).
So far we cannot figure out the best way to do this. However, it seems so elementary I'm sure there must be a Panel best practice. If not, perhaps one should be developed?
I'll give you our code structure so you can see how we're trying to fit it in:
One simple feature that could be used to solve this kind of stuff might be to allow the programmer to add an
id
oronclick
or other arbitrary items to widgets and other panel elements. If I can add anid="execute_query"
oronclick="showSpinner()"
to the run button then I could have some javascript on the client side that would handle it.I'm not a web developer so I don't know if that would actually work or if its the right way to do things, but in my tiny amount of experience other frameworks like Ruby on Rails and Phoenix allow you to add arbitrary items into your HTML tags, which I've found useful.
The text was updated successfully, but these errors were encountered: