我正在为下载管理器制作GUI。
单击“确定”按钮后,我希望启动命令execute
。我希望从我的dl_dialog
函数中获取值,例如url
,path
,md5url
并将它们提供给我的下载程序模块。
问题是url
,path
和md5url
的值不会更新为我在输入字段中输入的值。我该如何解决这个问题?
default_storage_path= "C:\sdmdownloads"
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
self.button.pack(side=LEFT)
self.hi_there = Button(frame, text="Download", command=self.dl_dialog)
self.hi_there.pack(side=LEFT)
self.path = default_storage_path
self.url = ""
self.md5url = ""
self.filename = ""
def dl_dialog(self):
self.dialog = Pmw.Dialog(root,
buttons = ('OK', 'Apply', 'Cancel', 'Help'),
defaultbutton = 'OK',
title = 'My dialog',
command = self.execute)
lbl1 = Tkinter.Label(self.dialog.interior(),text="URL")
lbl1.pack(side="left")
url = Tkinter.Entry(self.dialog.interior())
url.pack(side="left")
self.url = url
lbl2 = Tkinter.Label(self.dialog.interior(),text="Path")
lbl2.pack(side="left")
path = Tkinter.Entry(self.dialog.interior())
path.pack(side="left")
path.insert(0,default_storage_path)
self.path = path
lbl3 = Tkinter.Label(self.dialog.interior(),text="MD5 URL")
lbl3.pack(side="left")
md5url = Tkinter.Entry(self.dialog.interior())
md5url.pack()
self.md5url = md5url
def execute(self):
#if result not in ('Apply', 'Help'):
# self.dialog.deactivate(result)
if result == "OK":
print "OK"
path =self.path
url = self.url
md5url = self.md5url
d = Downloader(path,url,md5url)
thread.start_new_thread(d.checkhttplink, ())
thread.start_new_thread(d.checkifexists, ())
elif result == "Apply":
print "Apply"
elif result == "Cancel":
print "Cancel"
else:
print"Help
答案 0 :(得分:0)
修正...抱歉忘了使用我的StringVar()