website.p2 module
- website.p2.cleanup()[source]
Clean up resources, stop threads, and reset global variables.
- Side effects:
Stops all active threads by setting
stop_event.Closes Tkinter window if open.
Clears timestamps and filenames for stimuli.
- website.p2.command_listener(conn)[source]
Main entry point for the Image Stimuli Program (p2).
- Parameters:
conn (multiprocessing.Connection) – IPC connection for commands.
Starts the command listener thread and keeps the program running until interrupted or explicitly exited.
- website.p2.handle_command(command, conn)[source]
Handle commands received from parent program.
- Parameters:
command (str) – Command string such as
load_stimuli,save_config,start_stimuli, orstop_stimuli.
Sends back responses over the connection.
- website.p2.initialize_tkinter()[source]
Initialize a fullscreen Tkinter window in a separate thread.
- Returns:
root (tk.Tk): The Tkinter root window.
label (tk.Label): The label widget for displaying content.
- Return type:
tuple
- website.p2.load_stimuli()[source]
Load and read a JSON file containing image stimuli configuration.
Loads data/image_stimuli_data_sequence.json and updates the global
configdictionary.
- website.p2.save_config(json_data)[source]
Save JSON configuration received from parent program.
- Parameters:
json_data (str) – A JSON-encoded string representing the configuration.
- Side effects:
Updates the global
configdictionary.Saves the configuration into
data/image_stimuli_data_sequence.json.
- website.p2.start_stimuli()[source]
Start displaying images according to the loaded configuration.
- Uses
configvalues for: fileSequence: Comma-separated image names.
fileDuration: Comma-separated durations for each image.
initialDelay: Countdown time before starting.
Displays each image sequentially in a fullscreen Tkinter window, logs timestamps, and saves output to JSON.
- Uses
- website.p2.update_ui(task_type, data=None)[source]
Update the Tkinter UI depending on the given task type.
- Parameters:
task_type (str) – One of
update_label,display_image, orclose_window.data (Any, optional) – Data associated with the task: - For
update_label: a string to display. - Fordisplay_image: path to an image file. - Forclose_window: list [timestamps, filenames, json_filename].