[IPython-dev] Widget View post render hook

Nikolas Tezak ntezak at stanford.edu
Sun Mar 23 23:51:08 EDT 2014


Hey Jon,
awesome, thanks!

Nik

On Mar 21, 2014, at 11:12 AM, Jonathan Frederic <jon.freder at gmail.com> wrote:

> Hi Nik,
> 
> I added a `displayed` event to the widget model in https://github.com/ipython/ipython/pull/5404.  We will have to wait to see if the others like it.
> 
> Cheers,
> Jon
> 
> 
> On Sun, Mar 16, 2014 at 8:00 PM, Nikolas Tezak <ntezak at stanford.edu> wrote:
> Hi Jon,
> 
> that is pretty much what I ended up using (took me a while cause I’m a total noob at JavaScript).
> My circuit widget is coming together nicely. I’ve had a couple other ideas that I’ll probably throw together as soon as I get around to them. One example (shamelessly copied from Mathematica’s “Manipulate[]” command)
> 
> 1) extending the interactive command by adding a button that prints out a function call with the currently set parameters.
> 2) like 1) but perhaps an option to save the parameter setting to disk? (and then reload them when re-opening the notebook at a later time). I don’t like this second option very much because it would be nice to make any notebook self-contained.
> 
> Potentially one could also insert a new input cell with such a function call / stored parameter settings such that they would be available from within python even after restarting the kernel.
> But I don’t know if that kind of dynamic code inserting clashes with your guys’ vision of what should be doable.
> 
> Anyhow, thanks for your response! And again, my compliments for an awesome new feature in an amazing tool.
> 
> Nik
> 
> 
> 
> 
> On Mar 15, 2014, at 1:03 PM, Jonathan Frederic <jon.freder at gmail.com> wrote:
> 
> > Hi Nik,
> >
> > I'm glad you like the widgets and thank you for the feedback.  I encountered the same problem when implementing a D3.js widget (see https://github.com/jdfreder/ipython-d3).  As a hack-ish workaround I used a timeout with a 0ms interval (https://github.com/jdfreder/ipython-d3/blob/master/widget_forcedirectedgraph.js#L13).  Right now I don't believe we have a nice way to do this, adding an event or method is probably a good idea.
> >
> > -Jon
> >
> >
> > On Fri, Mar 14, 2014 at 11:27 AM, Nikolas Tezak <ntezak at stanford.edu> wrote:
> > Hi everybody,
> >
> > first of all, I _love_ the widgets, they are extremely useful!! And I’m super impressed by IPython’s crazy fast development progress.
> > I am currently trying to create a custom widget type that embeds a jsplumb circuit editor
> > ( http://jsplumbtoolkit.com/demo/home/jquery.html )
> >
> > However, when I implement my custom “render” method for the view I am running into a problem.
> > I first dynamically create the circuit components (currently just absolutely positioned divs within the widget view’s this.$el div. This works fine.
> > I then initialize a jsplumb instance and pass this.$el as the default container.
> > Now, however, when I try to add the connectors and connections with jsplumb within the render method, it fails because jsplumb is trying to read out dynamically the position of the widget view’s div before that div has been inserted into the DOM.
> >
> > So basically, my problem is that I want code within “render()” that already requires the view to be inserted into the document.
> > Should I use a different approach, i.e., maybe put this initialization code into "update()”, or do you expect that this will be a common enough use case that it would justify adding a special post render hook that gets called after the view’s div has been attached to a cell's widget sub_area?
> >
> >
> > I hope I described this well enough, let me know if you’d like me to share a code example.
> > Thanks,
> >
> > Nik
> > _______________________________________________
> > 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




More information about the IPython-dev mailing list