Clickable hyperlinks

Michael Torrie torriem at
Mon Jan 9 12:27:41 EST 2017

On 01/09/2017 06:00 AM, Deborah Swanson wrote:
> Rhodri James wrote, on January 09, 2017 4:28 AM
>> Nope.  PyCharm outputs text to the console that the console 
>> chooses to 
>> interpret as a link and makes clickable.  As Stephen pointed 
>> out right 
>> back at the beginning of this thread, printing the textual 
>> string that 
>> is a URL could do exactly the same thing *if* the console you 
>> print to 
>> chooses to interpret it as such.  The choice is with the console, not 
>> your program; that there is the incorrect assumption.
> Sorry, Rhodri. I don't agree with your logic. 

You may, but that doesn't change the fact that Rhodri's post is 100%

> You can use tkinter (code
> in a program) to make clickable links in the console, 

Unless you're talking about an implementation of a console or terminal
emulator in tkinter, this is incorrect.  Tkinter does not do anything
with standard out.

> and the webbrowser
> module to web-enable them so urls open in a browser when you click on
> them.
> I have no idea how this crowd got off on the mantra "The choice is with
> the console".  

I guess things keep going in circles because people are just trying to
help you understand what these various parts of the system are and how
they fit together, particularly with regards to so-called "console
applications."  (Text-mode, terminal-based, etc.)

> Code does in fact have the power to control what happens
> in the console.

Other than a pre-arranged protocol (win32 console api, ANSI, VT100, or
similar) between the displayer of the bytes and the python program, code
does not in fact have power to control what happens in the "console."

> How do you think Linux does it on their terminals with
> clickable links? 

This is just the terminal emulator trying to be smart and assuming
meaning in the bytes given to it, which may be a valid assumption on its
part, or may  not.  This is no way implies that all terminal emulators
should do this, nor do most terminal emulators.

> Granted, the code may have to specify parameters for a
> particular console, but I certainly wasn't asking for universal code
> that would work with any console. 

Your initial query back in the beginning did not state this.  Indeed you
never stated which console you wanted to work with. We addressed several
common ones including the Win32 console window (which cmd.exe runs in)
and various terminal emulators.

> That was something made up by the
> responders on the thread, so they could revile me for such an
> outrageously impossible demand. My original question was if Python had
> anything equivalent to the hyperlink formula in Excel, which is a
> program (code) feature. Nothing about doing it on any console in the
> universe.

I read frustration in several posts, but never reviling!

> The developers who wrote PyCharm coded it for the console they were
> using. 

The PyCharm developers built their own window to display "console"
output (standard-out bytes) from the app, and they could have their own
window interpret bytes and messages however they wanted to, and added
their own PyCharm-specific feature including hot links to error
locations (I think that comes from standard-err, though, not
standard-out). So if you want the PyCharm output window to create a
clickable hot-link for you you have to modify the PyCharm code to do that.

> The console is a dead thing, it has no mind or soul to choose
> anything. Surely an educated person would know that.

Not sure what you mean by that?

More information about the Python-list mailing list