home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / teken / scribus-1.3.3.9-win32-install.exe / share / samples / startup_hook.py < prev    next >
Text File  |  2005-06-30  |  1KB  |  39 lines

  1. #!/usr/bin/env python
  2. # -*- coding: utf8 -*-
  3.  
  4. """
  5. This script is a simple example to show how you can trigger things based on
  6. event hooks provided by Scribus. This sample runs the `gotSignal' method
  7. when the app has finished setting up and it emits the appStarted() signal.
  8. This is useful if, for example, you need access to the main window to
  9. do your setup when running as a startup script.
  10.  
  11. This script isn't very interesting unless you run it as a startup script,
  12. with Scribus running in an xterm, and watch the output on stdout/stderr.
  13.  
  14. You will need PyQt for this script to work.
  15. """
  16.  
  17. try:
  18.     import qt
  19. except:
  20.     print "Seems you don't have PyQt. Doing nothing."
  21.     return
  22.  
  23. from qt import SIGNAL, PYSIGNAL, SLOT
  24.  
  25. # Note that to connect to signals etc you MUST inherit from QObject or a subclass
  26. # of QObject.
  27. class Recipient(qt.QObject):
  28.  
  29.     def __init__(self):
  30.         # Connect ourselves to the "appStarted()" signal emitted by Scribus.
  31.         # Ask PyQt to run the self.gotSignal method when the signal is emitted.
  32.         self.connect(qt.qApp, SIGNAL("appStarted()"), self.gotSignal)
  33.  
  34.     def gotSignal(self):
  35.         print "PONG!"
  36.  
  37. if __name__ == '__main__':
  38.     recip = Recipient();
  39.