Difference between revisions of "Development/Languages/Python/PyKDE WebKit Tutorial/Part4"

Jump to: navigation, search
(New page: Now we want to prepare to add an address bar. Replace the __init__ method with: <code python> self.widget = QWidget() layout = QVBoxLayout(self.widget) self.web...)
 
(oops.)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
Replace the __init__ method with:
 
Replace the __init__ method with:
  
<code python>
+
<syntaxhighlight lang="python">
 
         self.widget = QWidget()
 
         self.widget = QWidget()
  
Line 12: Line 12:
 
         layout.addWidget(self.web)
 
         layout.addWidget(self.web)
 
         self.widget.show()
 
         self.widget.show()
</code>
+
</syntaxhighlight>
  
 
Now instead of having the ''QWebView'' as our top widget we have a plain ''QWidget''.  This widget contains a layout which is not a visible widget but ensure child widgets are put in a sensible place.  It is a ''QVBoxLayout'' which will put widgets in a vertical colum.
 
Now instead of having the ''QWebView'' as our top widget we have a plain ''QWidget''.  This widget contains a layout which is not a visible widget but ensure child widgets are put in a sensible place.  It is a ''QVBoxLayout'' which will put widgets in a vertical colum.
Line 22: Line 22:
 
[[image:Pykde-tutorial-2.png|center]]
 
[[image:Pykde-tutorial-2.png|center]]
  
 +
[[Development/Languages/Python/PyKDE_WebKit_Tutorial/Part3|« Back to Part 3]] |
 
[[Development/Languages/Python/PyKDE_WebKit_Tutorial/Part5|On to Part 5 »]]
 
[[Development/Languages/Python/PyKDE_WebKit_Tutorial/Part5|On to Part 5 »]]
 +
[[Category:Python]]

Latest revision as of 18:16, 27 June 2011

Now we want to prepare to add an address bar.

Replace the __init__ method with:

        self.widget = QWidget()
 
        layout = QVBoxLayout(self.widget)
 
        self.web = QWebView(self.widget)
        self.web.load(QUrl("http://kubuntu.org"))
        layout.addWidget(self.web)
        self.widget.show()

Now instead of having the QWebView as our top widget we have a plain QWidget. This widget contains a layout which is not a visible widget but ensure child widgets are put in a sensible place. It is a QVBoxLayout which will put widgets in a vertical colum.

See the full code.

This version will look the same as the previous.

Pykde-tutorial-2.png

« Back to Part 3 | On to Part 5 »


This page was last modified on 27 June 2011, at 18:16. This page has been accessed 4,779 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal