赞
踩
展开全部
# -*- coding: utf-8 -*-
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from Tkinter import *
class test(object):
def __init__(self,parent):
self.parent = parent
self.n = 0
Button(self.parent,text = 'change',command = self.change).pack()
'''表格个数'''
num = 2
fig = []
self.canvas = []
for i in range(num):
fig.append(Figure())
self.canvas.append(FigureCanvasTkAgg(fig[i],master = self.parent))
self.canvas[0]._tkcanvas.pack()
'''以下可以创2113建不同的图5261'''
axe = fig[0].add_subplot(111)
axe.set_title(u'第一个图',{'fontname':'STSong'})
axe2 = fig[1].add_subplot(211)
axe2_2 = fig[1].add_subplot(212)
axe2.set_title(u'第二个图',{'fontname':'STSong'})
def change(self):
self.n +=1
if self.n == 2:
self.n = 0
self.canvas[self.n -1]._tkcanvas.pack_forget()
self.canvas[self.n]._tkcanvas.pack()
if __name__ == "__main__":
root = Tk()
test(root)
root.mainloop()
您看着样4102能不能满足您的要求1653?
单击change后:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。