Skip to content

Clickable hyperlinks within CTkTextBox #2337

Answered by Akascape
w11-z asked this question in Q&A
Discussion options

You must be logged in to vote

@invader276 Yes it's possible to add clickable hyperlinks inside CTkTextBox.
Here is the implementation:

import customtkinter
import webbrowser

class CTkHyperlinkManager:
    """
    Modified class for implementing hyperlink in CTkTextbox
    """
    def __init__(self,
                 master,
                 text_color="#82c7ff"):

        self.text = master

        self.text.tag_config("hyper", foreground=text_color, underline=1)

        self.text.tag_bind("hyper", "<Enter>", self._enter)
        self.text.tag_bind("hyper", "<Leave>", self._leave)
        self.text.tag_bind("hyper", "<Button-1>", self._click)

        self.links = {}

    def add(self, link):
        tag = "hyper-%d" %

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@w11-z
Comment options

Answer selected by w11-z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants