def settimerinterval(self): #if self.root.attributes("-topmost", True):…
- User
def set_timer_interval(self): #if self.root.attributes("-topmost", True): # self.root.attributes("-topmost", False)
if not hasattr(self, 'current_session_timings'): # Make sure the properties exist self.current_session_timings = [] self.is_session_mode = False dialog = CustomTimeDialog(self.root, self.current_session_timings, self.is_session_mode) if dialog.result is not None: self.is_session_mode = dialog.togsess_mode.get() # Ensure you're accessing the toggled state from the dialog if self.is_session_mode: self.current_session_timings = dialog.result # Session mode is active, dialog.result contains the list of session strings self.current_session_timings = dialog.result self.process_session(dialog.result) # Set the interval to the first session's time self.timer_interval = self.current_session_list[0][1] * 1000 else: # Session mode is inactive, dialog.result should be a numerical value interval = dialog.result 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 else: pass #self.root.lift() # Bring the main window to the top self.root.focus_force() # Give focus to the main window minutes = self.timer_interval // 60000 seconds = (self.timer_interval % 60000) // 1000 if self.timer_interval <=59000: self.timer_label.config(text=f"{seconds}") else : self.timer_label.config(text=f"{minutes:d}:{seconds:02d}") def next_image(self, event=None): if self.image_folder != "": if len(self.image_files) == len(self.history): self.history_index = (self.history_index + 1) % len(self.image_files) else: self.add_image_to_history() self.display_image() # Reset the timer interval to the stored set timer interval if self.is_session_mode: self.session_image_count -= 1 if self.session_image_count <= 0: self.session_index = (self.session_index + 1) % len(self.current_session_list) self.session_image_count, interval = self.current_session_list[self.session_index] self.timer_interval = interval * 1000 # Setting the new interval from session self.set_timer_interval = interval * 1000 print (self.session_image_count) else:self.current_session_list[self.session_index]
self.timer_interval = self.set_timer_interval #not reseton first time initialisation, because self.session_image_count is 0 when self.session_image_count -= 1 it doesnt play the first item on the list. how do i set the initial self.session_image_count to the first item before doing -=1 to it to make sure
- Assistant
- User
self.session_image_count = self.current_session_list[0][1] is the indices to the right correct? what will it call
- Assistant
Apologies for any confusion before. No, this line
self.session_image_count = self.current_session_list[0][1]is not correct according to the structure you've described earlier. It seems there's a mix-up in the indices. - User
what does this say self.timer_interval = self.current_session_list[0][1] * 1000
- Assistant
The line
self.timer_interval = self.current_session_list[0][1] * 1000is setting theself.timer_intervalattribute to the interval defined for the first session in theself.current_session_list, multiplied by 1000 to convert it from seconds to milliseconds.Breaking down the elements of this line:
-
self.timer_interval: This is an attribute that is presumably being used to store the amount of time for which a timer should run. -
self.current_session_list: This is a list where each item is assumed to be a tuple (or list) containing two elements. The first element is the number of images that will be displayed during that session, and the second element is the time in seconds for each image.
-