It's difficult to have all three types of values in the same label, but you can split them into 4 different labels. You can make the first three using two lists and creating labels based on the text and colors in the two lists, words
and colors
. You can separately make the fourth label, the link, using .bind()
.
Code:
from tkinter import *
import webbrowser
def callback(url):
webbrowser.open_new(url)
words = ["Made with", "?", "by"]
colors = ["white", "red", "white"]
root = Tk()
for index, word in enumerate(words):
Label(root, text = word, bg="black", fg=colors[index]).grid(column=index, row=0)
link = Label(root, text = "LINK", font="TKDefaultFont 9 underline", fg = "white", bg = "black", cursor="hand2")
link.grid(column=len(words),row=0)
link.bind("<Button-1>", lambda e: callback("https://www.google.com"))
root.mainloop()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…