Untitled
def __init__(self, parent, bin_id, size=200, base_color='#f5f5f7'): super().__init__( parent, width=size, height=size, bg='white', highlightthickness=0 ) # Store bin_id self.bin_id = bin_id # Add this line to store the bin_id # Keep track of destroyed status self._destroyed = False CircularProgress._instances.append(self) # Initialize properties self.size = size self.stroke_width = 8 self.radius = (size - self.stroke_width) / 2 self.center = size / 2 self.fill_level = 0 self.base_color = base_color self.dark_mode = False # Enhanced animation properties self.last_press_time = 0 self.cooldown_period = 5.0 # Global cooldown between activations self.can_press = True self.is_pressed = False self.press_scale = 1.0 self.press_animation_active = False self.servo_active = False # Animation timing constants self.PRESS_SCALE_MIN = 0.9 self.PRESS_SCALE_MAX = 1.0 self.SCALE_STEP = 0.05 self.SERVO_OPEN_TIME = 10 # Pulse animation properties self.pulse_active = False self.pulse_scale = 1.0 self.pulse_growing = True self.PULSE_MIN = 0.9 self.PULSE_MAX = 1.0 self.PULSE_STEP = 0.007 # Create image for drawing self.im = Image.new('RGBA', (1000, 1000)) self.arc = None # Bind events self.bind('<Button-1>', self.on_press) self.bind('<ButtonRelease-1>', self.on_release) self.bind('<Destroy>', self._on_destroy) # Initialize self.target_fill_level = self.fill_level self.animate() # Set initial fill level self.set_fill_level(random.randint(0, 100)) self.draw()
Leave a Comment