Take the 2-minute tour ×

i have created a web browser in glade / python and what i'm wanting to do is get HTTP:// to load automatically. Just because at the moment whenever i go to a website i have to type the HTTP:// and if i do not type this then the website does not open and i get a error message.

could anyone please help me out with the code or a way to do this please.

share|improve this question
It works in Firefox. Have you tried Ctrl+Enter? –  Mitch Apr 17 '13 at 17:36
Just add a list of protocols (http, https, ftp, etc) and require that the leading blob be one of them. If it's not prepend the default to the string. –  hbdgaf Apr 17 '13 at 18:03
add comment

1 Answer

up vote 3 down vote accepted

Assuming the address entry is called address_entry, try it like this:

url = address_entry.get_text()
if not "://" in url:
    # Is http a sane prefix?
    url = "http://" + url
share|improve this answer
cheers for that i just got it working tonight i was playing about with some code and it started working. self.webview.open("http://" + url) that is the code that got it to work for me –  DriftedMass Apr 18 '13 at 23:02
@DriftedMass: that doesn't sound like a solution to me. What if the user already typed http://? You end up with an invalid http://http://www.ubuntu.com. –  Timo Apr 19 '13 at 8:30
python is so nice! –  don.joey Apr 19 '13 at 10:31
So if the user had already typed http:// how do you suggest that i cancel out the script running the http:// bit? –  DriftedMass Apr 19 '13 at 12:23
@DriftedMass: see my answer. It will only add http:// if the string :// isn't found in the url. –  Timo Apr 19 '13 at 12:46
show 1 more comment

Your Answer


