I am trying to add the animation to tkinter canvas. How can i place matplotlib example animation on tkinter canvas either by grid or pack methods.
Asked
Active
Viewed 1,505 times
0
-
1have a look here http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html... – Saullo G. P. Castro Aug 25 '13 at 11:25
-
possible duplicate of [Running matplotlib in tkinter](http://stackoverflow.com/questions/3845407/running-matplotlib-in-tkinter) – Viktor Kerkez Aug 25 '13 at 12:45
-
@SaulloCastro : I already referred the links, but i am unable to implement the same for "imshow" and animation. – lokesh Aug 25 '13 at 13:40
-
@ViktorKerkez as i am trying with imshow and funcanimation it is giving me error. – lokesh Aug 25 '13 at 13:42
-
1Do not import `pyplot` if you are embedding – tacaswell Aug 25 '13 at 15:28
-
and please show use the error you are getting – tacaswell Aug 25 '13 at 15:28
-
And see http://stackoverflow.com/questions/18391038/deleting-and-redrawing-matplotlib-animation Which is an example of embedding in QT, but the `matplotlib` side of it will be the same. – tacaswell Aug 25 '13 at 15:29
-
Look at the examples in the first comment, or the code in the suggested duplicate, or the example I linked to. – tacaswell Aug 25 '13 at 16:23
-
@tcaswell i implemented it and its working. but now how can i stop and remove the imshow.. – lokesh Aug 25 '13 at 17:26
-
remove it like any other tk widget – tacaswell Aug 25 '13 at 17:35
-
@tcaswell already did it. thanks – lokesh Aug 25 '13 at 17:54
-
Please write up what you did as an answer and answer your own question – tacaswell Aug 25 '13 at 17:59
-
@tcaswell sure i have to add little bit features then i will add entire code and explanation – lokesh Aug 25 '13 at 18:03
-
@tcaswell i am drawing imshow on canvas(figurecanvastkagg) with artistanimation im running animation and also drawing some line on the same canvas using create_line. now how can i remove the animation alone without removing the canvas and line. i can able to remove entire canvas but not animation? how can i do it?please help me – lokesh Aug 28 '13 at 19:50
-
`del ani` and `im.remove()` – tacaswell Aug 28 '13 at 20:01
-
@tcaswell i can't able to make it work i think i am doing something wrong. i have added my new modified code in the above post please have a look at it. please clarify. how to stop or remove animation and removing image and preserving the line, canvas – lokesh Aug 28 '13 at 20:13
-
I really have no idea what you are really asking at this point and this is more code than I am willing to wade through. Please clean up and reduce your question to the _minimum_ amount of code needed to demonstrate it. – tacaswell Aug 29 '13 at 04:14
-
You might be better off just asking a new question, as this seems like it is in fact a different problem than you orginally asked. – tacaswell Aug 29 '13 at 04:15
1 Answers
0
Using FigureCanvasTkAgg, like this:
from tkinter import *
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
fb = Figure(figsize=(5, 2.5), dpi=100)
b = fb.add_subplot(111)
b.set_title('Ethernet Packet')
canvas = FigureCanvasTkAgg(fb, master=Root)
canvas.get_tk_widget().place(x=540, y=560)
b.plot(final_data)

Izalion
- 708
- 4
- 11