__author__ = 'saintdragon2'

#http://www.tutorialspoint.com/python/tk_menu.htm

from tkinter import Tk, Menu, Toplevel, Button
from tkinter.filedialog import askopenfilename
from tkinter.messagebox import showerror

def donothing():
    filewin = Toplevel(root)
    button = Button(filewin, text="Do nothing button")
    button.pack()


def load_file():
    fname = askopenfilename(filetypes=(("Template files", "*.tplate"),
                                       ("HTML files", "*.html;*.htm"),
                                       ("All files", "*.*") ))
    if fname:
        try:
            # print("""here it comes: self.settings["template"].set(fname)""")
            print(fname)
        except:                     # <- naked except is a bad idea
            showerror("Open Source File", "Failed to read file\n'%s'" % fname)
        return

root = Tk()
menubar = Menu(root)

filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label='New', command=donothing)
filemenu.add_command(label='Open', command=load_file)
filemenu.add_command(label='Save', command=donothing)
filemenu.add_command(label='Save as ...', command=donothing)
filemenu.add_command(label='Close', command=donothing)
filemenu.add_separator()
filemenu.add_command(label='Exit', command=root.quit)
menubar.add_cascade(label='File', menu=filemenu)

editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label='Undo', command=donothing)
editmenu.add_separator()
editmenu.add_command(label='Cut', command=donothing)
editmenu.add_command(label='Copy', command=donothing)
editmenu.add_command(label='Paste', command=donothing)
editmenu.add_command(label='Delete', command=donothing)
editmenu.add_command(label='Select All', command=donothing)
menubar.add_cascade(label='Edit', menu=editmenu)

helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label='Help Index', command=donothing)
helpmenu.add_command(label='About ...', command=donothing)
menubar.add_cascade(label='Help', menu=helpmenu)


root.config(menu=menubar)
root.mainloop()

