0

我正在为下载管理器制作 GUI。单击“确定”按钮时,我希望execute启动该命令。我希望它从我的函数中获取值,即dl_dialog,url并将它们提供给我的下载器模块。pathmd5url

问题是 的值urlpath并且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
4

1 回答 1

0

已修复...抱歉忘记使用我的 StringVar()

于 2013-04-16T13:22:51.613 回答