Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@azdle
Last active December 23, 2015 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azdle/6556433 to your computer and use it in GitHub Desktop.
Save azdle/6556433 to your computer and use it in GitHub Desktop.
PyQt Problem -- Fixed with Help From Ryan Hanson on PyQt Mailing List
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
pages = [
"https://portals.exosite.com/views/3819798770/3579834479",
"https://portals.exosite.com/views/2562112089/4128069106",
"https://portals.exosite.com/views/2060811893/1760385000",
"https://exosite:AKYQhkDqj4@logs.exosite.com:444"
]
class MainWindow(QMainWindow):
def __init__(self, *args):
QMainWindow.__init__(self)
self.quitButton = QPushButton("Quit")
vbox = QVBoxLayout()
vbox.addWidget(self.quitButton)
centralWidget = QWidget()
centralWidget.setLayout(vbox)
self.setCentralWidget(centralWidget)
self.quitButton.clicked.connect(self.close)
self.pageView = PageWindow()
self.pageView.show()
class PageWindow(QWebView):
def __init__(self):
QWebView.__init__(self)
self.pageIndex = 0
self.nextPage()
self.setGeometry(QApplication.desktop().screenGeometry(1))
self.showFullScreen()
self.pageTimer = QTimer()
self.pageTimer.timeout.connect(self.nextPage)
self.pageTimer.start(5000)
def nextPage(self):
print("Loading:"+pages[self.pageIndex])
self.load(QUrl(pages[self.pageIndex]))
self.pageIndex = self.pageIndex + 1
if self.pageIndex >= len(pages):
self.pageIndex = 0
def closeEvent(self, event):
self.pageTimer.stop()
event.accept()
def main(args):
app = QApplication(args)
win = MainWindow()
win.show()
app.connect(app, SIGNAL("lastWindowClosed()"),
app, SLOT("quit()"))
app.exec_()
if __name__=="__main__":
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment