Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Use Tkinter for python 2, tkinter for python 3
- import os
- import tkinter as tk
- import tkinter.ttk as ttk
- import matplotlib.pyplot as plt
- class MainApplication(tk.Frame):
- def __init__(self, parent, *args, **kwargs):
- tk.Frame.__init__(self, parent, *args, **kwargs)
- self.parent = parent
- parent.title("data plotter")
- parent.geometry("600x400")
- self.Xlabel = ttk.Label(parent, text=" enter your x-cords")
- self.Xlabel.pack()
- self.xentry = ttk.Entry(parent)
- self.xentry.pack()
- self.cLabel = ttk.Label(text="enter label")
- self.cLabel.pack()
- self.customlabel = ttk.Entry(parent)
- self.customlabel.pack()
- self.fileLabel = ttk.Label(parent, text=" enter your file")
- self.fileLabel.pack()
- self.filentry = ttk.Entry()
- self.filentry.pack()
- self.action = ttk.Button(text="plot", command=self.Plotter)
- self.action.pack()
- def Plotter(self):
- x_c = []
- x_cords = self.xentry.get()
- for x in x_cords.split():
- int(x)
- x_c.append(x)
- plt.legend(["stats",])
- plt.ylabel("y-cords")
- plt.plot(x_c, marker="^")
- plt.xlabel(self.customlabel.get())
- plt.savefig(self.filentry.get())
- os.startfile(self.filentry.get())
- if __name__ == "__main__":
- root = tk.Tk()
- MainApplication(root).pack(side="top", fill="both", expand=True)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement