Source code for gwa.main

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys, os, getpass
from PyQt4 import QtGui, QtCore
from ihm_menu import Ui_Menu
from code_menu import MenuController
from code_place import PlaceController
from code_AP import APController
from code_measure import MeasureController
from code_extract import ExtractController
from code_SG import SGController
from code_import import ImportController


# Declares a list of the screens with their identifiers 
SCREENS = [("Menu", MenuController),
           ("Extract", ExtractController),
           ("Place", PlaceController),
           ("AP", APController),
	   ("SG", SGController),
	   ("Import", ImportController),
           ("Measure", MeasureController)]


[docs]class GWA(QtGui.QApplication): """ Principal Class of the program, it instances the global object. """ def __init__(self, args): """ Constructor """ # Application path self.gwa_path=os.path.dirname(os.path.realpath(__file__)) QtGui.QApplication.__init__(self, args) # The QStackedWidget contains multiple widgets but only displays # one at a time self.scr_mgr = QtGui.QStackedWidget() self.scr_indexes= {} # Creates each screen widget and adds it into the QStackedWidget # Keeps also the index of each the screen widget in order to be # able to display it when asked for idx, (scr_id, scr_class) in enumerate(SCREENS): self.scr_mgr.addWidget(scr_class(main=self)) self.scr_indexes[scr_id] = idx # Starts with first screen self.goToScreen("Menu") self.scr_mgr.show()
[docs] def goToScreen(self, screenId): """ This function is called byt the "switchTo...", function who is used to switch between the differrent interfaces """ self.scr_mgr.setCurrentIndex(self.scr_indexes[screenId])
[docs] def switchToMenu(self): """ This fonction permits to switch on the principal interface """ print ("going to next screen: Menu") self.goToScreen("Menu")
[docs] def switchToExtract(self): """ This fonction is used to switch on the measure extraction screen """ print ("going to next screen: Extract") self.goToScreen("Extract")
[docs] def switchToLieu(self): """ This fonction is used to switch to switch on the environment management screen """ print ("going to next screen: Place") self.goToScreen("Place")
[docs] def switchToAP(self): """ This fonction is used to access Access Point management screen """ print ("going to next screen: AP") self.goToScreen("AP")
[docs] def switchToMesure(self): """ This fonction is used to switch to the "taking measure" screen """ print ("going to next screen: Measure") self.goToScreen("Measure")
[docs] def switchToSG(self): """ This fonction is used to switch to the "show graphics" screen """ print ("going to next screen: Show Graphics") self.goToScreen("SG")
[docs] def switchToImport(self): """ This fonction is used to switch to the "Import XML" screen """ print ("going to next screen: Import XML") self.goToScreen("Import")
[docs] def quit(self): """ This fonction is used to exit the programme """ print ("Close GWA") sys.exit()
if __name__ == "__main__": """ Start Point of the program """ app = GWA(sys.argv) sys.exit(app.exec_()) # GWA must be started with a superuser to be fully functional # if getpass.getuser() != 'root': # print "Please execute GWA using a superuser. Exit." # sys.exit() # else: