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