[IPython-dev] More widget feasibility ideas

Nicholas Bollweg nick.bollweg at gmail.com
Wed Oct 29 19:05:34 EDT 2014


Yes, add_class was replaced with _dom_classes. It should actually simplify
a lot of your code!

On Wed, Oct 29, 2014 at 6:53 PM, Adam Hughes <hughesadam87 at gmail.com> wrote:

> Hi Nicholas,
>
> After I updated to the recent dev, part of our code broke.  It's from the
> part that you showed to us, so I figured you might be aware of what has
> been changed:
>
> AttributeError                            Traceback (most recent call last)<ipython-input-8-70485b3b7990> in displayed(self, _)    113     # -----    114     def displayed(self, _):--> 115         self.add_class("col-xs-9")    116         # THIS IS WHERE DRAW IS CALLED AFTER DISPLAYS CHANGE    117         self.draw()
> AttributeError: 'Spectrogram' object has no attribute 'add_class'
>
>
>
> On Tue, Oct 28, 2014 at 12:07 AM, Adam Hughes <hughesadam87 at gmail.com>
> wrote:
>
>> Ah gotcha!  Thanks for clearing that up, much appreciated!  I guess my
>> dev is way older than I recall.
>>
>> On Mon, Oct 27, 2014 at 10:45 PM, Nicholas Bollweg <
>> nick.bollweg at gmail.com> wrote:
>>
>>> For reference, I see this:
>>>
>>> [image: Inline image 3]
>>>
>>> ah, the _dom_classes may have been more recent than that. Here's the
>>> change, landed sept 23: https://github.com/ipython/ipython/pull/6235
>>>
>>> you may have to go back to something like:
>>>
>>> w = HTML("text")
>>>> w.on_displayed(lambda x: w.add_class("alert-warning")
>>>>
>>>
>>> When you want to change it, you'd then have to:
>>>
>>> w.remove_class("alert-warning")
>>>> w.add_class("alert-success")
>>>>
>>>
>>> In the new core widgets, a traitlet manages these directly:
>>>
>>> https://github.com/ipython/ipython/blob/master/IPython/html/widgets/widget_button.py#L36
>>> And all the class adding/removing is done on the client side.
>>>
>>> In my bootstrap librar <https://github.com/bollwyvl/ip-bootstrap>y i
>>> have been tinkering with, I did the same, though a little differently.
>>>
>>> On Mon, Oct 27, 2014 at 8:55 PM, Adam Hughes <hughesadam87 at gmail.com>
>>> wrote:
>>>
>>>> Yes, but when you do this in your notebook, does it appear in a
>>>> different colors?  Mine looks like plain text.  IE I literally see:
>>>>
>>>> info
>>>> danger
>>>> warning
>>>> success
>>>>
>>>> In my output cell, instead of pretty colors like the example on the
>>>> bootstrap link.  Using about a 2week-old version of 3.0 dev, if that
>>>> matters.
>>>>
>>>> On Mon, Oct 27, 2014 at 8:50 PM, Nicholas Bollweg <
>>>> nick.bollweg at gmail.com> wrote:
>>>>
>>>>> right, you'd switch it out to another context:
>>>>>
>>>>> from IPython.html import widgets
>>>>>> from IPython.display import display
>>>>>> for context in ["info", "danger", "warning", "success"]:
>>>>>>     display(widgets.HTML(value=context, _dom_classes=["alert",
>>>>>> "alert-" + context]))
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> IPython-dev mailing list
>>>>> IPython-dev at scipy.org
>>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> IPython-dev mailing list
>>>> IPython-dev at scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>
>>>>
>>>
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>
>>>
>>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141029/bfd1dbe8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2014-10-27_2239.png
Type: image/png
Size: 47090 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141029/bfd1dbe8/attachment.png>


More information about the IPython-dev mailing list