code: def set_alpha_for_selection(self, alpha):
          '''
          Set alpha for selected layer.
          '''
          #  1. Look up selected layer.
          selection = self.treeview_layers.get_selection()
          list_store, selected_iter = selection.get_selected()
  
          # 2. Set alpha value for layer (if selected).
          if selected_iter is None:
              # No layer was selected, so disable scale widget.
              return
          else:
              surface_name, original_alpha = list_store[selected_iter]
  
              self.set_alpha(surface_name, alpha)
              self.set_scale_alpha_from_selection(f set_alpha_for_selection(self, alpha):
          '''
          Set alpha for selected layer.
          '''
          #  1. Look up selected layer.
          selection = self.treeview_layers.get_selection()
          list_store, selected_iter = selection.get_selected()
  
          # 2. Set alpha value for layer (if selected).
          if selected_iter is None:
              # No layer was selected, so disable scale widget.
              return
          else:
              surface_name, original_alpha = list_store[selected_iter]
  
              self.set_alpha(surface_name, alpha)
              self.set_scale_alpha_from_selection()
docs: Set alpha for selected layer.