Terry,
Thanks for your help with this it was very helpful and a lot simpler than I
feared. I have managed to get a matplotlib graph embedded within a pane in
leo as a widget. I now need some help with how to interact with the
widget using scripts in leo. I am unsure about the following:
*1/ How do I expose the widget within th leo python environment?*
Here I have created a self.mat in your MatplotPaneProvider class to make
the windget accessible but it doesn't feel like the correct way to do this.
from PyQt4 import QtGui
class MatplotPaneProvider:
def __init__(self, c):
self.c = c
* self.mat = myMatplotWidget()*
if hasattr(c, 'free_layout'):
splitter = c.free_layout.get_top_splitter()
if splitter:
splitter.register_provider(self)
def ns_provides(self):
return[('Add matplot', '_add_matplot_pane')]
def ns_provide(self, id_):
if id_ == '_add_matplot_pane':
c = self.c
return self.mat
def ns_provider_id(self):
# used by register_provider() to unregister previously registered
# providers of the same service
# provider ID is not the same as the service id_ above
return "completely unique value here"
*mat = MatplotPaneProvider(c)*
*mat.mat.someMethod()*
*mat.mat.someOtherMethod()*
*2/I would also like to make the widget accessible from any script within
leo. What's the leo way of doing this?*
*3/ If I create more than 1 pane containing these widgest. How do I switch
between them in scripts?*
**
*4/ Running this script more than once creates multiple items for Add
Matplot when pressing the Action button. How do I stop this from happening?
I have alrewady tried returning a unique integer in * ns_provider_id *but
that did not work.*
cheers
Hetal
--
On Monday, September 17, 2012 5:48:32 PM UTC+1, Terry wrote:
> On Sun, 16 Sep 2012 22:23:18 -0700 (PDT)
> felix74 <[email protected] <javascript:>> wrote:
>
> > I'm trying to create a interactive chart in a embedded in a new leo pane
> > using matplotlib. However, I am not sure about the the best way to
> > implement this. I would appreciate some guidance on this please? The
> > questions I would like answered are:
> > 1/ How do I create a new blank pane for embedding a chart as well as
> other
> > QtWidgets.
> > 2/ Can I do this in a script or do I need to work with leo source
>
> You can run this script from any body pane:
> ---cut here---
> from PyQt4 import QtGui
> class MatplotPaneProvider:
> def __init__(self, c):
> self.c = c
> if hasattr(c, 'free_layout'):
> splitter = c.free_layout.get_top_splitter()
> if splitter:
> splitter.register_provider(self)
> def ns_provides(self):
> return[('Add matplot', '_add_matplot_pane')]
> def ns_provide(self, id_):
> if id_ == '_add_matplot_pane':
> c = self.c
> w = QtGui.QSlider()
> return w
> def ns_provider_id(self):
> # used by register_provider() to unregister previously registered
> # providers of the same service
> # provider ID is not the same as the service id_ above
> return "completely unique value here"
>
> MatplotPaneProvider(c)
> ---cut here---
>
> Paste just as above and run the script. Nothing happens. Right click
> on one of the pane dividers and select Insert. A new pane with a
> button 'Action' appears. Click it, and select "Add matplot" from the
> context menu.
>
> Instead of "w = QtGui.QSlider()", you want "w = myMatplotWidget()"
>
> Cheers -Terry
>
>
> > The context for wanting to do this is that I want to create a data
> > processing and visualization tool kit in leo. Like Excel but using nodes
> > instead of columns. As such I have data in nodes and can create new data
> > nodes by applying python functions to data in existing nodes. The thing
> > missing is the visualization within a leo pane (I can easily launch a
> chart
> > in it's own window) .
> >
>
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/leo-editor/-/PXEeHMzvZeIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.