AutoSkill Python Image Viewer with History and Random Navigation
Implements a Tkinter-based image viewer that maintains a linear history of viewed image indices. Navigation moves backward through history and forward through history, adding new random images from the remaining pool only when the end of history is reached.
git clone https://github.com/ECNU-ICALK/AutoSkill
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/python-image-viewer-with-history-and-random-navigation" ~/.claude/skills/ecnu-icalk-autoskill-python-image-viewer-with-history-and-random-navigation && rm -rf "$T"
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/python-image-viewer-with-history-and-random-navigation/SKILL.mdPython Image Viewer with History and Random Navigation
Implements a Tkinter-based image viewer that maintains a linear history of viewed image indices. Navigation moves backward through history and forward through history, adding new random images from the remaining pool only when the end of history is reached.
Prompt
Role & Objective
You are a Python/Tkinter developer implementing an image viewer class with specific navigation and history management logic.
Operational Rules & Constraints
-
Data Structures:
: A list storing integer indices referencingself.history
.self.image_files
: An integer tracking the current position in the history list.self.history_index
-
Folder Selection (
):select_folder- Reset
to an empty listself.history
.[] - Reset
toself.history_index
.-1 - Call
to select and display the first random image.add_image_to_history()
- Reset
-
History Addition (
):add_image_to_history- Select a random index from
that is not already present inself.image_files
.self.history - Append this index to
.self.history - Increment
.self.history_index
- Select a random index from
-
Next Image Logic (
):next_image- If
: Incrementself.history_index + 1 < len(self.history)
(browse forward in existing history).self.history_index - Else: Call
(load a new random image from the remaining pool).add_image_to_history() - Update the current image state based on the new
.self.history_index - Call
.display_image()
- If
-
Previous Image Logic (
):previous_image- If
: Decrementself.history_index > 0
.self.history_index - Do not add new images to history.
- Update the current image state based on the new
.self.history_index - Call
.display_image()
- If
-
Display Logic (
):display_image- Retrieve the filename using
.self.image_files[self.history[self.history_index]] - Use this filename string to construct the full path via
.os.path.join(self.image_folder, filename) - Do not pass integers directly to
.os.path.join
- Retrieve the filename using
-
Delayed Loading:
- If implementing a delayed load (e.g., showing text first), ensure the delayed method loads the same image identified by the current history index, not a new random one.
Anti-Patterns
- Do not store full file paths in
ifself.history
is a list of names; store indices.self.image_files - Do not generate a new random image in
.previous_image - Do not generate a new random image in
if history is not exhausted.next_image
Triggers
- integrate history navigation into image viewer
- python tkinter image viewer with back button
- random image selection with history
- browse history then load new images
- implement image viewer history list