☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Dictionary of ColumnDataSource in bokeh-server

Community Support
sologub10
sologub10

Hello,

I’m trying to create an app on bokeh-server, where I need

to create a dict (or list) of ColumnDataSource instances.

#Data sources

sData = dict()

for Id in Data:

sData[Id] = Instance(ColumnDataSource)

``

I’ve used a https://github.com/bokeh/bokeh/tree/master/examples/app/stock_applet example as a basis.

After class initialization the make_source() method is executed.

Then I’m trying to catch a selection event:

def setup_events(self):

super(my_app, self).setup_events()

for Id in self.Data:

if self.sData[Id]:

self.sData[Id].on_change(‘selected’, self, ‘selection_change’)

``

But there is an error:

AttributeError: ‘Instance’ object has no attribute ‘on_change’

Is it possible to trig events from dictionary of ColumnDataSource and what I’m doing wrong?

⌁   Link to post
Bryan
Bryan

You will need to provide more context. "Instance" is a Bokeh models property, and is typically only used and useful as a class attribute, but it looks like you are trying to use it outside a class definition here? If not, and you are trying to define a dict of ColumnDataSources on an app class, you will need to use the Bokeh Dict property, instead of the standard python dict.

class StockApp(VBox):

    sData = Dict(String, ColumnDataSource) # or whatever key property type you want

It has to be Bokeh properties "all the way through" so that the model can properly validate and serialize itself.

Bryan

···

On Aug 24, 2015, at 4:08 PM, sologub10@gmail.com wrote:

Hello,

I'm trying to create an app on bokeh-server, where I need
to create a dict (or list) of ColumnDataSource instances.
#Data sources
    sData = dict()
    for Id in Data:
        sData[Id] = Instance(ColumnDataSource)

I've used a https://github.com/bokeh/bokeh/tree/master/examples/app/stock_applet example as a basis.
After class initialization the make_source() method is executed.

Then I'm trying to catch a selection event:
def setup_events(self):
    super(my_app, self).setup_events()
    for Id in self.Data:
       if self.sData[Id]:
           self.sData[Id].on_change('selected', self, 'selection_change')

But there is an error:
AttributeError: 'Instance' object has no attribute 'on_change'

Is it possible to trig events from dictionary of ColumnDataSource and what I'm doing wrong?

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/874b00c4-2895-4d78-b68e-0fd6448ac4c9%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled