Unable to update div's text

Hi, I want to update the text in a div whenever the user changes the select.value. I’m a beginner and this isn’t working:

div=Div()

def update(new,old,attr):

  number = df[filter1]['number'].values[0]
   name = df[filter1]['name'].values[0]
   state = df[filter1]['state'].values[0]
   city = df[filter1]['city'].values[0]

div.update(

    text='<span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">Number: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         number + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">Name: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         name + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">State:</span> <span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         state + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">City: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         city + '</span>')

select.on_change(‘value’, update)

I even tried div.text=text like in the pretext example under Stocks

···

On Wednesday, April 25, 2018 at 3:15:48 PM UTC+5:30, socks95 wrote:

Hi, I want to update the text in a div whenever the user changes the select.value. I’m a beginner and this isn’t working:

div=Div()

def update(new,old,attr):

  number = df[filter1]['number'].values[0]
   name = df[filter1]['name'].values[0]
   state = df[filter1]['state'].values[0]
   city = df[filter1]['city'].values[0]

div.update(

    text='<span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">Number: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         number + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">Name: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         name + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">State:</span> <span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         state + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">City: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         city + '</span>')

select.on_change(‘value’, update)

Hi,

···

On Wed, Apr 25, 2018 at 11:45 AM, socks95 [email protected] wrote:

Hi, I want to update the text in a div whenever the user changes the select.value. I’m a beginner and this isn’t working:

div=Div()

def update(new,old,attr):

  number = df[filter1]['number'].values[0]
   name = df[filter1]['name'].values[0]
   state = df[filter1]['state'].values[0]
   city = df[filter1]['city'].values[0]

div.update(

    text='<span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">Number: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         number + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">Name: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         name + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">State:</span> <span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         state + '</span><br><span style="color:#5c5c3d;font-weight:bold; font-family:sans-serif; font-size:20px;">City: </span><span style="color:#5c5c3d;font-family:sans-serif;font-size:18px;">' +
         city + '</span>')

select.on_change(‘value’, update)

updating Div widget should work. Maybe you are running the code in a way that prevents event handling, e.g. generating standalone HTML files and attempting to use server events. A full code snippet will be needed to determine this.

Mateusz

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9728f34d-38bc-44c5-ae25-d960bc4afeea%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.