Source code for gwa.code_place

#!/usr/bin/python
# -*- coding: utf-8 -*-
# Translation in English by David Dumas

"""
Contains the links between the UI and the measurements code.
"""

import sys
import re
import string
import time
import pg
import logging
import ConfigParser

from PyQt4 import QtGui, QtCore
from code.DBA import *
from ihm_place import *
from code.popups import *



[docs]class PlaceController(QtGui.QWizard): """ Create the wizard. Assign functions to the various buttons. """ def __init__(self, main=None, parent=None): """ Called every time this class is instantiated. It’s the equivalent of a class constructor in C/C++. It initializes the UI of the measurement part in four steps: - Creation of the link with the main UI - Creation of the UI - Creation of the event listeners generated by the UI via “connect_signals()” - Variables initializations via “initVariables()” """ QtGui.QWidget.__init__(self, parent=parent) # Keeps link towards high_level application self.main_app = main # Draws UI self.ui = Ui_Place() self.ui.setupUi(self) # Connects signals of UI to self methods self.connect_signals() #Initialise les variables self.initVariables()
[docs] def initVariables(self): """ Initialize the variables necessary to do measures and connect to the database. """ # Init various variables to false self.ui.toolButton_environment_add.setEnabled(False) self.ui.toolButton_environment_delete.setEnabled(False) self.ui.toolButton_environment_edit.setEnabled(False) self.ui.toolButton_place_add.setEnabled(False) self.ui.toolButton_place_delete.setEnabled(False) self.ui.toolButton_place_edit.setEnabled(False) # Définition des attributs self.idsEnvironnements = {} # Dictionary to store the environement in the UI { key => string displayed : value => environnement ID (in the database) } self.id_environnement = [] # Environnement ID selected by the user (Window 1) self.info_environnement = "" # Environnement selected selected by the user self.idsLieux = {} # Dictionary to store the places displayed in the UI { key => string displayed : value => place ID (in the database) } self.id_lieux = [] # Place ID selected by the user (Window 2) self.info_lieu = "" # Place selected by the user # Connect to the database with the parameters from the conf file self.db = DBConnect(main=self.main_app) # Instanciation of class Popup self.popup=Popups()
[docs] def connect_signals(self): """ Create action listeners for the UI. Example: self.connect(self.ui.toolButton_place_add,QtCore.SIGNAL("clicked()"),self.addPlace) When the bouton “self.ui.toolButton_place_add” is clicked, function “addPlace()” is called. """ # Buttons links with functions self.connect(self, QtCore.SIGNAL("currentIdChanged(int)"), self.switchPage) self.connect(self, QtCore.SIGNAL("rejected()"), self.main_app.switchToMenu) self.connect(self, QtCore.SIGNAL("finished(int)"), self.reinitialize) self.connect(self.ui.listWidget_environment_list, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.displayEnvironmentInfo) self.connect(self.ui.toolButton_environment_delete,QtCore.SIGNAL("clicked()"),self.removeEnvironment) self.connect(self.ui.toolButton_environment_edit,QtCore.SIGNAL("clicked()"),self.editEnvironment) self.connect(self.ui.toolButton_environment_add,QtCore.SIGNAL("clicked()"),self.addEnvironment) # Grey out the add environment button when the fields are not filled self.connect(self.ui.lineEdit_environment_name,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddEnvironment) self.connect(self.ui.lineEdit_environment_length,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddEnvironment) self.connect(self.ui.lineEdit_environment_width,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddEnvironment) self.connect(self.ui.lineEdit_environment_height,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddEnvironment) # Grey out the delete environment button when no environment is selected self.connect(self.ui.listWidget_environment_list, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.enableRemoveEnvironment) # Grey out the update environment button when no environment is selected self.connect(self.ui.listWidget_environment_list, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.enableEditEnvironment) self.connect(self.ui.listWidget_place_list, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.displayPlaceInfo) self.connect(self.ui.toolButton_place_delete,QtCore.SIGNAL("clicked()"),self.removePlace) self.connect(self.ui.toolButton_place_edit,QtCore.SIGNAL("clicked()"),self.editPlace) self.connect(self.ui.toolButton_place_add,QtCore.SIGNAL("clicked()"),self.addPlace) # Grey out the add place button when the fields are not filled self.connect(self.ui.lineEdit_place_name,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) self.connect(self.ui.lineEdit_place_length,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) self.connect(self.ui.lineEdit_place_width,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) self.connect(self.ui.lineEdit_place_height,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) self.connect(self.ui.lineEdit_place_coor_x,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) self.connect(self.ui.lineEdit_place_coor_y,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) self.connect(self.ui.lineEdit_place_coor_z,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) self.connect(self.ui.lineEdit_place_angle,QtCore.SIGNAL("textChanged (const QString&)"),self.enableAddPlace) # Grey out the delete place button when no place is selected self.connect(self.ui.listWidget_place_list, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.enableRemovePlace) # Grey out the update place button when no place is selected self.connect(self.ui.listWidget_place_list, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.enableEditPlace)
[docs] def switchPage(self): """ Called whenever a UI page change occurs to initialize: - Lists fulfillment (pages 1 to 4) - Measurements (page 5) - Completion of the measures (page 6) """ if self.currentId() == 1: logging.info('Page : Environnement') self.displayEnvironmentList() if self.currentId() == 3: logging.info('Page : Lieux') self.displayPlaceList() self.clearPlaceInfo()
[docs] def reinitialize(self, resultCode): """ Switch to the application master menu and reinitializes the QWizard module. """ self.main_app.switchToMenu() self.restart()
[docs] def validateCurrentPage(self): """ Reimplementation of the function “validateCurrentPage” which implements by default “QWizardPage::validatePage()” on “currentPage()”. """ # Check if any environnement is selected if self.currentId() == 1: if not self.ui.listWidget_environment_list.currentItem(): return False return True
[docs] def displayEnvironmentList(self): """ Display the list of environments in the UI. """ # Empty the list in the UI self.ui.listWidget_environment_list.clear() # Select the name, coordinates X,Y,Z and the description of places in the database resultat_sql=self.db.select('area',['id_area','name','length','width','height','description']) # Update the list in the UI with the info retrieved just before for id_area,name, length, width, height, description in resultat_sql: chaine = "Environnement %s de dimension (%i,%i,%i) : %s" % (name, length, width, height, description) # Store the environments ID in a list self.idsEnvironnements[chaine] = id_area self.ui.listWidget_environment_list.addItem(chaine) # Grey out delete environment and add environment buttons self.ui.toolButton_environment_delete.setEnabled(False) self.ui.toolButton_environment_edit.setEnabled(False)
[docs] def clearEnvironmentInfo(self): """ Clear the user filled fields. Called when the Access Points list is updated in UI with addEnvironment() and editEnvironment(). """ # Empty fields self.ui.lineEdit_environment_name.clear() self.ui.textEdit_environment_description.clear() self.ui.textEdit_environment_origin_info.clear() self.ui.lineEdit_environment_length.clear() self.ui.lineEdit_environment_width.clear() self.ui.lineEdit_environment_height.clear()
[docs] def verifyEnvironmentInfos(self, longueur, largeur, hauteur): """ Integrity check of the user’s input before insertion in the database. Verify the environment's dimensions are numbers. """ # Verify the input (integers) try: if type(int(longueur))==type(1) and type(int(largeur))==type(1) and type(int(hauteur))==type(1): # Conditions satisfied ==> return True return True except : self.popup.popupOK("Error","The values you have entered are incorrect. Please correct them.") self.displayEnvironmentList() return False
[docs] def addEnvironment(self): """ Add an environment in the database. """ # Retrieve the info filled in the UI nom_environnement = str(self.ui.lineEdit_environment_name.text()) desc_environnement = str(self.ui.textEdit_environment_description.toPlainText()) origin_environnement = str(self.ui.textEdit_environment_origin_info.toPlainText()) longueur = str(self.ui.lineEdit_environment_length.text()) largeur = str(self.ui.lineEdit_environment_width.text()) hauteur = str(self.ui.lineEdit_environment_height.text()) # Create a dictionary allowing to define parameters that will be loaded in the database dico = {'name':nom_environnement,'description':desc_environnement, 'length':longueur, 'width':largeur, 'height':hauteur,'x_coordinate_area':0, 'y_coordinate_area':0, 'z_coordinate_area':0,'origin_info':origin_environnement} # Insert in the database if the conditions are satisfied if self.verifyEnvironmentInfos(longueur, largeur, hauteur): try: # Insert in the database with the DBA module and the function 'insert', retrieve the added environment's ID. id_environnement = self.db.insertAndReturn("area",dico,'id_area') # If it suceeds, empty the fields self.clearEnvironmentInfo() except pg.DatabaseError, exc: # If there is an error, warn the user with a popup self.popup.popupOK("Error", "This environment already exists in the database, use the edit button to modify it.") # Update the list self.displayEnvironmentList()
[docs] def removeEnvironment(self): """ Remove an environment from the database. """ #Affichage de la liste des environnements self.displayEnvironmentList() #Affichage d'un bouton de confirmation avant la suppression d'un environnement if self.popup.popupYesNo("Warning", "Do you really want to remove the selected environment\n \"%s\" ?" % self.info_environnement): #Suppression de l'area dans la BDD self.db.delete("area",{'id_area':self.id_environnement}) #Mise à jour de la liste des area dans l'interface graphique self.displayEnvironmentList() self.clearEnvironmentInfo()
[docs] def editEnvironment(self): """ Edit an environment's parameters in the database. """ # Retrieve the info filled in the UI nom_environnement = str(self.ui.lineEdit_environment_name.text()) desc_environnement = str(self.ui.textEdit_environment_description.toPlainText()) origin_environnement = str(self.ui.textEdit_environment_origin_info.toPlainText()) longueur = str(self.ui.lineEdit_environment_width.text()) largeur = str(self.ui.lineEdit_environment_length.text()) hauteur = str(self.ui.lineEdit_environment_height.text()) # Integrity check on the modified fields if self.verifyEnvironmentInfos(longueur, largeur, hauteur): # Update the parameters of the environment in the database self.db.update("area", "name",'\''+ nom_environnement+'\'', {'id_area':self.id_environnement}) self.db.update("area", "length", longueur, {'id_area':self.id_environnement}) self.db.update("area", "width", largeur, {'id_area':self.id_environnement}) self.db.update("area", "height", hauteur, {'id_area':self.id_environnement}) self.db.update("area", "description",'\''+ desc_environnement+'\'', {'id_area':self.id_environnement}) self.db.update("area", "origin_info",'\''+ origin_environnement+'\'', {'id_area':self.id_environnement}) # Clear the fields if the edit succeeds self.clearEnvironmentInfo() # Update the AP list in the UI self.displayEnvironmentList()
[docs] def displayEnvironmentInfo(self): """ Cette fonction permet d'afficher les paramètres de lu environnement lors de la sélection d'un élément de la lister """ #Récupération de l'id de l'environnement sélectionné self.setCurrentEnvironment() #Récupération des informations de la ligne sélectionnée resultat_sql = self.db.select('area',['name','length','width',\ 'height','description','origin_info'],{'id_area':self.id_environnement}) #Affichage des paramètres dans les champs d'ajout/modification de l'IHM for name, length, width, height, description, origin_info in resultat_sql: self.ui.lineEdit_environment_name.setText(QtCore.QLatin1String(str(name))) self.ui.lineEdit_environment_length.setText(QtCore.QLatin1String(str(length))) self.ui.lineEdit_environment_width.setText(QtCore.QLatin1String(str(width))) self.ui.lineEdit_environment_height.setText(QtCore.QLatin1String(str(height))) self.ui.textEdit_environment_description.setText(QtCore.QLatin1String(str(description))) self.ui.textEdit_environment_origin_info.setText(QtCore.QLatin1String(str(origin_info)))
[docs] def setCurrentEnvironment(self): """ Retrieve the name and database ID of the selected environment. """ # Retrieve the ligne selected in the UI ligne_select = str(self.ui.listWidget_environment_list.currentItem().text()) # Retrieve the ID self.id_environnement = self.idsEnvironnements[ligne_select] # Retrieve the ligne for the popup self.info_environnement = ligne_select
[docs] def enableAddEnvironment(self): """ Activates / deactivates the button add environment. The button becomes active only when the user fills the required fields. """ # Check if the fields exist, if yes: activate the add button / if no: the add button remains greyed out if self.ui.lineEdit_environment_name.text() and self.ui.lineEdit_environment_length.text() and self.ui.lineEdit_environment_width.text() and self.ui.lineEdit_environment_height.text(): self.ui.toolButton_environment_add.setEnabled(True) else : self.ui.toolButton_environment_add.setEnabled(False)
[docs] def enableRemoveEnvironment(self, itemClicked): """ Activates / deactivates the button delete environment whenever an environment is selected in the list. """ if itemClicked: self.ui.toolButton_environment_delete.setEnabled(True) else : self.ui.toolButton_environment_delete.setEnabled(False)
[docs] def enableEditEnvironment(self, itemClicked): """ Activates / deactivates the button edit environment whenever an environment is selected in the list. """ if itemClicked: self.ui.toolButton_environment_edit.setEnabled(True) else : self.ui.toolButton_environment_edit.setEnabled(False)
[docs] def displayPlaceList(self): """ Display the list of places in the UI. """ # Empty the list in the UI self.ui.listWidget_place_list.clear() # Select the name, coordinates X,Y,Z and the description of places in the database resultat_sql=self.db.select('place',['id_place','name','description'],{'id_area':self.id_environnement}) self.idsLieux = {} # Update the list in the UI with the info retrieved just before for id_place,name, description in resultat_sql: chaine = "%s : %s" % (name, description) # Store the places ID in a list self.idsLieux[chaine] = id_place self.ui.listWidget_place_list.addItem(chaine) # Grey out delete place and add place buttons self.ui.toolButton_place_delete.setEnabled(False) self.ui.toolButton_place_edit.setEnabled(False)
[docs] def clearPlaceInfo(self): """ Clear the user filled fields. Called whenever the place list is updated. """ # Empty all the fields self.ui.lineEdit_place_name.clear() self.ui.textEdit_place_description.clear() self.ui.textEdit_place_origin_info.clear() self.ui.lineEdit_place_length.clear() self.ui.lineEdit_place_width.clear() self.ui.lineEdit_place_height.clear() self.ui.lineEdit_place_coor_x.clear() self.ui.lineEdit_place_coor_y.clear() self.ui.lineEdit_place_coor_z.clear() self.ui.lineEdit_place_angle.clear()
[docs] def verifyPlaceInfo(self,longueur_lieux, largeur_lieux, hauteur_lieux, x_lieux, y_lieux, z_lieux, angle): """ Integrity check of the user’s input before insertion in the database. Verify the input is numbers. Verify the place's dimensions and coordinates consistency in the environement. """ # Verify the input (integers) try: if type(int(longueur_lieux))==type(1) and type(int(largeur_lieux))==type(1) and type(int(hauteur_lieux))==type(1) and type(int(x_lieux))==type(1) and type(int(y_lieux))==type(1) and type(int(z_lieux))==type(1) and type(int(angle))==type(1): # Verify coordinate x longueur_environnement = self.db.select('area',['length'], {'id_area':self.id_environnement})[0][0] if int(x_lieux) > longueur_environnement: if not self.popup.popupYesNo("Out of local area","Warning, you have specified a place where the x coordinate is greater than the environment's length (%dm). Do you really want to continue ?" % longueur_environnement): self.displayPlaceList() return False # Verify coordinate y largeur_environnement = self.db.select('area',['width'], {'id_area':self.id_environnement})[0][0] if int(y_lieux) > largeur_environnement: if not self.popup.popupYesNo("Out of local area","Warning, you have specified a place where the y coordinate is greater than the environment's width (%dm). Do you really want to continue ?" % largeur_environnement): self.displayPlaceList() return False # Verify coordinate z hauteur_environnement = self.db.select('area',['height'], {'id_area':self.id_environnement})[0][0] if int(z_lieux) > hauteur_environnement: if not self.popup.popupYesNo("Out of local area","Warning, you have specified a place where the z coordinate is greater than the environment's height (%dm). Do you really want to continue ?" % hauteur_environnement): self.displayPlaceList() return False # Verify angle if int(angle) < 0 or int(angle) > 360: if not self.popup.popupYesNo("Incorrect specified angle","Attention, vous avez specifie un angle non compris entre 0 et 360. Voulez-vous vraiment continuer ?"): self.displayPlaceList() return False # Conditions satisfied ==> return True return True # If the user inputs incorrect values, warn him with a popup. except : self.popup.popupOK("Error","The values you have entered are incorrect. Please correct them.") self.displayPlaceList() return False
[docs] def addPlace(self): """ Add a place into the database. """ # Retrieve the info filled in the UI nom_lieux = str(self.ui.lineEdit_place_name.text()) desc_lieux = str(self.ui.textEdit_place_description.toPlainText()) origin_lieux = str(self.ui.textEdit_place_origin_info.toPlainText()) longueur_lieux = str(self.ui.lineEdit_place_length.text()) largeur_lieux = str(self.ui.lineEdit_place_width.text()) hauteur_lieux = str(self.ui.lineEdit_place_height.text()) x_lieux = str(self.ui.lineEdit_place_coor_x.text()) y_lieux = str(self.ui.lineEdit_place_coor_y.text()) z_lieux = str(self.ui.lineEdit_place_coor_z.text()) angle = str(self.ui.lineEdit_place_angle.text()) # Retrieve the place the user is working with self.setCurrentEnvironment() # Create a dictionary allowing to define parameters that will be loaded in the database dico = {'name':nom_lieux,'length':longueur_lieux,'width':largeur_lieux,'height':hauteur_lieux,'x_coordinate_area':x_lieux,'y_coordinate_area':y_lieux,'z_coordinate_area':z_lieux,'angle':angle,'description':desc_lieux, 'origin_info':origin_lieux,'id_area':self.id_environnement} # Insert in the database if the conditions are satisfied if self.verifyPlaceInfo(longueur_lieux, largeur_lieux, hauteur_lieux, x_lieux, y_lieux, z_lieux, angle): try: # Insert in the database with the DBA module and the function 'insert', retrieve the added place's ID. self.id_lieux = self.db.insertAndReturn("place", dico, 'id_place') # If it suceeds, empty the fields self.clearPlaceInfo() except pg.DatabaseError, exc: # If there is an error, warn the user with a popup self.popup.popupOK("Error", "This place already exists in the database, use the edit button to modify it.") # Update the list self.displayPlaceList()
[docs] def removePlace(self): """ Remove a place from the database. """ # Diplsay the loocation list self.displayPlaceList() # Pop up a confirmation dialog to delete the place if self.popup.popupYesNo("Warning", "Do you really want to remove the selected place\n \"%s\" ?" % self.info_lieu): # Delete the place from the database after confirmation self.db.delete("place",{'id_place':self.id_lieux}) # Update the AP list in the UI self.displayPlaceList() # Clear the fields self.clearPlaceInfo()
[docs] def editPlace(self): """ Edit a place's parameter in the database. """ # Retrieve the info filled in the UI nom_lieux = str(self.ui.lineEdit_place_name.text()) desc_lieux = str(self.ui.textEdit_place_description.toPlainText()) origin_lieux = str(self.ui.textEdit_place_origin_info.toPlainText()) longueur_lieux = str(self.ui.lineEdit_place_length.text()) largeur_lieux = str(self.ui.lineEdit_place_width.text()) hauteur_lieux = str(self.ui.lineEdit_place_height.text()) x_lieux = str(self.ui.lineEdit_place_coor_x.text()) y_lieux = str(self.ui.lineEdit_place_coor_y.text()) z_lieux = str(self.ui.lineEdit_place_coor_z.text()) angle = str(self.ui.lineEdit_place_angle.text()) # Integrity check on the modified fields if self.verifyPlaceInfo(longueur_lieux, largeur_lieux, hauteur_lieux, x_lieux, y_lieux, z_lieux, angle): # Update the parameters of the place in the database self.db.update("place", "name", '\''+nom_lieux+'\'', {'id_place':self.id_lieux}) self.db.update("place", "length", longueur_lieux, {'id_place':self.id_lieux}) self.db.update("place", "width", largeur_lieux, {'id_place':self.id_lieux}) self.db.update("place", "height", hauteur_lieux, {'id_place':self.id_lieux}) self.db.update("place", "x_coordinate_area", x_lieux, {'id_place':self.id_lieux}) self.db.update("place", "y_coordinate_area", y_lieux, {'id_place':self.id_lieux}) self.db.update("place", "z_coordinate_area", z_lieux, {'id_place':self.id_lieux}) self.db.update("place", "angle", angle, {'id_place':self.id_lieux}) self.db.update("place", "description", '\''+desc_lieux+'\'', {'id_place':self.id_lieux}) self.db.update("place", "origin_info", '\''+origin_lieux+'\'', {'id_place':self.id_lieux}) # Clear the fields if the edit succeeds self.clearPlaceInfo() # Update the place list in the UI self.displayPlaceList()
[docs] def displayPlaceInfo(self): """ Display the place’s parameters when an element is selected in the list. """ self.setCurrentPlace() # Retrieve the ID of the selected place resultat_sql = self.db.select('place',['name','length','width','height','x_coordinate_area','y_coordinate_area','z_coordinate_area','angle','description','origin_info'],{'id_place':self.id_lieux}) # Display the parameters in the add / modify fields of the UI for name, length, width, height, x_coordinate_area, y_coordinate_area, z_coordinate_area, angle, description, origin_info in resultat_sql: self.ui.lineEdit_place_name.setText(QtCore.QLatin1String(str(name))) self.ui.lineEdit_place_length.setText(QtCore.QLatin1String(str(length))) self.ui.lineEdit_place_width.setText(QtCore.QLatin1String(str(width))) self.ui.lineEdit_place_height.setText(QtCore.QLatin1String(str(height))) self.ui.lineEdit_place_coor_x.setText(QtCore.QLatin1String(str(x_coordinate_area))) self.ui.lineEdit_place_coor_y.setText(QtCore.QLatin1String(str(y_coordinate_area))) self.ui.lineEdit_place_coor_z.setText(QtCore.QLatin1String(str(z_coordinate_area))) self.ui.lineEdit_place_angle.setText(QtCore.QLatin1String(str(angle))) self.ui.textEdit_place_description.setText(QtCore.QLatin1String(str(description))) self.ui.textEdit_place_origin_info.setText(QtCore.QLatin1String(str(origin_info)))
[docs] def setCurrentPlace(self): """ Retrieve the name and database ID of the selected place. """ # Retrieve the ligne selected in the UI ligne_select = str(self.ui.listWidget_place_list.currentItem().text()) # Retrieve the ID self.id_lieux = self.idsLieux[ligne_select] self.info_lieu = ligne_select
[docs] def enableAddPlace(self): """ Activates / deactivates the button to add places. The button becomes active only when the user fills the required fields. """ # Check if the fields exist, if yes: activate the place button / if no: the place button remains greyed out if self.ui.lineEdit_place_name.text() and self.ui.lineEdit_place_length.text() \ and self.ui.lineEdit_place_width.text() and self.ui.lineEdit_place_height.text() \ and self.ui.lineEdit_place_coor_x.text() and self.ui.lineEdit_place_coor_y.text() \ and self.ui.lineEdit_place_coor_z.text() and self.ui.lineEdit_place_angle.text(): self.ui.toolButton_place_add.setEnabled(True) else : self.ui.toolButton_place_add.setEnabled(False)
[docs] def enableRemovePlace(self, itemClicked): """ Activates / deactivates the button delete place whenever an place is selected in the list. """ if itemClicked: self.ui.toolButton_place_delete.setEnabled(True) else : self.ui.toolButton_place_delete.setEnabled(False)
[docs] def enableEditPlace(self, itemClicked): """ Activates / deactivates the button edit place whenever an edit is selected in the list. """ if itemClicked: self.ui.toolButton_place_edit.setEnabled(True) else : self.ui.toolButton_place_edit.setEnabled(False)
if __name__ == "__main__": import sys app= QtGui.QApplication(sys.argv) scr = ControleurLieu() scr.show() sys.exit(app.exec_())