3

I'm trying to display a html link in a messagebox, like :

messagebox.showinfo("About", "Please visit www.mySite.com for more informations.")

I didn't found how to make the website link clickable to open the web page in a browser in Tkinter.

Can someone help me or redirect me with a same solved question ?

Thank you.

katze
  • 1,273
  • 3
  • 16
  • 24

2 Answers2

2

"Short answer: 'No!' message is a simple string, no interpretation like in some widgets of other frameworks is done." (tkinter tkMessageBox html link)

Community
  • 1
  • 1
noahbkim
  • 528
  • 2
  • 13
0

I know its pretty late but for someone who still wants to know...full working example is below.

from tkinter import *
import webbrowser

def callback(url):
   webbrowser.open_new_tab(url)
   
def TEstWin():
    toplevel = Toplevel(ws)

    toplevel.title("Test window")
    toplevel.geometry("230x80")


    l1=Label(toplevel, image="::tk::icons::information")
    l1.grid(row=0, column=0)
    l2=Label(toplevel,text="Test")
    l2.grid(row=0, column=1)


    left_label = Label(toplevel, text='Weblink', cursor="hand2", relief='raised', foreground='blue')#text= "Left-bottom")
    left_label.grid(row=2, column=2)
    left_label.bind("<Button-1>", lambda e:callback("https://robot.jbnu.ac.kr/robot/21492/subview.do"))

ws = Tk()
ws.geometry("300x200")
ws.title('Python Guides')
ws.config(bg='#345')
Button(ws,text="Test the window",command=TEstWin).pack(pady=80)

ws.mainloop()