Danila Ganchar Danila Ganchar - 1 year ago 198
Python Question

Python. How to print text to console as hyperlink?

I work with console application. My application uses urwid lib. In some cases I need to show very long hyperlinks into column of table as short text. I want to open link in browser

on text in column.

So, my question is:

It is possible to print message as hyperlink to console?

Can you provide small example how to print text as hyperlink using python?

Answer Source

Yes, using some tools, like gNewt or Curses, you could create a button and 'on click' do an action (like open a browser to a given url).

gNewt : http://gnewt.sourceforge.net/

nCurses : https://docs.python.org/3.7/library/curses.html

Otherwise, it's the terminal application that will manage the text you give it, and if it doesn't implement uri's recognition your program won't work as you'd like.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download