Good day there! I am currently working on a school proyect in a MVC arquitecture where I am communicating my app with a Firestore database and, among other things, displaying the data I get from the Database inside a DataTable in the Main Menu. Now everything on with regard to the connection with the database works fine, but I am having problems updating the DataTable I have on my Main Menu. How it works is: App opens and requests all files from the database to build the DataTable from. User goes to create an item (shirts) and selects options inside a pop-up called "EditorPopup" Once the user is done tinkering there, the data from the options they select gets sent to the Firestore database. Up until here everything is ok. [PROBLEM] When I go to update the MDDataTable using a function addRow(self, [the data]) I found in the documentation for Kivy 1.1.1, it apparently goes through without an error popping up or anything, and the data arrives to the function in question just fine. But when the pop-up closes I see that no row has been added. I've been doing some debugging with use of print()s, and everything seems to be working alright behind the scenes. For example, exploring solutions for this problem I thought of regenerating the table, where I can confirm that the data from the Database reaches just fine (IE, if there were 20 documents inside the collection before adding the next entry, after adding the new entry and calling the database again, it showed 21 entries), but even after removing the table, updating it with the new entry and readding it, it still looks the same. Below I am adding all the relevant code (Some of it is in Spanish, apologies in advance): vista.py (The View file, I have a .kv file but for this part I build it entirely in python) #[...] class MainMenuBox(MDBoxLayout): # Elementos del Menú principal controller = ObjectProperty() model = ObjectProperty() def __init__(self, model, controller, **kwargs): super(MainMenuBox, self).__init__(**kwargs) self.orientation = 'vertical' self.controller = controller self.model = model self.topbar = MDTopAppBar() self.topbar.title = "Menú Principal" self.topbar.elevation = "0" self.topbar.md_bg_color = "#4956cc" self.add_widget(self.topbar) self.grid = MDGridLayout() self.grid.cols = 2 self.add_widget(self.grid) self.doc_ref = self.model.get_items_dbbb() self.table = MDDataTable(pos_hint={'center_y': 0.5, 'center_x': 0.5}, use_pagination=True, check=True, column_data=[ ("Código de Pedido", dp(40)), ("Tamaño", dp(40)), ("Diseño", dp(40)), ("Texto", dp(40)), ("Logo", dp(40)), ], size_hint=(1.75, 0.7), row_data=self.add_table_data(self.doc_ref), rows_num=10, sorted_on="Código de Pedido") # self.table.bind(on_check_press=) self.grid.add_widget(self.table) self.ButtonBox = ButtonBox(self.model, self.controller) self.grid.add_widget(self.ButtonBox) def return_model(self): return self.model def return_controller(self): return self.controller # funciones de la tabla def add_row(self, row) -> None: last_num_row = int(self.table.row_data[0][0]) print(f'{last_num_row}') self.table.add_row((str(last_num_row + 1), row['cod_ped'], row['tamano'], row['diseno'], row['txt_cont'], row['logo'])) # self.table.row_data = self.add_table_data() self.regen_table() def update_row(self, row) -> None: self.table.update_row('placeholder') def delete_row(self, codigo) -> None: self.table.remove_row('placeholder') def add_table_data(self, docs): table_list = [] doc = [] for item in docs: doc = Firebase.get_doc('pedidos', item) datos_list = [] datos_list.append(doc['cod_ped']) datos_list.append(doc['tamano']) datos_list.append(doc['diseno']) datos_list.append(doc['txt_cont']) datos_list.append(doc['logo']) table_list.append(datos_list) return table_list def regen_table(self): self.grid.remove_widget(self.table) docs = self.model.get_items_dbbb() self.table = MDDataTable(pos_hint={'center_y': 0.5, 'center_x': 0.5}, use_pagination=True, check=True, column_data=[ ("Código de Pedido", dp(40)), ("Tamaño", dp(40)), ("Diseño", dp(40)), ("Texto", dp(40)), ("Logo", dp(40)), ], size_hint=(1.75, 0.7), row_data=self.add_table_data(docs), rows_num=10, sorted_on="Código de Pedido") self.grid.add_widget(self.table) for doc in docs: print(f'{doc}') #Checking if number of docs is correct #[...] controlador.py (Controller file) # [...] class Controlador: def __init__(self): # Inicializamos el Modelo self.modelo = Modelo(controller=self) # Inicializamos las pantallas self.main_view = AppMainMenu(model=self.modelo, controller=self) self.screen_editor = EditorPopup(controller=self, model=self.modelo) # Inicializamos los datos self.shirt_tam = '' self.shirt_des = '' # [...] def get_screen(self): return self.main_view # Gets the UI def validaciones (self): # Validación de cada dato, incluir un if # [Bunch of data here being passed to the Model file] self.modelo.push_item_ddbb() modelo.py (The Model file) class Modelo: def __init__(self, controller): # Inicializamos las variables self.controller = controller # Vistas self.main_view = AppMainMenu(model=self, controller=self.controller) self.main_menu = MainMenuBox(model=self, controller=self.controller) self.view = EditorPopup(controller = self.controller, model = self) self._shirt_tam = '' self._shirt_des = '' # [... Lots of variables and setters later, including initializing the UI] # Comandos ddbb def push_item_ddbb (self): datos = {'tamano': self.shirt_tam, 'diseno': self.shirt_des, 'col_base': self.shirt_col_base, 'col_des': self.shirt_col_des, 'txt_cont': self.shirt_txt_cont, 'txt_pos': self.shirt_txt_pos, 'txt_tam': self.shirt_txt_tam, 'txt_col': self.shirt_txt_col, 'txt_tip': self.shirt_txt_tip, 'logo': self.shirt_logo, 'logo_pos': self.shirt_logo_pos, 'logo_tam': self.shirt_logo_tam, 'logo_elev': self.shirt_logo_elev } datos_tabla = Firebase.ped_push_item(datos, 'pedidos') self.main_menu.add_row(datos_tabla) print('item pushed') #[def...] def get_items_dbbb (self): docs = Firebase.get_all_items('pedidos') return docs ddbb.py (File inside the Model folder that handles everything related to databases, not quite related to the matter, but thought it could maybe help you in seeing something I don't (?)) #[...] class Firebase: # Metodo para introducir nuevos pedidos def ped_push_item (datos, coleccion): datos['cod_ped']= gen_ped_id() db.collection(coleccion).document(f"cod-cli_{gen_ped_id()}").set(datos) db.collection('contadores').document("id_counters").update({"ped_id": Increment(1)}) return datos # Metodo para modificar pedidos def edit_item (datos, codigo, coleccion): ref = db.reference(coleccion) pedidos_ref = ref.child('') pedidos_ref.update(datos) # Metodo para borrar un pedido def delete_item (datos, codigo, coleccion): ref = db.reference(coleccion) pedidos_ref = ref.child('') pedidos_ref.delete() # Metodo para cargar los datos de la ddbb en la lista def get_all_items (coleccion): docs = (db.collection(f'{coleccion}') .where(filter=FieldFilter("cod_ped", ">=", 0)) .stream()) docs_dict = {doc.id:doc.to_dict() for doc in docs} return docs_dict def get_doc(coleccion, doc_id): doc_ref = db.collection(coleccion).document(doc_id) doc = doc_ref.get().to_dict() return doc #[...] I have tried different ways of adding rows into the table (looking at the documentation. The code in addRow was taken from there). Once simply trying to add it to the table did not work, i've tried regenerating the whole table with data from the database, and after that did not work, i tried both at the same time. Code doesn't give me any errors, but it still isn't doing anything visible. I have checked that everything beside the display of the datatable works smoothly, to be exact the most important part which is connection with the Database and being able to communicate with it (Push items, Get items, Modify items [WIP], Delete items[WIP]) It's a project I'll have to hand in and present soon-ish, so I would appreciate any feedback or reponse you could give me to help me make sense of any of this @_@ Thank you in advance! Language Versions: Python 3.13.3 Kivy 2.3.1 KivyMD 1.2.0 (solely for the DataTable) IDE Used: Pycharm Continue reading...