Chaco into Qt app - Exception

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Chaco into Qt app - Exception

Boiteux, Benoit

Hello,

 

I used very interesting example from Peter (Wang) on how to insert a chaco plot into a Qt application.

Please find the code below.

 

The example works fine, but I get an unhandled exception when I close the application. I’m on Windows environment (ETS 3.4 and Py 2.6 and PyQt 4.7 )

Exception is :

“An unhandled win32 exception occurred in python.exe [21132]”

 

Any idea?

 

Thanks

benoit

 

import sys

from numpy import linspace

from scipy.special import jn

from PyQt4 import QtGui, QtCore

 

from enthought.etsconfig.etsconfig import ETSConfig

ETSConfig.toolkit = "qt4"

from enthought.enable.api import Window

 

from enthought.chaco.api import ArrayPlotData, Plot

from enthought.chaco.tools.api import PanTool, ZoomTool

 

 

class PlotFrame(QtGui.QWidget):

    """ This widget simply hosts an opaque enthought.enable.qt4_backend.Window

    object, which provides the bridge between Enable/Chaco and the underlying

    UI toolkit (qt4).  This code is basically a duplicate of what's in

    enthought.enable.example_support.DemoFrame, but is reproduced here to

    make this example more stand-alone.

    """

    def __init__(self, parent, **kw):

        QtGui.QWidget.__init__(self)

 

def create_chaco_plot(parent):

    x = linspace(-2.0, 10.0, 100)

    pd = ArrayPlotData(index = x)

    for i in range(5):

        pd.set_data("y" + str(i), jn(i,x))

 

    # Create some line plots of some of the data

    plot = Plot(pd, title="Line Plot", padding=50, border_visible=True)

    plot.legend.visible = True

    plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")

    plot.plot(("index", "y3"), name="j_3", color="blue")

 

    # Attach some tools to the plot

    plot.tools.append(PanTool(plot))

    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)

    plot.overlays.append(zoom)

 

    # This Window object bridges the Enable and Qt4 worlds, and handles events

    # and drawing.  We can create whatever hierarchy of nested containers we

    # want, as long as the top-level item gets set as the .component attribute

    # of a Window.

    return Window(parent, -1, component = plot)

 

def main():

    app = QtGui.QApplication(sys.argv)

    main_window = QtGui.QMainWindow(size=QtCore.QSize(500,500))

 

    enable_window = create_chaco_plot(main_window)

 

    # The .control attribute references a QWidget that gives Chaco events

    # and that Chaco paints into.

    main_window.setCentralWidget(enable_window.control)

 

    main_window.show()

    app.exec_()

 

if __name__ == "__main__":

    main()

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev