Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can anyone tell me why my table is not refreshing? I have a treeview with a list

ID: 3755833 • Letter: C

Question

Can anyone tell me why my table is not refreshing?

I have a treeview with a list of drones and their info. When a user adds a new drone the new information should automatically show in the treeview but it isn't?

I thought it might be the 'commit' call on the cursor but it is not working.

I am writing in python, mysql and connecting a database

class DroneEditorWindow (EditorWindow): Editor window for drones." def -init-(self, # TODO: Add either the drone name or «new> in the window title, depending on whether this is a new # drone or not self.drones = parent.drones self.operators parent.operators self._drone drone self..-save-action = save-action if self._drone is None: parent, drone, save-action): else: titleD -drone.name super(DroneEditorWindow, self).-init_-(parent, # TODO: Load drone details "Drone: + titleo, self.save-drone) def add_editor_widgets(self): count = 0 global droneName global droneNameEntry droneName tk.Label(self.frame, text-"Name") droneName.grid(in_-self.frame, row-1, column-1, sticky "w" droneNameEntry tk. Entry(self.frame, width-25, textvariable-"StringVar") droneNameEntry.insert (0, 'default') droneNameEntry.grid(in-self.frame, row-1, column-2, sticky- "E") count-1 global droneClass global droneClassEntry droneClass tk.Label(self,frame, text-"Drone Class") droneClass.grid(in-self.frame, row-2, column-1, sticky-"W" droneClassEntry ttk.Combobox(self.frame, width-10, state-"readonly") droneClassEntry['values'-"One", "Two") droneClassEntry.current(0) droneClassEntry.grid (in#5e1f.frame, row-2, column-2, sticky-"W") count + 1 global rescueDrone global rescueDroneEntry rescueDrone = tk. Label(self, frame, text="Rescue Drone") rescueDrone.grid(in-self.frame, row-3, column-1, sticky-"W rescueDroneEntry ttk. Combobox (self.frame, width-10, state-"readonly") rescueDroneEntry['values'] ('Yes''No') rescueDroneEntry.current (1) rescueDroneEntry.grid(in_-self.frame, row-3, column-2, sticky "") count +1 return count def save_drone(self): pdates the drone details and calls the save action. " drone name droneNameEntry.get() print drone name if droneClassEntry.get)'One': class-type = 1 class_type2 rescue1 else: if rescueDroneEntry.get() 'Yes' = else: rescue 0 dr-(drone_name, class type, rescue) self.drones.add (dr) self._save action(self._drone)

Explanation / Answer

Sir, in def add(), you have cursor.execute("INSERT ......."), after that you need to write:-

Basically what I am saying is that after execute(), you need to issue a commit() clause so that the record gets permananetly committed in DB and then your treeview will be able to reflect the newly made changes.

Please let me know in case of any clarifications required. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote