You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pytqt/examples/webbrowser/webbrowser.py

92 lines
2.5 KiB

# Copyright (C) 2001-2002 Trolltech AS. All rights reserved.
# Copyright (C) 2004 Riverbank Computing Ltd. All rights reserved.
#
# This file is part of an example program for the ActiveTQt integration.
# This example program may be used, distributed and modified without
# limitation.
import sys
from PyTQt import tqt
from PyTQt import tqtaxcontainer
import mainwindow
class MainWindowImpl(mainwindow.MainWindow):
def init(self):
self.pb = tqt.TQProgressBar(self.statusBar())
self.pb.setPercentageVisible(False)
self.pb.hide()
self.statusBar().addWidget(self.pb, 0, True)
self.connect(self.WebBrowser, tqt.SIGNAL("ProgressChange(int,int)"), self.setProgress)
self.connect(self.WebBrowser, tqt.SIGNAL("StatusTextChange(const TQString&)"), self.statusBar(), tqt.SLOT("message(const TQString&)"))
self.WebBrowser.dynamicCall("GoHome()");
self.subwindows = []
def go(self):
self.actionStop.setEnabled(True)
self.WebBrowser.dynamicCall("Navigate(const TQString&)", tqt.TQVariant(self.addressEdit.text()))
def setTitle(self, title):
self.setCaption("TQt WebBrowser - " + title.latin1())
def setProgress(self, a, b):
if a <= 0 or b <= 0:
self.pb.hide()
return
self.pb.show()
self.pb.setTotalSteps(b)
self.pb.setProgress(a)
def setCommandState(self, cmd, on):
if cmd == 1:
self.actionForward.setEnabled(on)
elif cmd == 2:
self.actionBack.setEnabled(on)
def navigateBegin(self):
self.actionStop.setEnabled(True)
def navigateComplete(self):
self.actionStop.setEnabled(False)
def newWindow(self):
window = MainWindowImpl()
window.show()
if self.addressEdit.text().isEmpty():
return
window.addressEdit.setText(self.addressEdit.text())
window.actionStop.setEnabled(True)
window.go()
self.subwindows += window
def aboutSlot(self):
tqt.TQMessageBox.about(self, self.tr("About WebBrowser"), self.tr(
"""This Example has been created using the ActiveTQt integration into TQt Designer.
It demonstrates the use of TQAxWidget to embed the Internet Explorer ActiveX
control into a TQt application."""))
def aboutTQtSlot(self):
tqt.TQMessageBox.aboutTQt(self, self.tr("About TQt"))
def main(args):
a = tqt.TQApplication(args)
w = MainWindowImpl()
a.setMainWidget(w)
w.show()
return a.exec_loop()
if __name__ == "__main__":
sys.exit(main(sys.argv))