autorun.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 import rospy
00019 import sys
00020 import os
00021 import signal
00022 
00023 from roslib.packages import get_pkg_dir
00024 from xml.etree import ElementTree
00025 
00026 from python_qt_binding.QtGui import *
00027 from python_qt_binding.QtCore import *
00028 
00029 from airbus_pyqt_extend.QtAgiCore import get_pkg_dir_from_prefix
00030 
00031 from airbus_cobot_gui.airbus_cobot_gui_main import CobotGuiSplash, \
00032                                      CobotGuiMain
00033                                      
00034 from airbus_pyqt_extend import QtAgiCore
00035 
00036 # Load my generated resources file
00037 from airbus_cobot_gui.res import R
00038 from PyQt4.Qt import QApplication
00039 from PyQt4.uic.Compiler.qtproxies import QtGui
00040 
00041 FULL_SCREEN_ARGS = ["full-screen"   ,"full"   ,"f",
00042                     "-full-screen"  ,"-full"  ,"-f",
00043                     "--full-screen" ,"--full" ,"--f"]
00044 
00045 class GuiApplication(QApplication):
00046     
00047     def __init__(self, args):
00048         QApplication.__init__(self, args)
00049         self.gui = None
00050         
00051     def cleanGui(self):
00052         self.gui.shutdown()
00053     
00054 def run():
00055     
00056     name = 'rqt_gui_py_node_%d' % os.getpid()
00057     rospy.init_node(name, disable_signals=True)
00058     app = GuiApplication(sys.argv)
00059     
00060     splash = CobotGuiSplash()
00061     splash.start()
00062     
00063     window = QMainWindow()
00064     
00065     gui = CobotGuiMain(splash)
00066     config = rospy.get_param("~config", "${airbus_cobot_gui}/config/default.conf")
00067     config = get_pkg_dir_from_prefix(config)
00068     gui.setupUserConfig(config)
00069     
00070     window.setCentralWidget(gui)
00071     window.setGeometry(gui.geometry())
00072     window.setWindowIcon(R.getIconById('airbus_cobot_gui'))
00073     
00074     if gui.getDisplayMode() in FULL_SCREEN_ARGS:
00075         window.showFullScreen()
00076     else:
00077         window.show()
00078     
00079     splash.close()
00080     #Set the gui signal for cleanup
00081     app.gui = gui
00082     app.connect(app, SIGNAL("aboutToQuit()"), app.cleanGui)
00083     
00084     #Set the ctrl+c signal for cleanup
00085     def signal_handler(signal, frame):
00086         app.quit()
00087         
00088     signal.signal(signal.SIGINT, signal_handler)
00089     
00090     #set the rospy shutdown signal
00091     rospy.on_shutdown(app.quit)
00092     
00093     #return of app
00094     sys.exit(app.exec_())
00095 
00096 
00097 if __name__ == "__main__":
00098     run()
00099     
00100 #@endcond


airbus_cobot_gui
Author(s): Martin Matignon
autogenerated on Thu Jun 6 2019 17:59:19