Dec-24-2019, 01:42 PM
Good morning all,
I want to delete to zero my "combobox" for a next entry. I have read is studied a lot of tutorials, but I found nothing to get to just delete the selected content in the field. I'm missing something, but I can't see it. Could you please help me. I am progressing slowly, but surely
.
Here are my comboboxes:
I want to delete to zero my "combobox" for a next entry. I have read is studied a lot of tutorials, but I found nothing to get to just delete the selected content in the field. I'm missing something, but I can't see it. Could you please help me. I am progressing slowly, but surely

Traceback (most recent call last): File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:\Users\xxxxxx\Documents\PythonDevProgramme\MnesisProject\main4.py", line 358, in <lambda> command=lambda : save_citation(combo_auteur.get(), combo_theme.get(), entry_citation.get('1.0', END), entry_ref.get('1.0', END))) File "C:\Users\xxxxx\Documents\PythonDevProgramme\MnesisProject\main4.py", line 306, in save_citation combo_auteur.subwidget_list['cmb_nomsauteur'].delete(0, Tk.END) AttributeError: 'Combobox' object has no attribute 'subwidget_list'
Here are my comboboxes:
def cmb_nomsauteur(event=None): connexion = sqlite3.connect('mnesis.db') cursor = connexion.cursor() cursor.execute('SELECT auteur_auteur FROM tb_auteur ORDER BY auteur_auteur') data = [] for row in cursor.fetchall(): data.append(row[0])
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 dataMy function and lines 18 to 23 we find the subject of my request:
def save_citation(citation_auteur, citation_theme, citation_citation, citation_reference): """ Insertion des données dans database tb_citation """ try: connection = sqlite3.connect('mnesis.db') # Connection à la BdD cursor = connection.cursor() # création du curseur #création variable new_citation req = "INSERT INTO tb_citation( citation_auteur, citation_theme, citation_citation, citation_reference) VALUES ('"+citation_auteur+"','"+citation_theme+"', '"+citation_citation+"', '"+citation_reference+"')" cursor.execute(req) except Exception as e: print("ERREUR",e) connection.rollback() finally: cursor.close() connection.commit() # Valider l'enregistrement dans la database connection.close() ## Fermeture de la connection # Delete textbox after records combo_auteur.subwidget_list['cmb_nomsauteur'].delete(0, Tk.END) combo_theme.subwidget_list['cmb_theme'].delete(0, Tk.END) entry_citation.delete('1.0', END) entry_verset.delete('1.0', END) entry_ref.delete('1.0', END)My form:
def write_citation(): global combo_auteur global combo_theme global entry_citation global entry_verset global entry_ref tpl_citation = Toplevel() tpl_citation.title(" Bienvenue dans la saisie des citations") screen_x = int(tpl_citation.winfo_screenwidth()) screen_y = int(tpl_citation.winfo_screenheight()) tpl_citation_x = 1024 tpl_citation_y = 600 pos_x = (screen_x // 2) - (tpl_citation_x // 2) pos_y = (screen_y // 2) - (tpl_citation_y // 2) geo = "{}x{}+{}+{}".format(tpl_citation_x, tpl_citation_y, pos_x, pos_y) tpl_citation.geometry(geo) tpl_citation.resizable(width=False,height=False) tpl_citation.configure(bg='lightblue3') #--- citation_auteur_label = Label(tpl_citation, text="Auteur",bg='lightblue3', font=("Arial", 12,"bold")) citation_auteur_label.place(x=30,y=38) combo_auteur = ttk.Combobox(tpl_citation, values=cmb_nomsauteur(), width=25, font=("Century Gothic", 14,"bold")) combo_auteur.bind('<<ComboboxSelected>>', cmb_nomsauteur) combo_auteur.place(x=30,y=65) citation_theme_label = Label(tpl_citation, text="Thème",bg='lightblue3', font=("Arial", 12,"bold")) citation_theme_label.place(x=450,y=38) combo_theme = ttk.Combobox(tpl_citation, values=cmb_theme(), width=25, font=("Century Gothic", 14,"bold")) combo_theme.bind('<<ComboboxSelected>>', cmb_theme) combo_theme.place(x=450,y=65) #------------ citation_label = Label(tpl_citation, text="Citation",bg='lightblue3', font=("Arial", 12,"bold")) citation_label.place(x=30,y=100) entry_citation = Text(tpl_citation, width="107", height="19", font=("Arial", 12)) entry_citation.place(x=30,y=127) ref_label = Label(tpl_citation, text="Référence",bg='lightblue3', font=("Arial", 12,"bold")) ref_label.place(x=30,y=485) entry_ref = Text(tpl_citation, width="107", height="1",font=("Arial", 12)) entry_ref.place(x=30,y=512) boutonEnregistrer = Button(tpl_citation, text='Enregistrer', command=lambda : save_citation(combo_auteur.get(), combo_theme.get(), entry_citation.get('1.0', END), entry_ref.get('1.0', END))) boutonEnregistrer.pack(side=BOTTOM, anchor=SE, padx=20, pady=20) # end tpl_citation.mainloop()