วิดเจ็ตป้ายกำกับใน Tkinter ใช้เพื่อแสดงข้อความและรูปภาพ เราสามารถเชื่อมโยง URL กับวิดเจ็ตป้ายกำกับเพื่อให้คลิกได้ เมื่อใดก็ตามที่คลิกวิดเจ็ตป้ายกำกับ จะเปิดลิงก์ที่แนบมาในเบราว์เซอร์เริ่มต้น
ในการทำงานกับเบราว์เซอร์และไฮเปอร์ลิงก์ เราสามารถใช้เว็บเบราว์เซอร์ โมดูลในภาษาไพทอน โมดูลสามารถเข้าถึงได้ในไลบรารีส่วนขยายของ Python และสามารถติดตั้งได้โดยพิมพ์คำสั่ง pip install webbrowser ในเปลือก
ตัวอย่าง
ในแอปพลิเคชันนี้ เราจะสร้างป้ายกำกับซึ่งกลายเป็นไฮเปอร์ลิงก์ที่อ้างอิงถึงหน้าเว็บ
# Import the required library
from tkinter import *
import webbrowser
# Create an instance of tkinter frame
win = Tk()
win.geometry("700x350")
def open_url(url):
webbrowser.open_new_tab(url)
# Create a Label Widget
label= Label(win, text= "Welcome to TutorialsPoint", cursor= "hand2", foreground= "green", font= ('Aerial 18'))
label.pack(pady= 30)
# Define the URL to open
url= 'https://www.tutorialspoint.com/'
# Bind the label with the URL to open in a new tab
label.bind("<Button-1>", lambda e:open_url(url))
win.mainloop() ผลลัพธ์

เมื่อคลิกที่ป้ายกำกับ ผู้ใช้จะถูกเปลี่ยนเส้นทางไปยังหน้าแรกของ Tutorialspoint