如何将我的网站名称传递到“def openChrome()”,例如,从“def proceed3()”到“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
添加
return website_name
到proceed3()函数的结尾将参数
website_name
添加到OpenChrome()函数中。你知道吗我建议阅读this tutorial关于如何在python中使用函数的内容,因为这将是进一步进行编程工作的基础。你知道吗
相关问题 更多 >
编程相关推荐