Skip to content

Commit

Permalink
Merge pull request #95 from realsdx/savebtn
Browse files Browse the repository at this point in the history
Save functionality added in GUI file menu
  • Loading branch information
djmgit authored Feb 6, 2018
2 parents 0cbcdeb + 483b16a commit ea9e7ff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

try:
from Tkinter import *
import tkFileDialog as fdialog
except ImportError:
from tkinter import *
from tkinter import filedialog as fdialog

try:
import ttk
Expand Down Expand Up @@ -65,6 +67,14 @@ def destroy_app():
root.destroy()
exit(0)

def save_file():
file=fdialog.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 +83,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.destroy)


Expand Down

0 comments on commit ea9e7ff

Please sign in to comment.