#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
These classes contain the links between the GUI and the code
"""
from PyQt4 import QtCore, QtGui
import os, sys
from ihm_menu import Ui_Menu
[docs]class MenuController(QtGui.QWizard):
"""
This function is called at each instantiation of this class. In C and C ++ is a constructor.
It initializes GUI Menu into different steps:
- Link creation with the main interface.
- Graphic interface creation
- Listening events implementation generated by GUI via "connect_signals ()".
"""
def __init__(self, main=None, parent=None):
QtGui.QWidget.__init__(self, parent=parent)
# Keeps link towards high_level application
self.main_app = main
# Draws UI
self.ui = Ui_Menu()
self.ui.setupUi(self)
# Connects signals of UI to self methods
self.connect_signals()
[docs] def connect_signals(self):
"""
This fonction allows to listen signals generated by the GUI, and associates the appropriate treatment
"""
# Correlated buttons with associated actions
self.connect(self, QtCore.SIGNAL("rejected()"), self.main_app.quit)
self.connect(self, QtCore.SIGNAL("finished(int)"), self.main_app.quit)
self.connect(self.ui.ButtonMenuExtraction, QtCore.SIGNAL("clicked()"), self.main_app.switchToExtract)
self.connect(self.ui.ButtonMenuPlace, QtCore.SIGNAL("clicked()"), self.main_app.switchToLieu)
self.connect(self.ui.ButtonMenuAP, QtCore.SIGNAL("clicked()"), self.main_app.switchToAP)
self.connect(self.ui.ButtonMenuMeasure, QtCore.SIGNAL("clicked()"), self.main_app.switchToMesure)
self.connect(self.ui.ButtonMenuSG, QtCore.SIGNAL("clicked()"), self.main_app.switchToSG)
self.connect(self.ui.ButtonMenuImport, QtCore.SIGNAL("clicked()"), self.main_app.switchToImport)
if __name__ == "__main__":
import sys
app= QtGui.QApplication(sys.argv)
scr = ControlerMenu()
scr.show()
sys.exit(app.exec_())