code: def selected_value(self, layer_purpose_key):
          
          if layer_purpose_key == layer_purpose_exposure['key']:
              role = RoleExposureConstraint
          elif layer_purpose_key == layer_purpose_hazard['key']:
              role = RoleHazardConstraint
          else:
              return None
  
          selected = self.tblFunctions2.selectedItems()
          if len(selected) != 1:
              return None
          try:
              return selected[0].data(role)
          except (AttributeError, NameError):
              return None
docs: Obtain selected hazard or exposure.
  
          :param layer_purpose_key: A layer purpose key, can be hazard or
              exposure.
          :type layer_purpose_key: str
  
          :returns: A selected hazard or exposure definition.
          :rtype: dict