Clickable hyperlinks

Dan Strohl D.Strohl at F5.com
Tue Jan 3 04:47:58 EST 2017


Keeping mind how this all works...

Python is providing the data, the console/terminal/app handles how that data is 
displayed.   There is no specification for text output to be hyperlinked (that
I know about at least), so while some apps may handle specific coding to tell 
them that "this text should be a hyperlink", most will either parse the text 
looking for hyper-linkable string, or more commonly, just output the text as 
text.

If you control the app that is displaying info to the user (such as using QT or 
another GUI tool), or generating html yourself, you can control if a text 
string is a hyperlink or not, and what to do with the hyperlink when clicked.

So, if you want clickable links, you would need to find a console/terminal that 
supported them.

Some references:
https://opensource.com/life/15/11/top-open-source-terminal-emulators  (see 
Gnome)
http://unix.stackexchange.com/questions/63417/is-there-a-terminal-app-that-allo
ws-filenames-to-be-clickable
http://superuser.com/questions/654116/configure-os-x-terminal-to-detect-urls-an
d-make-them-clickable
http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/url-launching.html


-----Original Message-----
From: Python-list [mailto:python-list-bounces+d.strohl=f5.com at python.org] On
Behalf Of Deborah Swanson
Sent: Tuesday, January 03, 2017 1:35 PM To: 'Devin Jeanpierre' 
<jeanpierreda at gmail.com>
Cc: 'comp.lang.python' <python-list at python.org>
Subject: RE: Re: Clickable hyperlinks

Devin Jeanpierre wrote, on January 03, 2017 12:57 PM

>Sadly, no. :(  Consoles (and stdout) are just text, not hypertext. The
way to
>make an URL clickable is to use a terminal that makes URLs clickable,
and
>print the URL:
>
>
>print("%s: %s" % (description, url))
>
>
>
>
>-- Devin

I'm sorry, I should have said a GUI console because I wouldn't expect a 
text-based console to produce clickable links. But it appears that a simple GUI 
console can't do it either. I have 3 GUI consoles and in all 3, when I ask:

print("%s: %s" % ("python.org list", 
"https://mail.python.org/mailman/listinfo/python-list"))

I get:
python.org list: https://mail.python.org/mailman/listinfo/python-list

(Outlook made the url clickable here, the python GUI consoles just output plain 
text.)

Pretty clearly the output is plain text because your format parameters are %s. 
Maybe the trick, if there is one, is in a format parameter for urls.



On Tue, Jan 3, 2017 at 11:46 AM, Deborah Swanson <python at deborahswanson.net> 
wrote:

Excel has a formula:

=HYPERLINK(url,description)

that will put a clickable link into a cell.

Does python have an equivalent function? Probably the most common use for it 
would be output to the console, similar to a print statement, but clickable.

--
https://mail.python.org/mailman/listinfo/python-list

--
https://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list