Make a window that contains open image button, below it add previous button next to next…
- User
Make a window that contains open image button, below it add previous button next to next button. Below it add a "rest" checkbox. Next to the checkbox is a spinbox. Below everything add total images in the folder label, and below that is label that show the image name
When open image is pressed, it opens a folder, lists the image content. Filter by extension jpg, Png, gif, webp. Then list it, add number to it and then save it to folder_index. If i open a second folder, it resets and load the list from the new folder instead, unless the new folder is the same as the current, then do not reset the list
The next button will call a random image from the folder index and add it to history. The previous button will load the previously shown images in order. When the previous button reach the beginning of the history, it's still active but does nothing.
The next button will go to the next image in history, until it reaches the end, then load up new next images to the history like usual.
At this point i ca cycle through the history with next and previous button. Show every image in the folder once before showing a previously shown image.
If the rest button is enabled, every (spinbox value) of images shown set by the spinbox, it'll call a function that set the label to say "rest" Instead of the image name for every (spinbox value) of img name. It doesn't stop the next button or affect the history, it just show the "rest" Text every (spinbox value) instead of the image name when active.
When i press previous while the rest checkbox is enabled, it just goes through the history unaffected by the rest function.
Do not disable any button. Use straight quotationmark and not curved quotes for the code.
- Assistant
- User
line 158, in next_image if self.rest_counter == 0 and self.rest_checkbox.instate(['selected']): ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Checkbutton' object has no attribute 'instate'
- Assistant
In Tkinter, to check if a
Checkbuttonis selected, you can use thevar.get()method wherevaris a Tkinter variable (IntVar,StringVar, etc.) that holds the state of theCheckbutton.Here's an updated portion of the
ImageAppclass showing how you would modify therest_checkboxto use atk.IntVar()for its state and check if it's selected in thenext_image()method:class ImageApp: def __init__(self, root): # ... other initializations ... self.rest_var = tk.IntVar() # Tkinter variable to hold the state of the checkbox self.rest_checkbox = tk.Checkbutton(root, text="Rest", variable=self.rest_var) self.rest_checkbox.pack(side='left') # ... rest of the code ... def next_image(self): self.rest_counter = (self.rest_counter + 1) % self.spin_value.get() if self.rest_counter == 0 and self.rest_var.get() == 1: # Check if 'Rest' is selected self.image_name_label.config(text="Rest") else: # ... remainder of the next_image method ... - User
- make the open folder immediately open an image after selecting a folder. and the rest function will show 1 less than the value it is set on.
- how do i set it so that when i set the spinbox to (rest value) it shows the rest text every (rest value+1) of images instead
- Assistant
- User
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 self.rotated = 0 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=self.bgcolor, 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") - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.