Python Forum
[Tkinter] Update a combobox
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] How can I sync Combobox index to other combobox index? nickzsche 2 2,382 Jan-03-2022, 12:29 PM
Last Post: Axel_Erfurt
  [PyQt] How to update selected data in combobox displaying DB data? JokerSob 3 3,419 Aug-02-2021, 04:39 AM
Last Post: JokerSob

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020