Qt is cross platform Desktop framework with IDE Qt Creator. But its code behind is C++.
To replace C++ with Python, we need Python 3.4, PyQt4.11 and Qt4.8.7 download and installed properly
The IDE is Jetbrain PyCharm Community Edition. It can compile/run test GUI but no design surface to work with.
Here is the Python+PyQt+Qt code and Simulate a browser
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
from PyQt4.QtWebKit import QWebView
class BlogBrowser(QDialog):
def __init__(self):
QDialog.__init__(self)
layout=QGridLayout()
self.setLayout(layout)
self.url_ledt=QLineEdit("http://homelab16.blogspot.com")
go_btn=QPushButton("Go")
self.browser=QWebView(self)
self.browser.setUrl(QUrl(self.url_ledt.text()))
layout.addWidget(self.url_ledt,0,0)
layout.addWidget(go_btn,0,1)
layout.addWidget(self.browser,1,0,1,2)
go_btn.clicked.connect(self.navigate)
def navigate(self, txt):
txt=self.url_ledt.text()
if "http://" not in txt:
txt="http://"+txt
self.browser.setUrl(QUrl(txt))
app = QApplication(sys.argv)
bb=BlogBrowser()
bb.show()
app.exec_()
Html5 Test: it scores 240 vs. IE Edge 421 vs. FF 478 vs. Chrome 521 out of max 555
Saturday, March 5, 2016
Write Qt Desktop App using Python
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment