我如何传递我的website_name这是一个 URL,例如https://www.google.com/;从“defproceed3()”到“def openChrome()”?有什么建议么?
from Tkinter import *
def proceed3():
popup = Toplevel()
popup.geometry("350x175+350+180")
popup.resizable(width=False, height=False)
instruction = Label(popup, text="Enter the URL and pressGO!").pack()
website_name = Entry(popup, width=50).pack(pady=5)
goButton = Button(popup, text="GO!", command=openChrome)
goButton.pack(pady=5)
def openChrome():
openWebsite = website_name.get()
os.system(r"start chrome " + openWebsite)
windows = Tk()
windows.geometry("200x200+375+280")
windows.resizable(width=False, height=False)
submitButton = Button(windows, text='OpenChrome', command=proceed3)
submitButton.pack(pady=5)
windows.mainloop()
回溯错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1542, in __call__
return self.func(*args)
File "E:/educational_data/PyCharmProjects/web_grabber/starflow_grabber.py",
line 15, in openChrome
openWebsite = website_name.get()
NameError: global name 'website_name' is not defined