How do i go about adding Chaco to an existing PyQt4 application?
Hours of searches yielded little (search for yourself). So far i've figured i need the following lines:
import os
os.environ['ETS_TOOLKIT']='qt4'
i could not find PyQt4-Chaco code anywhere on the internets
i would be very grateful to anyone filling in the blanks to show me the simplest line plot possible (with 2 points)
from PyQt4 import QtCore, QtGui
import sys
import os
os.environ['ETS_TOOLKIT']='qt4'
from enthought <blanks>
:
:
app = QtGui.QApplication(sys.argv)
main_window = QtGui.QMainWindow()
main_window.setCentralWidget(<blanks>)
main_window.show()
app.exec_()
print('bye')
what Chaco/Enthought class inherits from QWidget ?
here is what you need:
import os, sys
os.environ['ETS_TOOLKIT'] = 'qt4'
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
from numpy import linspace, pi, sin
from enthought.enable.api import Component, Container, Window
from enthought.chaco.api import create_line_plot, \
add_default_axes, \
add_default_grids, \
OverlayPlotContainer
x = linspace(-pi,pi,100)
y = sin(x)
plot = create_line_plot((x,y))
add_default_grids(plot)
add_default_axes(plot)
container = OverlayPlotContainer(padding = 50)
container.add(plot)
plot_window = Window(None, -1, component=container)
plot_window.control.setWindowTitle('hello')
plot_window.control.resize(400,400)
plot_window.control.show()
app.exec_()
plot_window.control inherits from QWidget