编程新手,特别是python和tKinter.如何创建一种方法将键“s”绑定到按钮或功能锐化?任何帮助都是极好的.
from Tkinter import *
from PIL import Image,ImageTk,ImageFilter,ImageEnhance
class Application(Frame):
def __init__(self,master=None):
Frame.__init__(self,master)
master.wm_title("Image examples")
self.pack()
self.createWidgets()
def createWidgets(self):
self.img = Image.open("lineage.jpg")
self.photo1 = ImageTk.PhotoImage(self.img.convert("RGB"))
self.label1 = Label(self,image=self.photo1)
self.label1.grid(row=0,column=0,padx=5,pady=5,rowspan=10)
self.photo2 = ImageTk.PhotoImage(self.img.convert("RGB"))
self.label2 = Label(self,image=self.photo2)
self.label2.grid(row=0,column=1,rowspan=10)
button5 = Button(self,text="Sharpen",command=self.sharpen)
button5.grid(row=4,column= 2,sticky = N)
def sharpen(self):
img2 = self.img.filter(ImageFilter.SHARPEN)
self.photo2 = ImageTk.PhotoImage(img2)
self.label2 = Label(self,rowspan=10)
最佳答案