Home > Software design >  How to solve the alpha component ignored in kivy?
How to solve the alpha component ignored in kivy?

Time:08-13

I've got the following code as a part of a project:

class One (Widget):
  
  def _init_(self, **kwargs):

    lib.kwargs.set_kwargs(self, **kwargs)
    
    super(One, self)._init_(**kwargs)  
          
    # Widget position
    self.pos = (lib.config.viewport[self.clientIdIndex][0], 0)
    self.width = lib.config.viewport[self.clientIdIndex][1]
    self.background_path = "images/bgs/"   str(self.clientIdIndex   1)   ".jpg"
    
    self.threshold_reachedMessageSent = False

    self.last_touch = 0
    
    self.points = []
    
    # ZoneOfInterest
    self.shapes = []
    
    for zi in lib.config.zones_of_interest[self.clientIdIndex]:
      self.shapes.append( ZoneOfInterest( img=kivy.core.image.Image(zi[0]),
                                          pos=zi[1],
                                          alpha_index=1))

When I want to run it, I can't see on the screen the clientId when it should be displayed. I get an error and the alpha component is ignored.

CodePudding user response:

I don't have a whole picture of your project, but I think it's because your code contains aplha_index = 1

In your code:

self.shapes.append( ZoneOfInterest( img=kivy.core.image.Image(zi[0]),
                                          pos=zi[1],
                                          alpha_index=1))

alpha_index = 1 should be replaced with 1.0, you cannot assign just 1 as an int to it.

Hope this solves your problem.

  • Related