Reputation: 218
Is it possible to include an html mailto link in a customtkinter textbox?
Whilst the below example provides the required text and the link to open the default email client separately, I would like to combine the two by replacing the line 2 text with the link so that it automatically looks tidy and in the same format as the surrounding text.
import customtkinter as ctk
from tkhtmlview import HTMLLabel
class App(ctk.CTk):
def __init__(self):
super().__init__()
self.abouttext = ctk.CTkTextbox(master=self, width=500, height=100)
self.abouttext.pack()
self.abouttext.insert('1.0', 'Line 1: Stuff.\n\n')
self.abouttext.insert('2.0', 'Line 2: Email me for support.\n\n')
self.abouttext.insert('3.0', 'Line 3: More stuff.\n\n')
self.email_me = HTMLLabel(self, html=""" Line 2 replacement: <a href="mailto:[email protected]?subject=Help%20me%20please">Email me</a> for support""")
self.email_me.pack()
app = App()
app.mainloop()
My best attempt is:
self.abouttext.insert('2.0', 'Line 2: ' + HTMLLabel(self, html=""" <a href="mailto:[email protected]?subject=Help%20me%20please">Email me</a>""") + ' for support')
but TypeError: can only concatenate str (not "HTMLLabel") to str
Upvotes: 0
Views: 29