Problems inheriting from HBox/Row in v0.12.0

Hi,

I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.

Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)

from bokeh.models.layouts import HBox
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class HBoxTest(HBox):

button = Instance(Button)
slider = Instance(Slider)

def __init__(self):

    self.__view_model__ = 'HBox'
    self.__subtype__ = 'HBoxTest'

    super(HBoxTest,self).__init__()

    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(HBoxTest())

…but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str

As it looks like Row replaces HBox in 0.12.0 I then tried the following…

from bokeh.models.layouts import Row
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class RowTest(Row):

button = Instance(Button)
slider = Instance(Slider)

def __init__(self):

    self.__view_model__ = 'Row'
    self.__subtype__ = 'RowTest'

    super(RowTest,self).__init__()

    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(RowTest())

No error this time but nothing appears in the browser.

I’m sure I’m getting something basic wrong but can’t work out what it is. Help!

Thanks,
Marcus.

Hi Marcus,

There was extensive work on layout in 0.12 and a few changes as well. We tried both to minimize these and also to anticipate as many as we could and note them in the Migration Guide, but I will admit subclassing is one that escaped my attention. Long story short: There are new fundamental models Row and Column, and those are what you would want to subclass from. We kept HBox and VBox as functions for convenient aliases to create Row and Column, and to prevent breaking "standard usage" but as I said subclassing them is simply something it did not occur to me that people would do. My apologies for any inconvenience.

Thanks,

Bryan

···

On Jul 5, 2016, at 8:19 AM, Marcus Donnelly <[email protected]> wrote:

Hi,

I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.

Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)

from bokeh.models.layouts import HBox
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class HBoxTest(HBox):

    button = Instance(Button)
    slider = Instance(Slider)

    def __init__(self):

        self.__view_model__ = 'HBox'
        self.__subtype__ = 'HBoxTest'

        super(HBoxTest,self).__init__()

        self.button = Button(label='Click')
        self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
        self.children.append(self.button)
        self.children.append(self.slider)

curdoc().add_root(HBoxTest())

..but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str

As it looks like Row replaces HBox in 0.12.0 I then tried the following...

from bokeh.models.layouts import Row
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class RowTest(Row):

    button = Instance(Button)
    slider = Instance(Slider)

    def __init__(self):

        self.__view_model__ = 'Row'
        self.__subtype__ = 'RowTest'

        super(RowTest,self).__init__()

        self.button = Button(label='Click')
        self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
        self.children.append(self.button)
        self.children.append(self.slider)

curdoc().add_root(RowTest())

No error this time but nothing appears in the browser.

I'm sure I'm getting something basic wrong but can't work out what it is. Help!

Thanks,
Marcus.

--
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/f48bf659-418e-4ac1-ba3d-dd1284396ac8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Also for completeness: the analogue to "VBoxForm" is now "WidgetBox"

Thanks,

Bryan

···

On Jul 5, 2016, at 8:34 AM, Bryan Van de Ven <[email protected]> wrote:

Hi Marcus,

There was extensive work on layout in 0.12 and a few changes as well. We tried both to minimize these and also to anticipate as many as we could and note them in the Migration Guide, but I will admit subclassing is one that escaped my attention. Long story short: There are new fundamental models Row and Column, and those are what you would want to subclass from. We kept HBox and VBox as functions for convenient aliases to create Row and Column, and to prevent breaking "standard usage" but as I said subclassing them is simply something it did not occur to me that people would do. My apologies for any inconvenience.

Thanks,

Bryan

On Jul 5, 2016, at 8:19 AM, Marcus Donnelly <[email protected]> wrote:

Hi,

I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.

Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)

from bokeh.models.layouts import HBox
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class HBoxTest(HBox):

   button = Instance(Button)
   slider = Instance(Slider)

   def __init__(self):

       self.__view_model__ = 'HBox'
       self.__subtype__ = 'HBoxTest'

       super(HBoxTest,self).__init__()

       self.button = Button(label='Click')
       self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
       self.children.append(self.button)
       self.children.append(self.slider)

curdoc().add_root(HBoxTest())

..but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str

As it looks like Row replaces HBox in 0.12.0 I then tried the following...

from bokeh.models.layouts import Row
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class RowTest(Row):

   button = Instance(Button)
   slider = Instance(Slider)

   def __init__(self):

       self.__view_model__ = 'Row'
       self.__subtype__ = 'RowTest'

       super(RowTest,self).__init__()

       self.button = Button(label='Click')
       self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
       self.children.append(self.button)
       self.children.append(self.slider)

curdoc().add_root(RowTest())

No error this time but nothing appears in the browser.

I'm sure I'm getting something basic wrong but can't work out what it is. Help!

Thanks,
Marcus.

--
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/f48bf659-418e-4ac1-ba3d-dd1284396ac8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thanks for the quick response. Do you know if/when (I’m really hoping when rather than if!) subclassing support is likely to be re-introduced? It’s quite an issue for me as I’ve created some specialised classes, e.g. a heatmap with automatically updating colourbar (like the example here - the post on Jan 17th is from me). I might be able to find another way around it but it would need significant rework. I can stick with 0.11.1 for the meantime but would like to know if it will be reintroduced.

Thanks,
Marcus.

···

On Tuesday, July 5, 2016 at 2:34:32 PM UTC+1, Bryan Van de ven wrote:

Hi Marcus,

There was extensive work on layout in 0.12 and a few changes as well. We tried both to minimize these and also to anticipate as many as we could and note them in the Migration Guide, but I will admit subclassing is one that escaped my attention. Long story short: There are new fundamental models Row and Column, and those are what you would want to subclass from. We kept HBox and VBox as functions for convenient aliases to create Row and Column, and to prevent breaking “standard usage” but as I said subclassing them is simply something it did not occur to me that people would do. My apologies for any inconvenience.

Thanks,

Bryan

On Jul 5, 2016, at 8:19 AM, Marcus Donnelly [email protected] wrote:

Hi,

I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.

Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)

from bokeh.models.layouts import HBox

from bokeh.core.properties import Instance

from bokeh.io import curdoc

from bokeh.models.widgets import Button, Slider

class HBoxTest(HBox):

button = Instance(Button)
slider = Instance(Slider)
def __init__(self):
    self.__view_model__ = 'HBox'
    self.__subtype__ = 'HBoxTest'
    super(HBoxTest,self).__init__()
    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(HBoxTest())

…but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str

As it looks like Row replaces HBox in 0.12.0 I then tried the following…

from bokeh.models.layouts import Row

from bokeh.core.properties import Instance

from bokeh.io import curdoc

from bokeh.models.widgets import Button, Slider

class RowTest(Row):

button = Instance(Button)
slider = Instance(Slider)
def __init__(self):
    self.__view_model__ = 'Row'
    self.__subtype__ = 'RowTest'
    super(RowTest,self).__init__()
    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(RowTest())

No error this time but nothing appears in the browser.

I’m sure I’m getting something basic wrong but can’t work out what it is. Help!

Thanks,

Marcus.


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/f48bf659-418e-4ac1-ba3d-dd1284396ac8%40continuum.io.

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

Marcus,

As I mentioned, the new analogous classes are `bokeh.models.layouts.Row` and `bokeh.models.layouts.Column`. The most direct solution is to change your code to subclass from those, instead of from HBox an VBox. If there is an issue with updating all of your own code this way, you might have success by making and using your own shims:

  class HBox(Row): pass

  class VBox(Column): pass

However, I have not tried this to know it would work for certain. In any case I don't expect there will ever be HBox/VBox classes ever again, only Row and Column.

Thanks,

Bryan

···

On Jul 5, 2016, at 9:12 AM, Marcus Donnelly <[email protected]> wrote:

Hi Bryan,

Thanks for the quick response. Do you know if/when (I'm really hoping when rather than if!) subclassing support is likely to be re-introduced? It's quite an issue for me as I've created some specialised classes, e.g. a heatmap with automatically updating colourbar (like the example here - the post on Jan 17th is from me). I might be able to find another way around it but it would need significant rework. I can stick with 0.11.1 for the meantime but would like to know if it will be reintroduced.

Thanks,
Marcus.

On Tuesday, July 5, 2016 at 2:34:32 PM UTC+1, Bryan Van de ven wrote:
Hi Marcus,

There was extensive work on layout in 0.12 and a few changes as well. We tried both to minimize these and also to anticipate as many as we could and note them in the Migration Guide, but I will admit subclassing is one that escaped my attention. Long story short: There are new fundamental models Row and Column, and those are what you would want to subclass from. We kept HBox and VBox as functions for convenient aliases to create Row and Column, and to prevent breaking "standard usage" but as I said subclassing them is simply something it did not occur to me that people would do. My apologies for any inconvenience.

Thanks,

Bryan

> On Jul 5, 2016, at 8:19 AM, Marcus Donnelly <[email protected]> wrote:
>
> Hi,
>
> I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.
>
> Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)
>
> from bokeh.models.layouts import HBox
> from bokeh.core.properties import Instance
> from bokeh.io import curdoc
> from bokeh.models.widgets import Button, Slider
>
> class HBoxTest(HBox):
>
> button = Instance(Button)
> slider = Instance(Slider)
>
> def __init__(self):
>
> self.__view_model__ = 'HBox'
> self.__subtype__ = 'HBoxTest'
>
> super(HBoxTest,self).__init__()
>
> self.button = Button(label='Click')
> self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
> self.children.append(self.button)
> self.children.append(self.slider)
>
> curdoc().add_root(HBoxTest())
>
> ..but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str
>
> As it looks like Row replaces HBox in 0.12.0 I then tried the following...
>
> from bokeh.models.layouts import Row
> from bokeh.core.properties import Instance
> from bokeh.io import curdoc
> from bokeh.models.widgets import Button, Slider
>
> class RowTest(Row):
>
> button = Instance(Button)
> slider = Instance(Slider)
>
> def __init__(self):
>
> self.__view_model__ = 'Row'
> self.__subtype__ = 'RowTest'
>
> super(RowTest,self).__init__()
>
> self.button = Button(label='Click')
> self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
> self.children.append(self.button)
> self.children.append(self.slider)
>
> curdoc().add_root(RowTest())
>
> No error this time but nothing appears in the browser.
>
> I'm sure I'm getting something basic wrong but can't work out what it is. Help!
>
> Thanks,
> Marcus.
>
>
> --
> 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/f48bf659-418e-4ac1-ba3d-dd1284396ac8%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/355267f3-59ef-4369-bafb-1ffde2c998a3%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Sorry, I don’t think I explained myself very well - I’m happy to replace HBox/VBox with Row/Column - that’s no trouble. I thought you meant there was no subclassing support for the Row and Column classes either - I obviously misunderstood and if there is then there’s no problem! But…your suggestion of changing to these is what I tried in the simple example at the start of this post and couldn’t get it to work, and I don’t know what I’ve done wrong.

Thanks again and apologies for the confusion,

Marcus.

···

On Tuesday, July 5, 2016 at 3:21:07 PM UTC+1, Bryan Van de ven wrote:

Marcus,

As I mentioned, the new analogous classes are bokeh.models.layouts.Row and bokeh.models.layouts.Column. The most direct solution is to change your code to subclass from those, instead of from HBox an VBox. If there is an issue with updating all of your own code this way, you might have success by making and using your own shims:

    class HBox(Row): pass



    class VBox(Column): pass

However, I have not tried this to know it would work for certain. In any case I don’t expect there will ever be HBox/VBox classes ever again, only Row and Column.

Thanks,

Bryan

On Jul 5, 2016, at 9:12 AM, Marcus Donnelly [email protected] wrote:

Hi Bryan,

Thanks for the quick response. Do you know if/when (I’m really hoping when rather than if!) subclassing support is likely to be re-introduced? It’s quite an issue for me as I’ve created some specialised classes, e.g. a heatmap with automatically updating colourbar (like the example here - the post on Jan 17th is from me). I might be able to find another way around it but it would need significant rework. I can stick with 0.11.1 for the meantime but would like to know if it will be reintroduced.

Thanks,

Marcus.

On Tuesday, July 5, 2016 at 2:34:32 PM UTC+1, Bryan Van de ven wrote:

Hi Marcus,

There was extensive work on layout in 0.12 and a few changes as well. We tried both to minimize these and also to anticipate as many as we could and note them in the Migration Guide, but I will admit subclassing is one that escaped my attention. Long story short: There are new fundamental models Row and Column, and those are what you would want to subclass from. We kept HBox and VBox as functions for convenient aliases to create Row and Column, and to prevent breaking “standard usage” but as I said subclassing them is simply something it did not occur to me that people would do. My apologies for any inconvenience.

Thanks,

Bryan

On Jul 5, 2016, at 8:19 AM, Marcus Donnelly [email protected] wrote:

Hi,

I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.

Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)

from bokeh.models.layouts import HBox
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class HBoxTest(HBox):

button = Instance(Button)
slider = Instance(Slider)

def __init__(self):

    self.__view_model__ = 'HBox'
    self.__subtype__ = 'HBoxTest'

    super(HBoxTest,self).__init__()

    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(HBoxTest())

…but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str

As it looks like Row replaces HBox in 0.12.0 I then tried the following…

from bokeh.models.layouts import Row
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class RowTest(Row):

button = Instance(Button)
slider = Instance(Slider)

def __init__(self):

    self.__view_model__ = 'Row'
    self.__subtype__ = 'RowTest'

    super(RowTest,self).__init__()

    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(RowTest())

No error this time but nothing appears in the browser.

I’m sure I’m getting something basic wrong but can’t work out what it is. Help!

Thanks,
Marcus.


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/f48bf659-418e-4ac1-ba3d-dd1284396ac8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/355267f3-59ef-4369-bafb-1ffde2c998a3%40continuum.io.

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

Marcus,

Actually, I missed the bottom of your original post, where you said that you had tried exactly that. Please accept my apologies. Let me try your code and report back.

Thanks,

Bryan

···

On Jul 5, 2016, at 9:32 AM, Marcus Donnelly <[email protected]> wrote:

Hi Bryan,

Sorry, I don't think I explained myself very well - I'm happy to replace HBox/VBox with Row/Column - that's no trouble. I thought you meant there was no subclassing support for the Row and Column classes either - I obviously misunderstood and if there is then there's no problem! But...your suggestion of changing to these is what I tried in the simple example at the start of this post and couldn't get it to work, and I don't know what I've done wrong.

Thanks again and apologies for the confusion,

Marcus.

On Tuesday, July 5, 2016 at 3:21:07 PM UTC+1, Bryan Van de ven wrote:
Marcus,

As I mentioned, the new analogous classes are `bokeh.models.layouts.Row` and `bokeh.models.layouts.Column`. The most direct solution is to change your code to subclass from those, instead of from HBox an VBox. If there is an issue with updating all of your own code this way, you might have success by making and using your own shims:

        class HBox(Row): pass

        class VBox(Column): pass

However, I have not tried this to know it would work for certain. In any case I don't expect there will ever be HBox/VBox classes ever again, only Row and Column.

Thanks,

Bryan

> On Jul 5, 2016, at 9:12 AM, Marcus Donnelly <[email protected]> wrote:
>
> Hi Bryan,
>
> Thanks for the quick response. Do you know if/when (I'm really hoping when rather than if!) subclassing support is likely to be re-introduced? It's quite an issue for me as I've created some specialised classes, e.g. a heatmap with automatically updating colourbar (like the example here - the post on Jan 17th is from me). I might be able to find another way around it but it would need significant rework. I can stick with 0.11.1 for the meantime but would like to know if it will be reintroduced.
>
> Thanks,
> Marcus.
>
>
> On Tuesday, July 5, 2016 at 2:34:32 PM UTC+1, Bryan Van de ven wrote:
> Hi Marcus,
>
> There was extensive work on layout in 0.12 and a few changes as well. We tried both to minimize these and also to anticipate as many as we could and note them in the Migration Guide, but I will admit subclassing is one that escaped my attention. Long story short: There are new fundamental models Row and Column, and those are what you would want to subclass from. We kept HBox and VBox as functions for convenient aliases to create Row and Column, and to prevent breaking "standard usage" but as I said subclassing them is simply something it did not occur to me that people would do. My apologies for any inconvenience.
>
> Thanks,
>
> Bryan
>
>
> > On Jul 5, 2016, at 8:19 AM, Marcus Donnelly <[email protected]> wrote:
> >
> > Hi,
> >
> > I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.
> >
> > Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)
> >
> > from bokeh.models.layouts import HBox
> > from bokeh.core.properties import Instance
> > from bokeh.io import curdoc
> > from bokeh.models.widgets import Button, Slider
> >
> > class HBoxTest(HBox):
> >
> > button = Instance(Button)
> > slider = Instance(Slider)
> >
> > def __init__(self):
> >
> > self.__view_model__ = 'HBox'
> > self.__subtype__ = 'HBoxTest'
> >
> > super(HBoxTest,self).__init__()
> >
> > self.button = Button(label='Click')
> > self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
> > self.children.append(self.button)
> > self.children.append(self.slider)
> >
> > curdoc().add_root(HBoxTest())
> >
> > ..but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str
> >
> > As it looks like Row replaces HBox in 0.12.0 I then tried the following...
> >
> > from bokeh.models.layouts import Row
> > from bokeh.core.properties import Instance
> > from bokeh.io import curdoc
> > from bokeh.models.widgets import Button, Slider
> >
> > class RowTest(Row):
> >
> > button = Instance(Button)
> > slider = Instance(Slider)
> >
> > def __init__(self):
> >
> > self.__view_model__ = 'Row'
> > self.__subtype__ = 'RowTest'
> >
> > super(RowTest,self).__init__()
> >
> > self.button = Button(label='Click')
> > self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
> > self.children.append(self.button)
> > self.children.append(self.slider)
> >
> > curdoc().add_root(RowTest())
> >
> > No error this time but nothing appears in the browser.
> >
> > I'm sure I'm getting something basic wrong but can't work out what it is. Help!
> >
> > Thanks,
> > Marcus.
> >
> >
> > --
> > 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/f48bf659-418e-4ac1-ba3d-dd1284396ac8%40continuum.io.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout.
>
>
> --
> 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/355267f3-59ef-4369-bafb-1ffde2c998a3%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/8d2675b6-7dda-4f88-bd2c-ed3a16ab3e8b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

No problem, thanks!

···

On Tuesday, July 5, 2016 at 3:36:35 PM UTC+1, Bryan Van de ven wrote:

Marcus,

Actually, I missed the bottom of your original post, where you said that you had tried exactly that. Please accept my apologies. Let me try your code and report back.

Thanks,

Bryan

On Jul 5, 2016, at 9:32 AM, Marcus Donnelly [email protected] wrote:

Hi Bryan,

Sorry, I don’t think I explained myself very well - I’m happy to replace HBox/VBox with Row/Column - that’s no trouble. I thought you meant there was no subclassing support for the Row and Column classes either - I obviously misunderstood and if there is then there’s no problem! But…your suggestion of changing to these is what I tried in the simple example at the start of this post and couldn’t get it to work, and I don’t know what I’ve done wrong.

Thanks again and apologies for the confusion,

Marcus.

On Tuesday, July 5, 2016 at 3:21:07 PM UTC+1, Bryan Van de ven wrote:

Marcus,

As I mentioned, the new analogous classes are bokeh.models.layouts.Row and bokeh.models.layouts.Column. The most direct solution is to change your code to subclass from those, instead of from HBox an VBox. If there is an issue with updating all of your own code this way, you might have success by making and using your own shims:

    class HBox(Row): pass

    class VBox(Column): pass

However, I have not tried this to know it would work for certain. In any case I don’t expect there will ever be HBox/VBox classes ever again, only Row and Column.

Thanks,

Bryan

On Jul 5, 2016, at 9:12 AM, Marcus Donnelly [email protected] wrote:

Hi Bryan,

Thanks for the quick response. Do you know if/when (I’m really hoping when rather than if!) subclassing support is likely to be re-introduced? It’s quite an issue for me as I’ve created some specialised classes, e.g. a heatmap with automatically updating colourbar (like the example here - the post on Jan 17th is from me). I might be able to find another way around it but it would need significant rework. I can stick with 0.11.1 for the meantime but would like to know if it will be reintroduced.

Thanks,
Marcus.

On Tuesday, July 5, 2016 at 2:34:32 PM UTC+1, Bryan Van de ven wrote:
Hi Marcus,

There was extensive work on layout in 0.12 and a few changes as well. We tried both to minimize these and also to anticipate as many as we could and note them in the Migration Guide, but I will admit subclassing is one that escaped my attention. Long story short: There are new fundamental models Row and Column, and those are what you would want to subclass from. We kept HBox and VBox as functions for convenient aliases to create Row and Column, and to prevent breaking “standard usage” but as I said subclassing them is simply something it did not occur to me that people would do. My apologies for any inconvenience.

Thanks,

Bryan

On Jul 5, 2016, at 8:19 AM, Marcus Donnelly [email protected] wrote:

Hi,

I just upgraded to version 0.12.0 and am having problems creating classes inheriting from bokeh.models.layouts.

Under 0.11.1 the following code worked (using the Bokeh server, i.e. bokeh serve --show)

from bokeh.models.layouts import HBox
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class HBoxTest(HBox):

button = Instance(Button)
slider = Instance(Slider)

def __init__(self):

    self.__view_model__ = 'HBox'
    self.__subtype__ = 'HBoxTest'

    super(HBoxTest,self).__init__()

    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(HBoxTest())

…but under 0.12.0 I got the following error at line 6: TypeError: function() argument 1 must be code, not str

As it looks like Row replaces HBox in 0.12.0 I then tried the following…

from bokeh.models.layouts import Row
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class RowTest(Row):

button = Instance(Button)
slider = Instance(Slider)

def __init__(self):

    self.__view_model__ = 'Row'
    self.__subtype__ = 'RowTest'

    super(RowTest,self).__init__()

    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(RowTest())

No error this time but nothing appears in the browser.

I’m sure I’m getting something basic wrong but can’t work out what it is. Help!

Thanks,
Marcus.


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/f48bf659-418e-4ac1-ba3d-dd1284396ac8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/355267f3-59ef-4369-bafb-1ffde2c998a3%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/8d2675b6-7dda-4f88-bd2c-ed3a16ab3e8b%40continuum.io.

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

Marcus,

Simple fix, __view_model__ and __subtype__ need to be class attributes:

    from bokeh.models.layouts import Row
    from bokeh.core.properties import Instance
    from bokeh.io import curdoc
    from bokeh.models.widgets import Button, Slider

    class RowTest(Row):

        __view_model__ = 'Row'
        __subtype__ = 'RowTest'

        button = Instance(Button)
        slider = Instance(Slider)

        def __init__(self):

            super(RowTest,self).__init__()

            self.button = Button(label='Click')
            self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
            self.children.append(self.button)
            self.children.append(self.slider)

    curdoc().add_root(RowTest())

If it was working the other way before, that was purely an accident and unintentional.

Bryan

···

On Jul 5, 2016, at 8:19 AM, Marcus Donnelly <[email protected]> wrote:

from bokeh.models.layouts import Row
from bokeh.core.properties import Instance
from bokeh.io import curdoc
from bokeh.models.widgets import Button, Slider

class RowTest(Row):

    button = Instance(Button)
    slider = Instance(Slider)

    def __init__(self):

        self.__view_model__ = 'Row'
        self.__subtype__ = 'RowTest'

        super(RowTest,self).__init__()

        self.button = Button(label='Click')
        self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
        self.children.append(self.button)
        self.children.append(self.slider)

curdoc().add_root(RowTest())

Works perfectly now, many thanks Bryan!

···

On Tuesday, July 5, 2016 at 3:38:38 PM UTC+1, Bryan Van de ven wrote:

Marcus,

Simple fix, view_model and subtype need to be class attributes:

from bokeh.models.layouts import Row

from bokeh.core.properties import Instance

from [bokeh.io](http://bokeh.io) import curdoc

from bokeh.models.widgets import Button, Slider



class RowTest(Row):



    __view_model__ = 'Row'

    __subtype__ = 'RowTest'



    button = Instance(Button)

    slider = Instance(Slider)



    def __init__(self):





        super(RowTest,self).__init__()



        self.button = Button(label='Click')

        self.slider = Slider(title='value',start=0,end=10,value=5,step=1)

        self.children.append(self.button)

        self.children.append(self.slider)



curdoc().add_root(RowTest())

If it was working the other way before, that was purely an accident and unintentional.

Bryan

On Jul 5, 2016, at 8:19 AM, Marcus Donnelly [email protected] wrote:

from bokeh.models.layouts import Row

from bokeh.core.properties import Instance

from bokeh.io import curdoc

from bokeh.models.widgets import Button, Slider

class RowTest(Row):

button = Instance(Button)
slider = Instance(Slider)
def __init__(self):
    self.__view_model__ = 'Row'
    self.__subtype__ = 'RowTest'
    super(RowTest,self).__init__()
    self.button = Button(label='Click')
    self.slider = Slider(title='value',start=0,end=10,value=5,step=1)
    self.children.append(self.button)
    self.children.append(self.slider)

curdoc().add_root(RowTest())