Created
August 24, 2010 15:44
-
-
Save msiahaan/547765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import * | |
from PyQt4.QtWebKit import * | |
from PyQt4.QtNetwork import * | |
class JendelaUtama(QMainWindow): | |
def __init__(self, parent=None): | |
super(JendelaUtama, self).__init__(parent) | |
self.createMenu() # bikin menu | |
self.websettings = QWebSettings #setting untuk browser web | |
self.websettings = { | |
'JavascriptEnabled': True, | |
'AutoLoadImages': True} | |
#widget untuk menampilkan halaman web: QWebView | |
self.twitterView = QWebView(self) | |
self.twitterView.load(QUrl('http://twitter.com/login')) | |
self.setCentralWidget(self.twitterView) | |
self.setWindowTitle("TwitBrow") | |
self.connect (self.twitterView.page().networkAccessManager(), | |
SIGNAL("sslErrors (QNetworkReply *, const QList<QSslError> &)"), | |
self.sslErrorHandler) | |
def createMenu(self): | |
self.programMenu = self.menuBar().addMenu("&Program") | |
self.bantuanMenu = self.menuBar().addMenu("&Bantuan") | |
# bikin action (aksi yang akan dilakukan lewat menu) | |
tentangAction = self.createAction("&Tentang Program", self.bantuanTentang) | |
keluarAction = self.createAction("&Keluar", self.close) | |
# tambahkan aksi ke menu | |
self.bantuanMenu.addAction(tentangAction) | |
self.programMenu.addAction(keluarAction) | |
def createAction(self, text, slot=None, shortcut=None, icon=None, | |
tip=None, checkable=False, signal="triggered()"): | |
action = QAction(text, self) | |
if icon is not None: | |
action.setIcon(QIcon(":/%s.png" % icon)) | |
if shortcut is not None: | |
action.setShortcut(shortcut) | |
if tip is not None: | |
action.setToolTip(tip) | |
action.setStatusTip(tip) | |
if slot is not None: | |
self.connect(action, SIGNAL(signal), slot) | |
if checkable: | |
action.setCheckable(True) | |
return action | |
def sslErrorHandler(self, reply, errorList): | |
reply.ignoreSslErrors() | |
print 'SSL errors ignored' | |
def bantuanTentang(self): | |
QMessageBox.about(self, "Tentang Program", | |
'''<b>TwitBrow</b>, Twitter Browser, | |
Hak Cipta, 2010, @bangmico''') | |
if __name__=='__main__': | |
twitbrow = QApplication(sys.argv) | |
jendelaUtama = JendelaUtama() | |
jendelaUtama.show() | |
sys.exit(twitbrow.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment