Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Update a combobox
#1
Hello,

Please, how do I update a combobox so that after entering a data item I return it to the drop-down list without having to restart the form?

My Combobox :

def cmb_theme(event=None):
    connexion = sqlite3.connect('mnesis.db')
    cursor = connexion.cursor()
    cursor.execute('SELECT theme_theme FROM tb_theme ORDER BY theme_theme')
    data = []
    for row in cursor.fetchall():
        data.append(row[0])
    return data
My function Save :

def save_theme(theme_theme):
    """ Insert in database """
    try:
        connection = sqlite3.connect('mnesis.db')  # Connection à la BdD
        cursor = connection.cursor() 
        new_theme = (cursor.lastrowid, theme_theme)  
        cursor.execute('INSERT INTO tb_theme VALUES(?,?)', new_theme)

    except Exception as e:
        print("ERREUR", e)
        connection.rollback()
    finally:
        cursor.close()
        connection.commit()
        connection.close()

        # Delete textbox after records
        entry_theme.delete('1.0', END)
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)