2013-04-16 92 views
0

我正在爲下載管理器製作GUI。 單擊確定按鈕後,我想要啓動命令execute。我希望它取自我的dl_dialog函數的值,即url,path,md5url,並將它們提供給我的下載程序模塊。從對話框中取值

問題是url,pathmd5url的值不會更新爲已輸入到輸入字段中的值。我怎樣才能解決這個問題?

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

固定...對不起忘了使用我的STRINGVAR()

+0

高興,你這個爲你工作,但是,你的回答並沒有真正說明你是如何解決您的問題。您能否將您的完整工作解決方案作爲您的答案的一部分發布? – Tommy