Clickable hyperlinks

Deborah Swanson python at deborahswanson.net
Tue Jan 3 10:25:34 EST 2017


Steve D'Aprano wrote, on January 04, 2017 2:20 AM
>
> On Wed, 4 Jan 2017 03:46 pm, Deborah Swanson wrote:
>
> > As I've mentioned in other posts on this thread, I'm now
> thinking that
> > I need to write a class to do this, and find out how
> Firefox and url
> > aware terminals in Linux do it. There must be a way.
>
>
> A GUI application can interpret text any way it chooses.
> Firefox takes a HTML file and renders it, using whatever GUI
> library it chooses. That GUI library understands that text like:
>
> <b>Hello World!</b>
>
> should be shown in bold face, and text like:
>
> <a href="http://www.example.com">Example</a>
>
> should be shown as the word "Example" underlined and in some
> colour, and when you click on it the browser will navigate to
> the URL given. Firefox can do this because it controls the
> environment it runs in.
>
> Same for Excel, which also controls the environment it runs in.
>
> That's *not* the case for Python, which is at the mercy of
> whatever console or terminal application it is running in.
>
> However, you can use Python to write GUI applications. Then it becomes
> *your* responsibility to create the window, populate it with
> any buttons or text or scroll bars you want, and you can
> choose to interpret text any way you like -- including as
> clickable Hyperlinks.
>
> The bottom line is, there is no "a way" to do this. There are
> a thousand, ten thousand, ways to do it. Every web browser,
> every terminal, every URL-aware application, can choose its
> own way to do it. There's no one single way that works
> everywhere, but if you are working in a console or terminal,
> just printing the URL is likely to be interpreted by the
> console as a clickable link:
>
> print("http://www.example.com")
>
>
>
>
> --
> Steve
> "Cheer up," they said, "things could be worse." So I cheered
> up, and sure enough, things got worse.

I can appreciate all that and pretty much knew most of it already. At this 
point I'm not so much concerned with how to put characters on a white space 
that are clickable, we've pretty much established at least a couple dozen 
messages ago that there's nothing for python to get hold of there because of 
the vast number of places people might want to put clickable links. (I actually 
read every message on a thread that interests me enough to participate.)

I think the entry point to this problem is to find out how to connect to the 
internet when you click that link. Then I think the nuts and bolts of what 
symbols to put where for a particular target would fall into place.



More information about the Python-list mailing list