torriem at gmail.com
Tue Jan 3 01:22:58 EST 2017
On 01/03/2017 04:32 PM, Deborah Swanson wrote:
> The GUI consoles I have are in Pycharm, the IDLE that comes with
> Anaconda, and Spyder. PyCharm and IDLE both ask for internet access when
> I open them, so they're capable of opening links, but whether that means
> their output space is capable of handling clickable links I don't know.
Hmm I still don't understand what you mean by "GUI console." Just because a
program asks for internet access does not mean anything about whether or not
your python program can display a clickable link in a console window. Besides
that, a clickable link would probably ask the OS to open it with the default
application, not cause your program to access the internet.
The standard out pipe (where stuff goes when you call print() or write to
sys.stdout) from a python program usually goes to a console or a terminal
emulator. PyCharm and IDLE both provide windows to display this output (they
emulate a terminal). But maybe you're misunderstanding what this actually is.
These windows just display a stream of bytes that come out of your program.
Certain escape codes can be emitted that can instruct the console or terminal
emulator to do things like set text color or display text at a certain
position. But there's certainly no special way to instruct the terminal
emulator to make a section of text into a hyperlink. Maybe if hyperlinks had
existed years ago when terminal escape codes were being defined we'd have a
"hyperlink" code that all consoles and terminals would understand. A few years
ago I saw some proposals to add an escape code to the ANSI scheme that would
encode hyperlinks, but nothing ever came of it because, honestly, it would be
too much hassle to roll this out to ever terminal emulator out there (to say
nothing of real terminals).
> I do know printing a full url with the %s specifier or entering a url
> and clicking enter just gives you the plain text url. Obviously, not all
> GUI consoles are enabled recognize and make clickable links from
> correctly formatted urls.
On my Linux machine, the terminal emulators I've used all make a regular url
printed out into a clickable link (or at least a right-clickable link). This
is just something they try to do with all things that look like urls.
Sometimes it's helpful, often it's annoying.
> I was hoping there was some functionality in python to make clickable
> links. Could be a package, if the core language doesn't have it.
No, there is not. If you made a full GUI app using a toolkit like GTK or Qt,
you can indeed place hyperlinks on your forms and the operating system will
automatically connect them to the web browser. But not in text-mode terminal
More information about the Python-list