change python script below so Disable mode switching would be activated at start if run_offset_once=True in config_tg-.ini:
import tkinter as tk
from tkinter import font, messagebox
import configparser
import os

class OffsetConfigEditor:
    def __init__(self, master):
        self.master = master
        self.master.title("TG - Offsets and GPU Mode Config Editor")
        
        # Remove maximize button
        self.master.resizable(False, False)
        self.master.attributes("-toolwindow", True)  # On Windows, removes the maximize button
        
        self.bold_font = font.Font(weight="bold")
        
        self.batch_folder = os.path.join("TG", "TGMAIN")
        self.ini_file = os.path.join(self.batch_folder, "config_tg-.ini")
        
        # Ensure batch folder exists
        if not os.path.exists(self.batch_folder):
            messagebox.showerror("Error", f"Batch folder not found: {self.batch_folder}")
            self.master.destroy()
            return
        
        # Read the config file
        self.config = configparser.ConfigParser()
        if not os.path.exists(self.ini_file):
            messagebox.showerror("Error", f"Configuration file not found: {self.ini_file}")
            self.master.destroy()
            return
        
        self.config.read(self.ini_file)
        self.entries = {}

        self.create_offset_fields()
        
        # Add the "Run offset correction 1 time" checkbox and input fields for offsets
        self.run_offset_var = tk.BooleanVar()
        self.offset_x_var = tk.StringVar()
        self.offset_y_var = tk.StringVar()

        # Load initial states
        self.run_offset_var.set(self.config.getboolean('Settings', 'run_offset_once', fallback=False))
        self.offset_x_var.set(self.config.get('Settings', 'offset_x_value', fallback=''))
        self.offset_y_var.set(self.config.get('Settings', 'offset_y_value', fallback=''))

        offset_frame = tk.Frame(self.master)
        offset_frame.grid(row=self.last_row + 1, column=0, columnspan=6, pady=10)
        
        run_once_checkbox = tk.Checkbutton(
            offset_frame, text="Run offset correction only 1 time",
            variable=self.run_offset_var,
            command=self.toggle_offset_correction
        )
        run_once_checkbox.pack(side=tk.LEFT, padx=5)

        explanation_label = tk.Label(offset_frame, text="(enable when use multiple models and input correct offset values)")
        explanation_label.pack(side=tk.LEFT, padx=5)

        # Offset X label and input
        offset_x_label = tk.Label(offset_frame, text="offset_x:")
        offset_x_label.pack(side=tk.LEFT, padx=5)
        
        offset_x_entry = tk.Entry(offset_frame, textvariable=self.offset_x_var, width=4)
        offset_x_entry.pack(side=tk.LEFT, padx=5)
        offset_x_entry.bind("<KeyRelease>", lambda e: self.save_offset_x_value())

        # Offset Y label and input
        offset_y_label = tk.Label(offset_frame, text="offset_y:")
        offset_y_label.pack(side=tk.LEFT, padx=5)
        
        offset_y_entry = tk.Entry(offset_frame, textvariable=self.offset_y_var, width=4)
        offset_y_entry.pack(side=tk.LEFT, padx=5)
        offset_y_entry.bind("<KeyRelease>", lambda e: self.save_offset_y_value())
        
        # Add buttons for mode switching at the bottom, centered
        self.mode_var = tk.StringVar()
        self.check_current_mode()
        
        mode_frame = tk.Frame(self.master)
        mode_frame.grid(row=1000, column=0, columnspan=6, pady=10)
        self.cuda_radio = tk.Radiobutton(mode_frame, text="CUDA mode", variable=self.mode_var, value="CUDA", command=self.switch_mode)
        self.cuda_radio.pack(side=tk.LEFT, padx=5)
        self.dml_radio = tk.Radiobutton(mode_frame, text="DirectML mode", variable=self.mode_var, value="DirectML", command=self.switch_mode)
        self.dml_radio.pack(side=tk.LEFT, padx=5)

    def create_offset_fields(self):
        """Populate offset fields in a multi-column, multi-row grid layout with aligned entry fields."""
        row = 0
        col = 0
        max_columns = 4

        for section in self.config.sections():
            if section == "Settings": 
                continue
                
            # Section Label (Bold)
            label = tk.Label(self.master, text=section, font=self.bold_font)
            label.grid(row=row, column=col * 2, columnspan=2, sticky="w", padx=(5, 15))

            offset_x_value = self.config.get(section, 'offset_x', fallback='0')
            offset_y_value = self.config.get(section, 'offset_y', fallback='0')

            # Label and aligned entry for offset_x
            offset_x_label = tk.Label(self.master, text="offset_x:")
            offset_x_label.grid(row=row + 1, column=col * 2, sticky="e", padx=5)
            offset_x_entry = tk.Entry(self.master, width=10)
            offset_x_entry.insert(0, offset_x_value)
            offset_x_entry.bind("<KeyRelease>", lambda e, sec=section, entry=offset_x_entry: self.update_value(sec, 'offset_x', entry.get()))
            offset_x_entry.grid(row=row + 1, column=col * 2 + 1, sticky="w", padx=(0, 10))

            # Label and aligned entry for offset_y
            offset_y_label = tk.Label(self.master, text="offset_y:")
            offset_y_label.grid(row=row + 2, column=col * 2, sticky="e", padx=5)
            offset_y_entry = tk.Entry(self.master, width=10)
            offset_y_entry.insert(0, offset_y_value)
            offset_y_entry.bind("<KeyRelease>", lambda e, sec=section, entry=offset_y_entry: self.update_value(sec, 'offset_y', entry.get()))
            offset_y_entry.grid(row=row + 2, column=col * 2 + 1, sticky="w", padx=(0, 10))

            # Store entries for later access
            self.entries[section] = (label, offset_x_label, offset_x_entry, offset_y_label, offset_y_entry)

            col += 1
            if col >= max_columns:
                col = 0
                row += 3

        # Update last used row for later layout adjustments
        self.last_row = row + 2

    def update_value(self, section, key, value):
        self.config.set(section, key, value)
        self.write_config()

    def toggle_offset_correction(self):
        """Toggle offset correction and manage related file renaming."""
        tecogan_bat = os.path.join(self.batch_folder, "tecogan.bat")
        tecogan_offset_bat = os.path.join(self.batch_folder, "tecogan_offset.bat")
        tecogan_cuda_no_offset_bat = os.path.join(self.batch_folder, "tecogan_cuda_no_offset.bat")
        tecogan_dml_no_offset_bat = os.path.join(self.batch_folder, "tecogan_dml_no_offset.bat")
        
        try:
            if self.run_offset_var.get():
                if os.path.exists(tecogan_bat):
                    os.rename(tecogan_bat, tecogan_offset_bat)
                
                mode_specific_no_offset_bat = (
                    tecogan_dml_no_offset_bat 
                    if self.mode_var.get() == "DirectML" 
                    else tecogan_cuda_no_offset_bat
                )
                
                if os.path.exists(mode_specific_no_offset_bat):
                    os.rename(mode_specific_no_offset_bat, tecogan_bat)
                
                # Disable mode switching
                self.cuda_radio.config(state=tk.DISABLED)
                self.dml_radio.config(state=tk.DISABLED)

            else:
                if os.path.exists(tecogan_bat):
                    mode_specific_no_offset_bat = (
                        tecogan_dml_no_offset_bat 
                        if self.mode_var.get() == "DirectML" 
                        else tecogan_cuda_no_offset_bat
                    )
                    os.rename(tecogan_bat, mode_specific_no_offset_bat)
                
                if os.path.exists(tecogan_offset_bat):
                    os.rename(tecogan_offset_bat, tecogan_bat)
                
                # Enable mode switching
                self.cuda_radio.config(state=tk.NORMAL)
                self.dml_radio.config(state=tk.NORMAL)

            # Save state to config
            self.save_run_offset_state()

        except FileNotFoundError as e:
            messagebox.showerror("Error", f"File not found during toggling offset correction: {e}")
        except Exception as e:
            messagebox.showerror("Error", f"Unexpected error during toggling offset correction: {e}")

    def save_run_offset_state(self):
        """Save the state of the 'Run Offset 1 Time' checkbox."""
        if not self.config.has_section('Settings'):
            self.config.add_section('Settings')
        self.config.set('Settings', 'run_offset_once', str(self.run_offset_var.get()))
        self.write_config()

    def save_offset_x_value(self):
        """Save the value of the offset_x input entry."""
        if not self.config.has_section('Settings'):
            self.config.add_section('Settings')
        self.config.set('Settings', 'offset_x_value', self.offset_x_var.get())
        self.write_config()

    def save_offset_y_value(self):
        """Save the value of the offset_y input entry."""
        if not self.config.has_section('Settings'):
            self.config.add_section('Settings')
        self.config.set('Settings', 'offset_y_value', self.offset_y_var.get())
        self.write_config()

    def write_config(self):
        with open(self.ini_file, 'w') as configfile:
            for section in self.config.sections():
                configfile.write(f'[{section}]\n')
                for key, val in self.config.items(section):
                    configfile.write(f'{key}={val}\n')  # No spaces around `=`
                configfile.write('\n')

    def check_current_mode(self):
        tecogan_bat = os.path.join(self.batch_folder, "tecogan.bat")
        tecogan_dml_bat = os.path.join(self.batch_folder, "tecogan_dml.bat")

        if os.path.exists(tecogan_bat) and os.path.exists(tecogan_dml_bat):
            self.mode_var.set("CUDA")
        elif os.path.exists(tecogan_bat) and not os.path.exists(tecogan_dml_bat):
            self.mode_var.set("DirectML")
            self.hide_directml_fields()
        else:
            messagebox.showerror("Error", "Invalid batch file configuration for determining mode.")
            self.master.destroy()

    def switch_mode(self):
        if self.mode_var.get() == "DirectML":
            self.hide_directml_fields()
        else:
            self.show_all_fields()
            
        tecogan_bat = os.path.join(self.batch_folder, "tecogan.bat")
        tecogan_dml_bat = os.path.join(self.batch_folder, "tecogan_dml.bat")
        tecogan_cuda_bat = os.path.join(self.batch_folder, "tecogan_cuda.bat")

        try:
            if self.mode_var.get() == "DirectML":
                if os.path.exists(tecogan_bat):
                    os.rename(tecogan_bat, tecogan_cuda_bat)
                if os.path.exists(tecogan_dml_bat):
                    os.rename(tecogan_dml_bat, tecogan_bat)

            elif self.mode_var.get() == "CUDA":
                if os.path.exists(tecogan_bat):
                    os.rename(tecogan_bat, tecogan_dml_bat)
                if os.path.exists(tecogan_cuda_bat):
                    os.rename(tecogan_cuda_bat, tecogan_bat)

        except FileNotFoundError as e:
            messagebox.showerror("Error", f"File not found during mode switching: {e}")
        except Exception as e:
            messagebox.showerror("Error", f"Unexpected error during mode switching: {e}")

    def hide_directml_fields(self):
        """Hide fields containing 'BVPP' or 'TG8Xa' in their name and reorganize layout."""
        row = 0
        col = 0
        max_columns = 4

        for section, widgets in self.entries.items():
            label, offset_x_label, offset_x_entry, offset_y_label, offset_y_entry = widgets
            if "BVPP" in section or "TG8Xa" in section:
                label.grid_remove()
                offset_x_label.grid_remove()
                offset_x_entry.grid_remove()
                offset_y_label.grid_remove()
                offset_y_entry.grid_remove()
            else:
                label.grid(row=row, column=col * 2, columnspan=2, sticky="w", padx=(5, 15))
                offset_x_label.grid(row=row + 1, column=col * 2, sticky="e", padx=5)
                offset_x_entry.grid(row=row + 1, column=col * 2 + 1, sticky="w", padx=(0, 10))
                offset_y_label.grid(row=row + 2, column=col * 2, sticky="e", padx=5)
                offset_y_entry.grid(row=row + 2, column=col * 2 + 1, sticky="w", padx=(0, 10))
                
                col += 1
                if col >= max_columns:
                    col = 0
                    row += 3

        self.last_row = row + 2

    def show_all_fields(self):
        """Show all fields and reset layout."""
        row = 0
        col = 0
        max_columns = 4

        for widgets in self.entries.values():
            label, offset_x_label, offset_x_entry, offset_y_label, offset_y_entry = widgets
            label.grid(row=row, column=col * 2, columnspan=2, sticky="w", padx=(5, 15))
            offset_x_label.grid(row=row + 1, column=col * 2, sticky="e", padx=5)
            offset_x_entry.grid(row=row + 1, column=col * 2 + 1, sticky="w", padx=(0, 10))
            offset_y_label.grid(row=row + 2, column=col * 2, sticky="e", padx=5)
            offset_y_entry.grid(row=row + 2, column=col * 2 + 1, sticky="w", padx=(0, 10))

            col += 1
            if col >= max_columns:
                col = 0
                row += 3

        self.last_row = row + 2

if __name__ == "__main__":
    root = tk.Tk()
    editor = OffsetConfigEditor(root)
    root.mainloop()