def select_folder(self):
        self.image_folder = filedialog.askdirectory()
        if self.image_folder:
            image_files = os.listdir(self.image_folder) # Get all files in the selected folder
            self.image_files = [file for file in image_files if file.endswith(self.SUPPORTED_EXTENSIONS)] # Filter image files
            
            if len(self.image_files) > 0:
                self.current_image_index = 0
                self.canvas.pack(fill=tk.BOTH, expand=True)
                self.select_folder_button.pack(side=tk.LEFT, padx=5, pady=5)
                self.root.title("Jesturing in " + self.image_folder)
                self.canvas.config(bg="#808080", highlightthickness=0)
                self.display_image()   
                self.start_button.config(**self.button_style)
            else:
                messagebox.showinfo("No Image Files", "The selected folder does not contain any image files.")
                self.image_folder = ""
                self.root.title("Jestur")

    def set_timer_interval(self):
        self.root.attributes("-topmost", False)
        interval = simpledialog.askinteger("Set Timer Interval", "How many seconds?")        
        if interval:
            if interval < 1:  # Check if interval is less than 1 second
                interval = 1
            self.timer_interval = interval * 1000  # Convert to milliseconds
            self.set_timer_interval = self.timer_interval  # Store the set timer interval
        self.root.lift()  # Bring the main window to the top
        self.root.focus_force()  # Give focus to the main window
        self.root.attributes("-topmost", True)

    def start_pause_slideshow(self, event=None):
        if self.image_folder == "":
            messagebox.showinfo("You haven't picked a folder", "Please select an image folder first.")
        else:
            if self.timer is None:  # Check if timer is not running
                self.display_image()
                self.start_button.config(text="Pause")
                self.is_paused = False  # Set paused flag to False
                self.start_timer()
            else:
                if self.is_paused:  # Check if the slideshow is paused
                    self.start_button.config(text="Pause")
                    self.is_paused = False  # Set paused flag to False
                    self.start_timer()
                else:
                    self.pause_timer()
                    self.start_button.config(text="Start")
                    self.is_paused = True  # Set paused flag to True
    
    def pause_timer(self):
        if self.timer is not None:
            self.root.after_cancel(self.timer)
            self.timer = None

    def start_timer(self):
        if self.image_folder != "" and not self.is_paused:
            self.update_timer()
            self.timer = self.root.after(1000, self.start_timer)

    def update_timer(self):
        seconds_left = int(self.timer_interval / 1000)
        self.timer_label.config(text=f"{seconds_left}")
        self.timer_interval -= 1000

        if self.timer_interval < 0:
            self.timer_interval = self.set_timer_interval  # Use the stored set timer interval
            self.next_image()
			

    def display_image(self):
        if self.image_folder != "" and len(self.image_files) > 0:
            if self.update_switch_timestamps():
                # Show the text of the image name instead of loading the actual image
                image_name = self.image_files[self.current_image_index]
                self.canvas.delete("all")  # Clear the canvas
                self.canvas.create_text(
                    self.canvas.winfo_width() // 2, 
                    self.canvas.winfo_height() // 2,
                    text=image_name,
                    fill="white"
                )
            else:
			# Process the queue and load the image normally if not quick-switching
                 image_path = os.path.join(self.image_folder, self.image_files[self.current_image_index])
                 threading.Thread(target=self.load_image, args=(image_path,)).start()
		
    def update_switch_timestamps(self):
        current_time = time.time()
        self.switch_timestamps.append(current_time)
        self.switch_timestamps = [t for t in self.switch_timestamps if current_time - t <= 1]
        if len(self.switch_timestamps) > 10:
            return True  # Too many updates in a short time period
        return False
		
    def queue_image_loading(self):
        if self.image_loading_queue.full():
            # Clear the queue if it’s full
            with self.image_loading_queue.mutex:
                self.image_loading_queue.queue.clear()
        self.image_loading_queue.put(self.current_image_index)
        self.process_image_loading_queue()

    def process_image_loading_queue(self):
        if not self.image_loading_queue.empty():
            # Only process the last item in the queue
            while self.image_loading_queue.qsize() > 1:
                self.image_loading_queue.get()
            last_index = self.image_loading_queue.get()
            self.root.after_cancel(self.timer) if self.timer else None
            self.current_image_index = last_index
            threading.Thread(target=self.display_image).start()
            self.timer_interval = self.set_timer_interval	
		
    def next_image(self, event=None):
        if self.image_folder != "" and not self.update_switch_timestamps():
            # Update index as before	
            if self.random_next_image_var.get(): # Check if random next image is selected
                self.current_image_index = random.randint(0, len(self.image_files) - 1) # Randomly select the next image index
            else:
                self.current_image_index = (self.current_image_index + 1) % len(self.image_files) # Linearly select the next image index

            target=self.queue_image_loading() # Call the queuing function instead of direct load
            self.timer_interval = self.set_timer_interval  # Use the stored set timer interval
            

    def previous_image(self, event=None):
        if self.image_folder != "" and not self.update_switch_timestamps():  # Check if rapid browsing update is needed
            if self.random_next_image_var.get():  # If True, select a random image
                self.current_image_index = random.randint(0, len(self.image_files) - 1)
            else:  # Otherwise, move to the previous image in the list
                self.current_image_index = (self.current_image_index - 1) % len(self.image_files)
            target=self.queue_image_loading() # Call the queuing function instead of direct load
            self.timer_interval = self.set_timer_interval  # Reset the timer interval

after rapid press it turns into image name only. can you make it so that  in 500ms after i stop the button press it process and loads current image it's supposed to be showing automatically so i don't have to refresh it manually. but only if there's no button press in that 500ms