Reputation: 324
I am building an interface with a complex layout (e.g. multiple rows and columns) and I am trying to figure out a way of simplifying the access to a given object (be it a figure, widget etc) through its name. Let's take the following example:
import numpy as np
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
from bokeh.layouts import row, column
from bokeh.palettes import Category20
output_notebook()
x = np.random.randint(1,10,10)
y = np.random.randint(1,10,10)
p1 = figure()
p1.line(x,y)
p2 = figure()
p2.line(x,y)
p3 = figure(title='Me!', name='target')
p3.line(x,y)
c = column([p2,p3])
r = row(p1,c)
Is there a way to access p3
from the main layout object r
? I understand that for the provided example it is possible to use the variable name directly, but my app contains plots that are plotted in sub-functions. I could return the handle of each plot individually, but I was wondering if there was a method to search "multi-dimensional" (i.e. navigating through the children) layouts by properties. I tried using r.select(name='target')
, but this returns:
TypeError: select() got an unexpected keyword argument 'name'
Thanks!
Upvotes: 0
Views: 795
Reputation: 10652
The select
method accepts a dict of attributes to their values. In your case, try using dict(name='target')
.
Upvotes: 1