Ничего больше не нашел, кроме как объединить оба класса в один, только так заработало
class Myplot(QtGui.QWidget):
def __init__(self, parent=None):
super(Myplot, self).__init__(parent)
# a figure instance to plot on
self.figure = plt.figure()
# this is the Canvas Widget that displays the `figure`
# it takes the `figure` instance as a parameter to __init__
self.canvas = FigureCanvas(self.figure)
self.mylist=QListWidget(self)
row1="COMMISSIONS & FEES"
self.mylist.addItem(row1)
row2="NET LIQUIDATING VALUE"
self.mylist.addItem(row2)
self.mylist.setFixedWidth(200)
self.mylist.itemClicked.connect(self.Clicked)
# set the layout
minlayout = QtGui.QHBoxLayout()
minlayout.addWidget(self.mylist)
minlayout.addWidget(self.canvas)
self.setLayout(minlayout)
# self.hist()
def compute_initial_figure(self):
# random data
xdata = [random.random() for i in range(10)]
# create an axis
ax = self.figure.add_subplot(111)
# discards the old graph
ax.hold(False)
# plot data
ax.plot(xdata)
# refresh canvas
self.canvas.draw()
def hist(self):
tm = pd.Series(np.random.randn(500), index=pd.date_range('1/1/2005', periods=500))
tm = tm.cumsum()
ax = self.figure.add_subplot(111)
ax.hold(False)
ax.plot(tm)
self.canvas.draw()
def Clicked(self):
index=self.mylist.currentRow()
if index == 0:
print '0000'
self.compute_initial_figure()
if index == 1:
print '1111'
self.hist()