From 99a09b0f9ec9e02dbe152f954756f26b33594e84 Mon Sep 17 00:00:00 2001 From: rox Date: Fri, 2 Feb 2018 10:08:36 +0530 Subject: [PATCH] #81 Added save button in filemenu --- .gitignore | 3 +-- gui_main.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2c916f9..dac5ad3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ *.pyc .temp/ venv/ -.png -test.py + diff --git a/gui_main.py b/gui_main.py index cab0dfe..79dd47b 100644 --- a/gui_main.py +++ b/gui_main.py @@ -8,6 +8,7 @@ from Tkinter import * except ImportError: from tkinter import * + from tkinter import filedialog try: import ttk @@ -65,6 +66,14 @@ def destroy_app(): root.destroy() exit(0) +def save_file(): + file=filedialog.asksaveasfile(mode="wb", title="Save Figure", defaultextension=".png", filetypes = (("png files","*.png"),("all files","*.*"))) + if file is None: + return None + img_to_save=open(".temp/generated_plot.png","rb").read() + file.write(img_to_save) + file.close() + class Menubar: def __init__(self, master): @@ -73,6 +82,7 @@ def __init__(self, master): filemenu = Menu(menubar, tearoff=0) menubar.add_cascade(label="File", menu=filemenu) + filemenu.add_command(label="Save", command=save_file) filemenu.add_command(label="Quit", command=root.quit)