summaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/webkitsnippets
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-03-02 17:49:28 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-03-02 21:17:57 -0300
commitb94f5359b08e3984c039023b337bfd248a984aee (patch)
tree0058d4ae3a40b2316089eb8ffcbe11a40a59b36b /doc/codesnippets/webkitsnippets
parent97a16f10ab0d0f608a00d3b05497cc6c4a464d2b (diff)
downloadpyside-b94f5359b08e3984c039023b337bfd248a984aee.tar.gz
pyside-b94f5359b08e3984c039023b337bfd248a984aee.tar.xz
pyside-b94f5359b08e3984c039023b337bfd248a984aee.zip
Added some missing code snippets to PySide documentation.
Diffstat (limited to 'doc/codesnippets/webkitsnippets')
-rw-r--r--doc/codesnippets/webkitsnippets/webelement/main.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/doc/codesnippets/webkitsnippets/webelement/main.cpp b/doc/codesnippets/webkitsnippets/webelement/main.cpp
new file mode 100644
index 0000000..3be8a69
--- /dev/null
+++ b/doc/codesnippets/webkitsnippets/webelement/main.cpp
@@ -0,0 +1,65 @@
+
+def traverse():
+//! [Traversing with QWebElement]
+ frame.setHtml("<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>")
+ doc = frame.documentElement()
+ body = doc.firstChild()
+ firstParagraph = body.firstChild()
+ secondParagraph = firstParagraph.nextSibling()
+//! [Traversing with QWebElement]
+
+def findButtonAndClick():
+ frame.setHtml("<form name=\"myform\" action=\"submit_form.asp\" method=\"get\">" \
+ "<input type=\"text\" name=\"myfield\">" \
+ "<input type=\"submit\" value=\"Submit\">" \
+ "</form>")
+
+//! [Calling a DOM element method]
+
+ document = frame.documentElement()
+ # Assume that the document has the following structure:
+ #
+ # <form name="myform" action="submit_form.asp" method="get">
+ # <input type="text" name="myfield">
+ # <input type="submit" value="Submit">
+ # </form>
+
+ button = document.findFirst("input[type=submit]")
+ button.evaluateJavaScript("click()")
+
+//! [Calling a DOM element method]
+
+def autocomplete1():
+ document = frame.documentElement()
+//! [autocomplete1]
+ firstTextInput = document.findFirst("input[type=text]")
+ storedText = firstTextInput.attribute("value")
+//! [autocomplete1]
+
+def autocomplete2():
+ document = frame.documentElement()
+ storedText = "text"
+
+//! [autocomplete2]
+ firstTextInput = document.findFirst("input[type=text]")
+ textInput.setAttribute("value", storedText)
+//! [autocomplete2]
+
+def findAll():
+//! [FindAll]
+ document = frame.documentElement()
+ # Assume the document has the following structure:
+ #
+ # <p class=intro>
+ # <span>Intro</span>
+ # <span>Snippets</span>
+ # </p>
+ # <p>
+ # <span>Content</span>
+ # <span>Here</span>
+ # </p>
+
+//! [FindAll intro]
+ allSpans = document.findAll("span")
+ introSpans = document.findAll("p.intro span")
+//! [FindAll intro] //! [FindAll]