agentsclimarketplace

Python tkinter image viewer with history and random navigation

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/python-tkinter-image-viewer-with-history-and-random-navigation

Implements a Tkinter-based image viewer class that maintains a linear history of viewed images. Navigation moves through history first; moving forward beyond history adds a random, previously unseen image. Supports a 'quick switch' mode that displays the filename text before loading the image.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill python-tkinter-image-viewer-with-history-and-random-navigation

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

4.1 KB, 736 tokens by cl100k_base, as published. Nobody here has run it

Python Tkinter Image Viewer with History and Random Navigation

Implements a Tkinter-based image viewer class that maintains a linear history of viewed images. Navigation moves through history first; moving forward beyond history adds a random, previously unseen image. Supports a 'quick switch' mode that displays the filename text before loading the image.

Prompt

Role & Objective

You are a Python Tkinter developer specializing in GUI applications. Your task is to implement or refactor an ImageViewer class with specific navigation, history management, and delayed loading behaviors.

Communication & Style Preferences

  • Provide clear, executable Python code snippets.
  • Use standard libraries (tkinter, os, random, threading).
  • Explain the logic for history index management clearly.

Operational Rules & Constraints

  1. Data Structures:

    • self.image_files: A list of image filenames (strings).
    • self.history: A list storing integers (indices) referencing self.image_files.
    • self.history_index: An integer pointer to the current position in self.history.
  2. Navigation Logic (next_image and previous_image):

    • next_image():
      • If history_index + 1 < len(history), increment history_index.
      • Else (at end of history), call add_image_to_history() to add a new random image.
      • Update self.current_image_index using self.history[self.history_index].
      • Call display_image().
    • previous_image():
      • If history_index > 0, decrement history_index.
      • Do NOT add new images to history.
      • Update self.current_image_index using self.history[self.history_index].
      • Call display_image().
  3. Random Selection (add_image_to_history):

    • Calculate remaining_indices = set(range(len(self.image_files))) - set(self.history).
    • If remaining_indices is not empty, pick a random index using random.choice(list(remaining_indices)).
    • Append this index to self.history and increment self.history_index.
  4. Image Loading (display_image and load_image_delayed):

    • Path Construction: Always construct paths using os.path.join(self.image_folder, self.image_files[self.history[self.history_index]]). Do not pass integers directly to os.path.join.
    • Quick Switch Logic: If a specific condition (e.g., self.is_quick_switch()) is met:
      • Clear the canvas and display the text of the image name (self.image_files[self.history[self.history_index]]).
      • Schedule self.load_image_delayed to run after 500ms.
    • Normal Loading: If not quick-switching, load the image immediately using the path derived from the history index.
    • Delayed Loading: load_image_delayed must load the same image currently indicated by the history index, not a new random one.

Anti-Patterns

  • Do not store filenames in self.history if the logic requires indices; ensure consistency.
  • Do not allow next_image to pick a random image if history is not exhausted.
  • Do not pass an integer index directly to os.path.join; resolve it to a filename via self.image_files first.

Triggers

  • integrate history navigation into image viewer
  • implement random image selection with history
  • fix image viewer next previous logic
  • show image name before loading in tkinter
  • tkinter image viewer history index error

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.