All pastes #796024 Raw Edit

Unnamed

public python v1 · immutable
#796024 ·published 2007-11-24 18:18 UTC
rendered paste body
from Tkinter import *import tkFileDialogdef 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)    top.title("Rotate Image")    rotation1 = Label (top, text="cw")    rotation1.grid(row=1,column=0)    rotation2 = Label (top, text="ccw")    rotation2.grid(row=1,column=1)    rotation_degrees = StringVar()    degree_90_left = Radiobutton (top, text="90", variable=rotation_degrees, \                                  value="left 90")    degree_90_left.grid(row=2, column=0)    degree_180_left = Radiobutton (top, text="180", variable=rotation_degrees, \                             value="left 180")    degree_180_left.grid(row=3, column=0)    degree_270_left = Radiobutton (top, text="270", variable=rotation_degrees, \                                   value ="left 270")    degree_270_left.grid(row=4, column=0)        rotate_right(top, rotation_degrees)def rotate_right(top, rotation_degrees):    degree_90_right = Radiobutton (top, text="90", variable=rotation_degrees, \                                   value="right 90")    degree_90_right.grid(row=2, column=1)    degree_180_right = Radiobutton (top, text="180", variable=rotation_degrees, \                                   value="right 180")    degree_180_right.grid(row=3, column=1)    degree_270_right = Radiobutton (top, text="270", variable=rotation_degrees, \                                   value ="right 270")    degree_270_right.grid(row=4, column=1)    ok_button = Button (top, text="Ok", command=lambda: process_rotate \                        (rotation_degrees), padx=12)    ok_button.grid(row=5, column=1)def process_rotate(rotation_degrees):    print rotation_degreesif __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()