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
Asked
Active
Viewed 3,548 times
2

Chops Kingsland
- 45
- 1
- 9
-
I recommend always explicityly settings a key on any element you indent to work with or get an event from. Make it PLAIN text. The PSG convention is "-KEY-". When the event is received, then use your complex string to open the browser. You can store it as metadata if you want it to be with the element. I suggest getting oddly formatted string out of the event processing. – Mike from PSG Feb 13 '21 at 16:42
1 Answers
1
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
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.

Mike from PSG
- 5,312
- 21
- 39
-
A reviewer has pointed out a bug in the PySimpleGUI code. It should be returning an auto-numbered key, but is instead returning the TEXT's contents. I'll add it as a bug. (Thank you, reviewer... I'm sorry I got the review comment so wrong! DOH!) – Mike from PSG Feb 13 '21 at 16:26
-
An issue opened on the project's GitHub... please submit problems you see there so that they're seen and dealt with. Not sure exactly how this one will resolve, but you can track progress on the GitHub. Thank you again to the reviewer for pointing out it's not well dcoumented and perhaps behaving in a way no intended. – Mike from PSG Feb 13 '21 at 16:39