# Temporary Pacing Simulator: A Training Tool for Clinicians
## 2 Materials and Methods
### The Encapsulation of the Simulator on a User Interface
#### 2.5.2 Main Simulation Panel Window Initialization  
The main simulation panel window is initialised with a size of 1500 \(\times\) 800 pixels and a white background, centered in the middle of the screen, similarly with the welcome window. The window is divided into two main sections: the left frame, which displays the simulated pacing signals, and the right frame, which contains the user input fields and controls (Figure 4). The left frame is dedicated to displaying the ECG, ABP, and CVP signals. Using the matplotlib library [14], three subplots are created within a figure, each representing one of these signals. Initially, the plots display static signals of null values. However, as the user begins to select options from the right frame, the plots become dynamic, simulating real-time data monitoring. This visualization is crucial for understanding the impact of different pacing modes and parameters on cardiac function. The dynamic visualization is achieved through a process known as windowing, where a fixed-length segment of the signal is displayed at any given time. The key steps in this process are as follows:  
1. Window Definition: At each update, a new segment (or window) of the signal is defined. This window consists of a fixed number of data points, representing a short duration of the signal. 2. Index Increment: The starting point of the window is incremented by a predefined number of data points, shifting the window forward along the signal. This incremental shift creates the appearance of a moving signal. Plot Clearing and Redrawing: Before plotting the new window, the current plot is cleared to remove the old data. The new segment of the signal is then plotted within the cleared axes. 4. Canvas Redrawing: The canvas, which is the plotting area within the Tkinter interface, is redrawn to display the updated plot. 5. Periodic Function Call: The program uses a periodic function call mechanism to ensure that the plot updates at regular intervals. This is typically set to one second, aligning with the real-time aspect of the simulation. The dynamic plot provides real-time visual feedback to the user. As the user adjusts the pacing parameters, the plot responds immediately, updating the signals to reflect the changes. This real-time feedback is essential for understanding the effects of different pacing strategies on cardiac function. The right frame contains several interactive elements for user inputs, structured in a logical sequence to guide the user through the setup process. These controls for the simulation, including dropdowns, entries, and buttons, are organized within several sub-frames, each holding related UI components for ease of layout and organization. The elements are as follows:  
* Title and Styling: The title \"Temporary Cardiac Pacing Settings\" is displayed at the top of the right frame in bold and centered for emphasis. * Baseline Rhythm Selection: The user selects the baseline rhythm from a dropdown menu. This input is essential as it influences the available pacing modes and signal baselines. The options include various rhythm types such as 'A-tach 2:1 block' (TAH), 'AF', 'SR', 'SR with LBBB', and 'SR with VEs'. * Pacing Mode Selection: Depending on the selected baseline rhythm, the user can choose a pacing mode from the dropdown menu, which includes options like 'VVT', 'VOO', 'AAI', 'AOO', 'DDI', and 'DOO'. This selection determines the type of pacing to be simulated. * Pacing Rate Input: A text entry field allows the user to input the desired pacing rate in bpm. * Pacing Rate Validation: An adjacent button validates the entered rate, ensuring it falls within the acceptable range (bpm). * Optimal AV Delay Input: Users can input an optimal AV delay value. There are buttons to plot AV delay data and validate the entered AV delay, providing feedback on whether the value is correct based on preloaded data. * AV Time Delay Selection: A dropdown menu is available for selecting the AV time delay, with options ranging from 40 to 300 milliseconds.