SIP4 python bindings for TQt
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.

webbrowser.py 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Copyright (C) 2001-2002 Trolltech AS. All rights reserved.
  2. # Copyright (C) 2004 Riverbank Computing Ltd. All rights reserved.
  3. #
  4. # This file is part of an example program for the ActiveTQt integration.
  5. # This example program may be used, distributed and modified without
  6. # limitation.
  7. import sys
  8. from python_tqt import qt
  9. from python_tqt import qtaxcontainer
  10. import mainwindow
  11. class MainWindowImpl(mainwindow.MainWindow):
  12. def init(self):
  13. self.pb = qt.TQProgressBar(self.statusBar())
  14. self.pb.setPercentageVisible(False)
  15. self.pb.hide()
  16. self.statusBar().addWidget(self.pb, 0, True)
  17. self.connect(self.WebBrowser, qt.SIGNAL("ProgressChange(int,int)"), self.setProgress)
  18. self.connect(self.WebBrowser, qt.SIGNAL("StatusTextChange(const TQString&)"), self.statusBar(), qt.SLOT("message(const TQString&)"))
  19. self.WebBrowser.dynamicCall("GoHome()");
  20. self.subwindows = []
  21. def go(self):
  22. self.actionStop.setEnabled(True)
  23. self.WebBrowser.dynamicCall("Navigate(const TQString&)", qt.TQVariant(self.addressEdit.text()))
  24. def setTitle(self, title):
  25. self.setCaption("TQt WebBrowser - " + title.latin1())
  26. def setProgress(self, a, b):
  27. if a <= 0 or b <= 0:
  28. self.pb.hide()
  29. return
  30. self.pb.show()
  31. self.pb.setTotalSteps(b)
  32. self.pb.setProgress(a)
  33. def setCommandState(self, cmd, on):
  34. if cmd == 1:
  35. self.actionForward.setEnabled(on)
  36. elif cmd == 2:
  37. self.actionBack.setEnabled(on)
  38. def navigateBegin(self):
  39. self.actionStop.setEnabled(True)
  40. def navigateComplete(self):
  41. self.actionStop.setEnabled(False)
  42. def newWindow(self):
  43. window = MainWindowImpl()
  44. window.show()
  45. if self.addressEdit.text().isEmpty():
  46. return
  47. window.addressEdit.setText(self.addressEdit.text())
  48. window.actionStop.setEnabled(True)
  49. window.go()
  50. self.subwindows += window
  51. def aboutSlot(self):
  52. qt.TQMessageBox.about(self, self.tr("About WebBrowser"), self.tr(
  53. """This Example has been created using the ActiveTQt integration into TQt Designer.
  54. It demonstrates the use of TQAxWidget to embed the Internet Explorer ActiveX
  55. control into a TQt application."""))
  56. def aboutTQtSlot(self):
  57. qt.TQMessageBox.aboutTQt(self, self.tr("About TQt"))
  58. def main(args):
  59. a = qt.TQApplication(args)
  60. w = MainWindowImpl()
  61. a.setMainWidget(w)
  62. w.show()
  63. return a.exec_loop()
  64. if __name__ == "__main__":
  65. sys.exit(main(sys.argv))