Skip to content

Commit

Permalink
NITDgpOS#81 Added save button in filemenu
Browse files Browse the repository at this point in the history
  • Loading branch information
rox committed Feb 2, 2018
1 parent c5d560a commit 99a09b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.pyc
.temp/
venv/
.png
test.py

10 changes: 10 additions & 0 deletions gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from Tkinter import *
except ImportError:
from tkinter import *
from tkinter import filedialog

try:
import ttk
Expand Down Expand Up @@ -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):
Expand All @@ -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)


Expand Down

0 comments on commit 99a09b0

Please sign in to comment.