[PyQt] QWebkit: saving/caching user input
James Polk
jpolk5001 at yahoo.com
Wed Jan 18 02:24:50 GMT 2012
Greetings All,
okay, Back at the front,...
Let's say we use QWebKit to read an HTML file containing a javascript textField...like so:
<html><body>
<p>
<form name="thisForm">
<tr>
<td>Name:</td> <td><input type=text name="name" id="nameId" value="John"></td>
</tr>
</form>
</body></html>
When displayed,..the user types "Mary" into the field, replacing "John".
Then using a method I, uh...derived...from a related web example...
We want to "capture" the HTML being displayed and save it out to file....
But,..we need the resulting file to contain the new user input text "Mary"...not John...
so that on subsequent reloads, the HTML textField will display "Mary",etc...
Here's the snippet to cache...
def DoIt(self):
print "Saving..."
data = self.webview.page().mainFrame().toHtml()
thisFile = "test.html"
open(QtCore.QString(thisFile), 'w').write(data)
print "Done!"
However, it saves out "John" instead of "Mary"....
Can anybody offer any solutions to this ? And/or offer any other suggestions or workarounds
to accomplish same ?
Thank you all very much,
Jim
Both these short files are attached as a zip..
Please NOTE: in the .py file you will need to edit the path to the html file to reflect your environment.
Using "file://" requires absolute paths.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120117/a14644ea/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QWebKitTextCache.zip
Type: application/zip
Size: 1037 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120117/a14644ea/attachment.zip>
More information about the PyQt
mailing list