<font size="6"><b>I am currently trying to run:</b></font><br><br><span style="font-family: courier new,monospace;">#!/usr/bin/env python</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># by patx | driver rowinggolfer </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># version fawn | GNU GPL v3</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># <a href="http://patx44.appspot.com/fastpatx">patx44.appspot.com/fastpatx</a></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># other helpers: azazel, trsh, </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># and people from #pyqt on freenode.</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import sys</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">import subprocess</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import time</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">from buzhug import Base</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">from PyQt4 import QtCore, QtGui</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">from PyQt4 import QtWebKit</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class fastpatx(QtGui.QWidget):</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def bookmarkfun(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> bookurl = self.lineEdit.text</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> bookdb = Base('faves').create(('url',str),mode='open')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> bookdb.insert(url=bookurl)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> bookwn = QtGui.QMessageBox.question(self,"fastPATX",</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> "The page has been marked.",</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> QtGui.QMessageBox.Ok)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def viewSrc(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> html = self.browser.page().mainFrame().toHtml()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dialog = QtGui.QDialog(self)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> text = QtGui.QPlainTextEdit(dialog)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> text.setPlainText(html)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ok = QtGui.QPushButton(dialog)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ok.setText('&Ok')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ok.setDefault(True)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(ok, QtCore.SIGNAL('clicked()'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> dialog.accept)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> layout = QtGui.QVBoxLayout()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> layout.addWidget(text)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> layout.addWidget(ok)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> dialog.setLayout(layout)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dialog.exec_()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def goHome(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.browser.setUrl(QtCore.QUrl("<a href="http://www.google.com">http://www.google.com</a>")) </span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def setCurl(self,url):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.curl=url</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.urlString=url.toString()</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def GoLink(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.browser.load(self.curl)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.page=self.browser.page()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.page.setLinkDelegationPolicy(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> QtWebKit.QWebPage.DelegateAllLinks)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def linkClicked(self,url):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.setCurl(url)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.GoLink()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def loadStarted(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> print "loading page...",</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def loadFinished(self,arg):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> print "load finished...",</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if arg:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> print "sucess"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> else:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> print "failed"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.offerDownload()</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def offerDownload(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> result=QtGui.QMessageBox.question(self,"Download File",</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> "download file <br />%s"%self.urlString,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> QtGui.QMessageBox.Yes,<a href="http://QtGui.QMessageBox.No">QtGui.QMessageBox.No</a>)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if result == QtGui.QMessageBox.Yes:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> p=subprocess.Popen(['wget',self.urlString])</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.browser.setHtml("""</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><h2>Downloading your file...</h2></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><hr>Powered by <a href="<a href="http://patx44.appspot.com">http://patx44.appspot.com</a>">fastPATX</a>.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">""")</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> time.sleep(2)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def lineEdited(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.setCurl(QtCore.QUrl(self.lineEdit.text()))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.GoLink()</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def updateLineEdit(self,url):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.setCurl(url)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.lineEdit.setText(self.curl.toString())</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def __init__(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> QtGui.QWidget.__init__(self)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.setCurl(QtCore.QUrl("<a href="http://www.google.com">http://www.google.com</a>"))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.lineEdit = QtGui.QLineEdit()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.pushButton = QtGui.QPushButton('Go')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.homeButton = QtGui.QPushButton('Home')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.srcButton = QtGui.QPushButton('Source')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.bookmark = QtGui.QPushButton('Bookmark')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.browser = QtWebKit.QWebView()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> tab = QtGui.QGridLayout()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> tab.setSpacing(5)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> tab.addWidget(self.browser, 0, 0, 1, 5)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> tab.addWidget(self.lineEdit, 2, 0)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> tab.addWidget(self.pushButton, 2, 1)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> tab.addWidget(self.homeButton, 2, 2)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> tab.addWidget(self.srcButton, 2, 3)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> tab.addWidget(self.bookmark, 2, 4)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.setLayout(tab)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.setWindowTitle('fastPATX')</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.lineEdit, QtCore.SIGNAL('returnPressed()'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.lineEdited)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.pushButton, QtCore.SIGNAL('clicked()'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.lineEdited)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.homeButton, QtCore.SIGNAL('clicked()'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.goHome)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.srcButton, QtCore.SIGNAL('clicked()'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.viewSrc)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.bookmark, QtCore.SIGNAL('clicked()'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.bookmarkfun)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.browser, QtCore.SIGNAL('linkClicked (const QUrl&)'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.linkClicked)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.browser, QtCore.SIGNAL('urlChanged (const QUrl&)'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.updateLineEdit)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.browser, QtCore.SIGNAL('loadStarted ()'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.loadStarted)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.connect(self.browser, QtCore.SIGNAL('loadFinished (bool)'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.loadFinished)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.GoLink()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">app = QtGui.QApplication(sys.argv)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">win = fastpatx()</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">win.show()</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">sys.exit(app.exec_())</span><br clear="all"><br><font size="6"><b>I get the error:<br><br></b></font><span style="font-family: courier new,monospace;"> File "fastpatx-fawn-alpha.py", line 21, in bookmarkfun</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> bookdb.insert(url=bookurl)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> File "/usr/local/lib/python2.6/dist-packages/buzhug/buzhug.py", line 515, in insert</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self._validate(k,v)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> File "/usr/local/lib/python2.6/dist-packages/buzhug/buzhug.py", line 978, in _validate</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> %(k,self.fields[k],v,v.__class__)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">TypeError: Bad type for url : expected <type 'str'>, got <built-in method text of QLineEdit object at 0xa114cac> <type 'builtin_function_or_method'></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">load finished... sucess</span><br><br><font size="6">What am I doing wrong? Please help!</font><br><br>-- <br>patx, python gui<br>