Fixed...Sorry forgot to use my StringVar()
Taking values from dialog box
-
04-04-2022 - |
Domanda
I am making a GUI for a download manager.
When the OK button is clicked, I would like the command execute
to be launched. I would like it to take the values from my dl_dialog
function i.e. url
, path
, md5url
and feed them to my downloader module.
The issue is the values of url
, path
and md5url
do not update to the ones I have typed into the entry field. How can I fix this?
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
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow