def add_supplier_list_to_combo(self, combo: QComboBox): # clear QComboBox combo.clear() combo.clearEditText() if self.parent.sheets is None: combo.setEnabled(False) return if self.db is None: self.flag_db = False combo.setEnabled(False) return # DB Query and update QConboBox sql = "SELECT name_supplier_short FROM supplier;" out = self.db.get(sql) for supplier in out: combo.addItem(supplier[0]) name = self.get_supplier_name() index = combo.findText(name) if index >= 0: combo.setCurrentIndex(index) combo.setEnabled(False) else: combo.setEnabled(True)
def get_filelist(self, combo: QComboBox): combo.clear() combo.clearEditText() # SQLite con = sqlite3.connect(self.dbname) cur = con.cursor() cur.execute("SELECT name_file FROM file;") out = cur.fetchall() con.close() # add list of file to QComboBox for name_file in out: combo.addItem(name_file[0])