Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import tkinter as tk
  2. import matplotlib
  3. matplotlib.use('TkAgg')
  4. import gc
  5. from memory_profiler import profile
  6. import matplotlib.pyplot as plt
  7.  
  8. from matplotlib.figure import Figure
  9. from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  10.  
  11. class App():
  12.     @profile
  13.     def __init__(self, parent):
  14.  
  15.         self.drawplotFrame = tk.Frame(parent, width=500, height=500)
  16.         self.drawplotFrame.pack()
  17.  
  18.         self.fig = Figure(figsize=(16, 11))
  19.         self.p = self.fig.add_subplot(1, 1, 1)
  20.         self.p.plot(range(1500000), range(1500000))
  21.  
  22.         self.drawplotCanvas = FigureCanvasTkAgg(self.fig, master=self.drawplotFrame)
  23.         self.drawplotCanvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
  24.         self.drawplotCanvas.get_tk_widget().destroy()
  25.         plt.close(self.fig)
  26.  
  27.         gc.collect()
  28.  
  29.  
  30.         print()
  31.  
  32. root = tk.Tk()
  33. App(root)
  34. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement