Import Sys
From Pyqt4.qtcore Import *
From Pyqt4.qtgui Import *
From Pyqt4.qtwebkit Import *
Class Mybrowser (Qwidget):
def __init__ (self, parent = None):
Super (Mybrowser, self). __init__ (parent)
Self.createlayout ()
Self.createconnection ()
def search (self):
Address = str (Self.addressBar.text ())
If address:
If Address.find ('://') = =-1:
Address = ' http//' + address
URL = qurl (address)
Self.webView.load (URL)
def createlayout (self):
Self.setwindowtitle ("Keakon ' s Browser")
Self.addressbar = Qlineedit ()
Self.gobutton = Qpushbutton ("&go")
BL = Qhboxlayout ()
Bl.addwidget (Self.addressbar)
Bl.addwidget (Self.gobutton)
Self.webview = Qwebview ()
Layout = Qvboxlayout ()
Layout.addlayout (BL)
Layout.addwidget (Self.webview)
Self.setlayout (Layout)
def createconnection (self):
Self.connect (Self.addressbar, SIGNAL (' returnpressed () '), Self.search)
Self.connect (Self.addressbar, SIGNAL (' returnpressed () '), Self.addressbar, SLOT (' SelectAll () '))
Self.connect (Self.gobutton, SIGNAL (' clicked () '), Self.search)
Self.connect (Self.gobutton, SIGNAL (' clicked () '), Self.addressbar, SLOT (' SelectAll () '))
App = Qapplication (SYS.ARGV)
Browser = Mybrowser ()
Browser.show ()
Sys.exit (App.exec_ ())
PYQT Practice x3.14