modify so that the boolean values have a field in the gui where the user can pick yes or no: import tkinter as tk
from tkinter import ttk, messagebox, font
import sqlite3

# Database functions
def run_query(query, parameters=()):
    with sqlite3.connect('media.db') as conn:
        cursor = conn.cursor()
        result = cursor.execute(query, parameters)
        if query.strip().lower().startswith("select"):
            return result.fetchall()
        conn.commit()

def create_tables():
    create_movies_table_sql = '''
    CREATE TABLE IF NOT EXISTS movies (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    movie TEXT,
    year TEXT,
    present BOOLEAN,
    watched BOOLEAN,
    notes TEXT
    );
    '''
    create_series_table_sql = '''
    CREATE TABLE IF NOT EXISTS series (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    series TEXT,
    seasons TEXT,
    year TEXT,
    present BOOLEAN,
    seasons_present TEXT,
    complete BOOLEAN,
    watched BOOLEAN,
    seasons_seen TEXT,
    notes TEXT
    );
    '''
    run_query(create_movies_table_sql)
    run_query(create_series_table_sql)

class MediaTracker(tk.Tk):
    def __init__(self):
        super().__init__()

        self.title("Movies and Series Tracker")
        self.geometry("1000x600")

        # Set font
        self.custom_font = font.Font(family='Arial', size=12)  # Change 'Arial' to your preferred font

        # Main frames
        self.sidebar = tk.Frame(self, width=150, bg='lightgrey')
        self.sidebar.pack(side='left', fill='y')

        self.button_bar = tk.Frame(self, width=50, bg='white')
        self.button_bar.pack(side='right', fill='y')

        self.content = tk.Frame(self, bg='white')
        self.content.pack(side='left', fill='both', expand=True)

        # Sidebar buttons
        self.movies_button = ttk.Button(self.sidebar, text="Movies", command=self.show_movies)
        self.movies_button.pack(pady=10, padx=10, fill='x')

        self.series_button = ttk.Button(self.sidebar, text="Series", command=self.show_series)
        self.series_button.pack(pady=10, padx=10, fill='x')

        # Add and Delete buttons in button bar
        self.add_button = ttk.Button(self.button_bar, text="+", command=self.add_entry, width=3)
        self.add_button.pack(pady=20)

        self.delete_button = ttk.Button(self.button_bar, text="-", command=self.delete_entry, width=3)
        self.delete_button.pack(pady=10)

        # Initialize Treeview
        self.tree = None
        self.current_table = None
        self.current_row_id = None

        # Load data
        self.show_movies()

    def clear_content(self):
        if self.tree:
            self.tree.destroy()

    def setup_treeview(self, columns, headings):
        self.tree = ttk.Treeview(self.content, columns=columns, show='headings', selectmode='browse')
        for col, head in zip(columns, headings):
            self.tree.heading(col, text=head)
            self.tree.column(col, width=100, anchor='center')
        self.tree.pack(fill='both', expand=True)

        # Bind events
        self.tree.bind('<<TreeviewSelect>>', self.on_row_select)
        self.tree.bind('<Double-1>', self.on_double_click)

    def load_movie_data(self):
        self.clear_content()
        columns = ["ID", "Movie", "Year", "Present", "Watched", "Notes"]
        headings = ["ID", "Movie", "Year", "Present", "Watched", "Notes"]
        self.setup_treeview(columns, headings)
        self.current_table = 'movies'

        for row in run_query('SELECT * FROM movies'):
            self.tree.insert('', 'end', values=row)

    def load_series_data(self):
        self.clear_content()
        columns = ["ID", "Series", "Seasons", "Year", "Present", "Seasons Present",
                   "Complete", "Watched", "Seasons Seen", "Notes"]
        headings = ["ID", "Series", "Seasons", "Year", "Present", "Seasons Present",
                   "Complete", "Watched", "Seasons Seen", "Notes"]
        self.setup_treeview(columns, headings)
        self.current_table = 'series'

        for row in run_query('SELECT * FROM series'):
            self.tree.insert('', 'end', values=row)

    def show_movies(self):
        self.load_movie_data()

    def show_series(self):
        self.load_series_data()

    def add_entry(self):
        if self.current_table == 'movies':
            run_query("INSERT INTO movies (movie, year, present, watched, notes) VALUES (?, ?, ?, ?, ?)",
                      ('', '', None, None, ''))
            self.load_movie_data()
        elif self.current_table == 'series':
            run_query("INSERT INTO series (series, seasons, year, present, seasons_present, complete, watched, seasons_seen, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
                      ('', '', '', None, '', None, None, '', ''))
            self.load_series_data()

    def delete_entry(self):
        selected_item = self.tree.selection()
        if not selected_item:
            messagebox.showwarning("No selection", "Please select a row to delete.")
            return
        item = self.tree.item(selected_item)
        row_id = item['values'][0]
        if self.current_table == 'movies':
            run_query("DELETE FROM movies WHERE id = ?", (row_id,))
            self.load_movie_data()
        elif self.current_table == 'series':
            run_query("DELETE FROM series WHERE id = ?", (row_id,))
            self.load_series_data()

    def on_row_select(self, event):
        selected_item = self.tree.selection()
        if selected_item:
            item = self.tree.item(selected_item)
            self.current_row_id = item['values'][0]
        else:
            self.current_row_id = None

    def on_double_click(self, event):
        item = self.tree.identify_row(event.y)
        if not item:
            return
        column = self.tree.identify_column(event.x)
        col_num = int(column.replace('#', '')) - 1
        if col_num == 0:
            return  # ID column is read-only

        x, y, width, height = self.tree.bbox(item, column)
        value = self.tree.set(item, column)
        # Create entry widget
        entry = tk.Entry(self.content, font=self.custom_font)
        entry.place(x=x, y=y, width=width, height=height)
        entry.insert(0, value)
        entry.focus()

        def save_edit(event):
            new_value = entry.get()
            entry.destroy()
            self.tree.set(item, column, new_value)
            row_values = self.tree.item(item)['values']
            self.update_database(row_values)

        entry.bind('<Return>', save_edit)
        entry.bind('<FocusOut>', save_edit)

    def update_database(self, row_values):
        if self.current_table == 'movies':
            query = "UPDATE movies SET movie = ?, year = ?, present = ?, watched = ?, notes = ? WHERE id = ?"
            parameters = (row_values[1], row_values[2], self.str_to_bool(row_values[3]),
                          self.str_to_bool(row_values[4]), row_values[5], row_values[0])
        elif self.current_table == 'series':
            query = """UPDATE series SET series = ?, seasons = ?, year = ?, present = ?, 
                       seasons_present = ?, complete = ?, watched = ?, seasons_seen = ?, notes = ? WHERE id = ?"""
            parameters = (row_values[1], row_values[2], row_values[3],
                          self.str_to_bool(row_values[4]), row_values[5],
                          self.str_to_bool(row_values[6]), self.str_to_bool(row_values[7]),
                          row_values[8], row_values[9], row_values[0])
        run_query(query, parameters)

    def str_to_bool(self, value):
        if isinstance(value, bool):
            return value
        if value.lower() in ['true', '1', 'yes']:
            return True
        elif value.lower() in ['false', '0', 'no']:
            return False
        return None

if __name__ == "__main__":
    create_tables()
    app = MediaTracker()
    app.mainloop()