我使用Python和Tkinter的开发项目点击它们后,网页浏览器应该打开。Python的Tkinter的:其中,在<strong>文本构件</strong> 变化内容动态根据program.Now在我的文本组件我增加了许多urls.And浏览器会自动打开,而不单击文本
http://effbot.org/zone/tkinter-text-hyperlink.htm我提到这个,现在创建我code.But链接我的问题是每当显示在文本组件甚至内部消除点击它网址浏览器中打开了。
这是我的代码。
def click1(self,url):
webbrowser.open(url)
restitle,resthumb,resurl=printit()#title,thumbnailimage,url array
while restitle:
raw_data = urllib.request.urlopen(resthumb[0]).read()
tim = PIL.Image.open(io.BytesIO(raw_data))
tim = tim.resize((100, 100), PIL.Image.ANTIALIAS)
timage = ImageTk.PhotoImage(tim)
Lb1.image_create(END, image=timage)
curl=resurl[0]
Lb1.update()
images.append(timage)
Lb1.insert(END,restitle,hyperlink.add(click1(resurl[0])))#Passing url
Lb1.insert(END,"\n")
restitle.pop(0)
resurl.pop(0)
resthumb.pop(0)
我的问题: 我需要知道如何打开浏览器只上点击特定文本(超链接),而不是当它们被添加到文本widget.I是新来的蟒蛇和tkinter抱歉在代码段中的任何错误。提前感谢。
是'CLICK1 “一种班级的方法? – PRMoureu