app.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import sys
  4. from qt import *
  5. import scom
  6. from dbus.mainloop.qt3 import DBusQtMainLoop
  7. import mainform
  8. class Window(mainform.mainForm):
  9. def __init__(self, parent=None):
  10. mainform.mainForm.__init__(self, parent)
  11. self.link = scom.Link()
  12. self.connect(self.buttonServices, SIGNAL("clicked()"), self.getServices)
  13. def handleServices(self, package, exception, results):
  14. if not exception:
  15. serviceName, serviceDesc, serviceState = results
  16. self.textServices.append("%s - %s - %s - %s" % (package, serviceName, serviceDesc, serviceState))
  17. def getServices(self):
  18. self.link.System.Service.info(async=self.handleServices)
  19. def main():
  20. app = QApplication(sys.argv)
  21. # Attach DBus to main loop
  22. DBusQtMainLoop(set_as_default=True)
  23. app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
  24. win = Window()
  25. win.show()
  26. # Enter main loop
  27. app.exec_loop()
  28. if __name__ == "__main__":
  29. main()