python at deborahswanson.net
Thu Jan 5 00:11:28 EST 2017
Terry Reedy wrote, on January 04, 2017 3:58 PM
> On 1/4/2017 4:32 AM, Deborah Swanson wrote:
> > My original question was whether python had anything to provide this
> > functionality, and the answer appears to be a resounding NO!!!
> I would say 'Yes, but with user effort'.
> To have a string interpreted as a clickable link, you send the string
> software capable of creating a clickable link, plus the information
> 'this is a clickable link'*. There are two ways to tag a string as a
> link. One is to use markup around the url in the string itself.
> '<url>' and html are example. Python provides multiple to make this
> easy. The other is to tag the string with a separate argument. Python
> provides tkinter, which wraps tk Text widgets, which have a powerful
> system. One can define a Link tag that will a) cause text to be
> displayed, for instance, blue and underlined and b) cause clicks on
> text to generate a web request. One could then use
> mytext.insert('insert', 'http://www.example.com', Link)
> Browser must do something similar when they encounter when they
> encounter html link tags.
I've actually moved on from my original question to one of opening a url
in a browser with python, which seems to be a much more easily achieved
But someone else mentioned tkinter, and I looked at it while ago but
haven't used it for anything. That really could be the way to go if you
want to make clickable links, although you still need some kind of
internet engine to open the url in a browser. PyCharm has clickable
local links in its console output, but they're not internet enabled,
they just jump to the relevant line of code.
You say, "There are two ways to tag a string as a link. One is to use
markup around the url in the string itself. '<url>' and html are
examples. Python provides multiple ways to make this easy."
Can you tell me where I'd begin to look for these? Are they in the core
language, or in packages?
> * If the software directly recognizes a bare url such as
> 'http://www.example.com' as a link, without further
> indication, then it
> should have a way to disable conversion to a clickable link.
One would think so. Thanks for all your info!
> Terry Jan Reedy
More information about the Python-list