THIS WEB BROWSER IS NOT SEASURF. IT IS A VERY BASIC BUT RATHER FUNCTIONAL WEB BROWSER.Β
Here is how to use Python, GTK and WebKit to create a very simple web browser.
First, you will need Python and the GTK and WebKit modules installed.
Here is the code for the basic web browser:
#!/usr/bin/env python
import gtk, webkit, os, pickle
class Basic():
def __init__(self):
self.window = gtk.Window()
self.window.connect('destroy', lambda w: gtk.main_quit())
self.window.set_default_size(640, 480)
self.navigation = gtk.HBox()
self.address_bar = gtk.Entry()
self.gobutton = gtk.Button("GO!")
self.view = gtk.ScrolledWindow()
self.webview = webkit.WebView()
self.webview.open('https://coolchasgamer.wordpress.com')
self.webview.connect('title-changed', self.change_title)
self.webview.connect('load-committed', self.change_url)
self.view.add(self.webview)
self.address_bar.connect('activate', self.load_page)
self.gobutton.connect('clicked', self.load_page)
self.navigation.pack_start(self.address_bar)
self.navigation.pack_start(self.gobutton, False)
self.container = gtk.VBox()
self.container.pack_start(self.navigation, False)
self.container.pack_start(self.view)
self.window.add(self.container)
self.window.show_all()
gtk.main()
def load_page(self, widget):
add = self.address_bar.get_text()
if add.startswith('http://') or add.startswith('https://') or add.startswith('file:///'):
self.webview.open(add)
else:
add = 'http://' + add
self.address_bar.set_text(add)
self.webview.open(add)
def change_title(self, widget, frame, title):
self.window.set_title(title + " - Basic Web Browser")
def change_url(self, widget, frame):
uri = frame.get_uri()
self.address_bar.set_text(uri)
browser = Basic()
The result:
Enjoy!
Epic Chas Gamer π
That looks awesome! Your code looks a lot more complex than mine, I have like half the code you do in my browser!
LikeLiked by 1 person
Well, maybe not half, but I’m pretty sure mine has less code than yours.
LikeLiked by 1 person
Good luck on your web browser π
LikeLiked by 1 person
This web browser isn’t SeaSurf, remember. This is just an example of Python.
And the result of this Basic Web Browser is just an address bar and a go button… Doesn’t even have forward and back! π
LikeLike
Oh, ok ππ»
LikeLiked by 1 person
No need to feel sorry, friend. π
LikeLike
I wasn’t sorry π I just simply said ok as in I understand.
LikeLiked by 1 person
π I understand. Thanks for info π
LikeLiked by 1 person
Hello, I tried testing the code myself but there’s one consistent error that keeps coming up:
def __init__(self):
^
SyntaxError: expected an indented block
Is there any way you can help out? I’d appreciate it a ton.
Thanks,
Kegan
LikeLike
hmmm… well, i haven’t done coding for some time… maybe search google for help on this error?
LikeLike