I want to invoke the method delImg
when the button delete is called. I used the following code segment for it. But the method parameters are highlighted as wrong. I used Tkinter.How to correct it ?
import Tkinter
import sys
from Tkinter import *
from tkFileDialog import askopenfilename
root= Tk()
enText =StringVar()
#root.geometry("400*400+500+300")
root.title("Welcome")
def Hello():
mtext = enText.get()
mlabel2 = Label(root,text=mtext).pack()
print(mtext)
return mtext
def callback():
name= askopenfilename()
print name
return name
def delImg(m1,n1):
if(m1!=n1):
print("Error")
text = Entry(root,textvariable =enText).pack()
mbtn = Button(root,text="Enter",command=callback,fg='red').pack()
mbtn = Button(root,text="Ok",command=Hello,fg='red').pack()
mbtn = Button(root,text="Delete", command= lambda:
delImg(mtext,name),fg='red').pack()
#print(mtext)
root.mainloop()
Aucun commentaire:
Enregistrer un commentaire