[D-BUS Service] Name=what.ever.yourapp Exec=/opt/yourapp/main.py
[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Terminal=false Name=YourApp Icon=YourApp Exec=/opt/yourapp/main.py X-Osso-Service=what.ever.yourapp
#!/usr/bin/env python2.5 # -*- coding: utf-8 -*- from PyQt4.QtGui import * from PyQt4.QtCore import * import osso # only needed for osso_initialize class MainWindow(QMainWindow): def __init__(self, parent = None): self.dbus_service_name = "what.ever.yourapp" #must be the same as your X-osso-service in yourapp.desktop file """ self.osso_c = osso.Context(self.dbus_service_name, "0.0.1", False) is only needed if your app is not launched from run-standalone.sh, Otherwise, your app will be terminated after ~ 2mins running don't ask me why :) """ self.osso_c = osso.Context(self.dbus_service_name, "0.0.1", False) QMainWindow.__init__(self, parent) self.centralwidget = QWidget(self) self.setCentralWidget(self.centralwidget) """ the rest of your code here.... """ def takeScreenShot(self): pvr = "/home/user/.cache/launch/%s.pvr" % self.dbus_service_name if not QFile.exists(pvr): # skipped if it's already there QPixmap.grabWidget(self.centralwidget).save(pvr, 'png') # tell it to grab only your self.centralwidget screen, which is just window screen without the menu status bar on top. if __name__ == '__main__': import sys app = QApplication(sys.argv) app.setApplicationName("YourAppName") YourApp = MainWindow() YourApp.show() YourApp.takeScreenShot() # run this after the YourApp.show() sys.exit(app.exec_())