Clickable text links using PySimpleGUI

Viewed 2844

Is it possible to add clickable text links in PySimpleGUI? I've already tried using buttons that then use os.system("start \"\" https://google.com/") or webbrowser.open('www.google.com/', new=0), but, once of the buttons on the window is pressed, all of the others don't work

1 Answers

The documentation is clear on how to do this. The Text element's documentation shows that the enable_events parameter will provide you an event when the text is clicked.

https://pysimplegui.readthedocs.io/en/latest/call%20reference/#text-element

enter image description here

When your text is clicked, the event string returned will be the full string contained in the Text element (including whitespace).

(A thank you to Chris for expanding the answer...)

Generally speaking, I recommend being explicit with keys for elements. It allows the text to change, but the event and the check for the event to remain the same.

The documentation needs some updating to reflect what Chris pointed out. Thanks for taking the time to review this Chris, make the suggestion.

Related