from Tkinter import * import tkFileDialog def quit(window): window.destroy() def save_file(text): filename = tkFileDialog.asksaveasfilename() file = open(filename, 'w') file.write(text.get(1.0, END)) file.close() def open_file(self): filename = tkFileDialog.askopenfilename() file = PhotoImage(file=filename) the_image = window.create_image(anchor=N, image=file) def callback(): print "called the callback!" def rotate_callback(): top = Toplevel() top.minsize(width=100, height=100) rotation_cap = Label (top, text="Angle of Rotation") rotation_cap.grid(row=0, column=0, sticky=N+E) rotation_cap.config(justify= LEFT) rotation_entry = Entry (top) rotation_entry.grid(row=0, column=2,sticky=N+E) rotation_entry.config(justify=LEFT) rotation_style = StringVar() radio_cw = Radiobutton (top, text="cw", variable=rotation_style, value="cw") radio_cw.grid(row=1, column=0) radio_cw.config (justify=LEFT) radio_ccw = Radiobutton (top, text="ccw", variable=rotation_style, \ value="ccw") radio_ccw.grid(row=2, column=0) ok_button = Button (top, text="Ok", command=callback, padx=12) ok_button.grid(row=3, column=1) if __name__ == '__main__': window = Tk() window.minsize(720,640) window.title("Image Tweak v1.0") frame = Frame (window) frame.pack(side=TOP, fill=X) menubar = Menu(window) filemenu = Menu(menubar) open_command = lambda : open_file(window) filemenu.add_command(label="Open", command=open_command) save_command = lambda : save_file(window, text) filemenu.add_command(label="Save", command=save_command) quit_command = lambda : quit(window) filemenu.add_command(label="Quit", command=quit_command) menubar.add_cascade(label="File", menu=filemenu) window.config(menu=menubar) scrollbar_y = Scrollbar (window) scrollbar_y.pack(side=RIGHT, fill=Y) scrollbar_x = Scrollbar (window) scrollbar_x.pack(side=BOTTOM, fill=X) scrollbar_x.config(orient=HORIZONTAL) b1 = Button(frame, text="rotate", width=6, command=rotate_callback) b1.pack(side=LEFT, padx=2, pady=2) b2 = Button(frame, text="effect2", width=6, command=callback) b2.pack(side=LEFT, padx=2, pady=2) b3 = Button(frame, text="effect3", width=6, command=callback) b3.pack(side=LEFT, padx=2, pady=2) b4 = Button(frame, text="effect4", width=6, command=callback) b4.pack(side=LEFT, padx=2, pady=2) window.config(menu=menubar) window.mainloop()