Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HTML links in a GUI tkinter

685 views
Skip to first unread message

aurel-le-gnou

unread,
Jun 1, 2002, 10:51:11 PM6/1/02
to
Hi,


If you can also help me to realize this, it would be really fine:


How can I put in a frame or in any widget (?) an html link so that the
browser opens at the url indicated when the user clicks ?
Just simply as if it were an HTML link in an HTML document but in a
tkinter GUI ?

What are the packetages to import ?
In what king of widget can I put such a link ?
What kind of lines of code should i put in this widget the link to be
active ?


Thanks a lot for your help


Aurélien Violet
aurelie...@noos.fr


G. Willoughby

unread,
Jun 2, 2002, 5:32:43 PM6/2/02
to
> How can I put in a frame or in any widget (?) an html link so that the
> browser opens at the url indicated when the user clicks ?

I think you can use a Tkinter Text widget, and then specify tags around the
web address:
http://www.pythonware.com/library/tkinter/introduction/x7883-concepts.htm

then:

import os
os.startfile(page.html)

to execute the html file.

--G. Willoughby


Kragen Sitaker

unread,
Jun 2, 2002, 10:51:31 PM6/2/02
to
"G. Willoughby" <ne...@mind.info> writes:
> import os
> os.startfile(page.html)
>
> to execute the html file.

os.startfile is nonportable.

Kragen Sitaker

unread,
Jun 2, 2002, 10:51:48 PM6/2/02
to

Kragen Sitaker

unread,
Jun 2, 2002, 10:53:46 PM6/2/02
to
aurel-le-gnou <aurelie...@noos.fr> writes:
> How can I put in a frame or in any widget (?) an html link so that the
> browser opens at the url indicated when the user clicks ?
> Just simply as if it were an HTML link in an HTML document but in a
> tkinter GUI ?

Sorry about the empty reply --- in Python 2.x, the webbrowser module
has a webbrowser.open() method that does what you want.

Steve Holden

unread,
Jun 3, 2002, 8:13:08 AM6/3/02
to
"Kragen Sitaker" <kra...@pobox.com> wrote in message
news:83elfpr...@panacea.canonical.org...
So, all Aurel needs to know now is how to run wxPython widgets inside
tkinter programs...

regards
--
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------

Eric Brunel

unread,
Jun 3, 2002, 11:23:47 AM6/3/02
to
Steve Holden wrote:
> So, all Aurel needs to know now is how to run wxPython widgets inside
> tkinter programs...

Why? Tkinter has everything to do it:

----------------------------------
from Tkinter import *

root = Tk()
t = Text(root)
t.pack()

def openHLink(event):
start, end = t.tag_prevrange("hlink",
t.index("@%s,%s" % (event.x, event.y)))
print "Going to %s..." % t.get(start, end)

t.tag_configure("hlink", foreground='blue', underline=1)
t.tag_bind("hlink", "<Control-Button-1>", openHLink)
t.insert(END, "This is a link\n")
t.insert(END, "http://www.python.org", "hlink")
t.insert(END, "\nAnd text goes on...\n")
root.mainloop()
----------------------------------

Control-click on the link and you should see the message "Going to <link
text>", which may be replaced by a webbrowser.open to actually open the
URL. To insert a new link, just do:
t.insert(<pos>, <url>, "hlink")

HTH
--
- Eric Brunel <eric....@pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Steve Holden

unread,
Jun 3, 2002, 10:29:57 AM6/3/02
to
"Eric Brunel" <eric....@pragmadev.com> wrote in message
news:adfqa4$pnf$1...@wanadoo.fr...

> Steve Holden wrote:
> > So, all Aurel needs to know now is how to run wxPython widgets inside
> > tkinter programs...
>
> Why? Tkinter has everything to do it:
>
[ ... ]
I cancelled the posting, but of course not quickly enough...

regards
Steve

Kragen Sitaker

unread,
Jun 3, 2002, 12:38:05 PM6/3/02
to
"Steve Holden" <sho...@holdenweb.com> writes:
> "Kragen Sitaker" <kra...@pobox.com> wrote in message
> news:83elfpr...@panacea.canonical.org...
> > Sorry about the empty reply --- in Python 2.x, the webbrowser module
> > has a webbrowser.open() method that does what you want.
>
> So, all Aurel needs to know now is how to run wxPython widgets inside
> tkinter programs...

Why would Aurel want to do that? webbrowser.open() doesn't use
wxPython. At least, I don't have wxPython installed, and it works for
me.

David LeBlanc

unread,
Jun 3, 2002, 2:40:54 PM6/3/02
to
From the sound of his original post, he doesn't want to just open a site in
an external browser, he wants to have clickable links in a tk widget. Maybe
i'm missing something here though.

BTW, there is a Python binding for Richard Hipp's Tk html widget around
somewhere if one really wants webbishness in a tkinter app.

David LeBlanc
Seattle, WA USA

> --
> http://mail.python.org/mailman/listinfo/python-list

0 new messages