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
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
os.startfile is nonportable.
Sorry about the empty reply --- in Python 2.x, the webbrowser module
has a webbrowser.open() method that does what you want.
regards
--
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------
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
regards
Steve
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.
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