def __init__(self, master: object, shape: object, value=0, maximum=100, bg='#231303', trough_color='#8a7852', bar_color='#f7f4bf'):
    'Creating the alpha mask and creating a custom widget of the given shape and dimensions.'
    im_shape_alpha = Image.open(shape).convert('L')
    im_shape = Image.new('RGBA', im_shape_alpha.size, bg)
    im_shape.putalpha(im_shape_alpha)
    (width, height) = im_shape_alpha.size
    tk.Canvas.__init__(self, master, bg=trough_color, width=width, height=height, highlightthickness=0)
    self._value = value
    self.maximum = maximum
    self.height = height
    self.width = width
    self.img_trough = ImageTk.PhotoImage(im_shape, master=self)
    self.create_rectangle(0, height, width, (height * (1 - (value / self.maximum))), width=0, fill=bar_color, tags='pbar')
    self.create_image(0, 0, anchor='nw', image=self.img_trough)
Creating the alpha mask and creating a custom widget of the given shape and dimensions.
def __init__(self, master: object, shape: object, value=0, maximum=100, bg='#231303', trough_color='#8a7852', bar_color='#f7f4bf'):
    
    im_shape_alpha = Image.open(shape).convert('L')
    im_shape = Image.new('RGBA', im_shape_alpha.size, bg)
    im_shape.putalpha(im_shape_alpha)
    (width, height) = im_shape_alpha.size
    tk.Canvas.__init__(self, master, bg=trough_color, width=width, height=height, highlightthickness=0)
    self._value = value
    self.maximum = maximum
    self.height = height
    self.width = width
    self.img_trough = ImageTk.PhotoImage(im_shape, master=self)
    self.create_rectangle(0, height, width, (height * (1 - (value / self.maximum))), width=0, fill=bar_color, tags='pbar')
    self.create_image(0, 0, anchor='nw', image=self.img_trough)