Üstat merhaba,
Kodların son şekli şöyle oldu:
SQL.py
def combo_binding(column, table, id_column, id_value):
conn, cursor = connect(read_db_config(sql_config_file))
query = """SELECT {} FROM {} WHERE {} = {}""".format(column, table, id_column, id_value)
temp_list = []
try:
cursor.execute(query)
row = cursor.fetchall()
for i in range(len(row)):
temp_list.append(row[i][0])
del row
return temp_list
except Error as e:
print(e)
finally:
cursor.close()
conn.close()
del conn, cursor, query
main.py
class NewCompany():
....
def current_informations(self)
country_lbl = QtWidgets.QLabel(Lang.company["country"][lang])
grid_layout.addWidget(country_lbl, 1, 0, 1, 1)
self.country_combo = QtWidgets.QComboBox(self)
country_data = sql.select_all_by_column("CountryName", "country")
self.country_combo.addItems(country_data)
self.country_combo.currentIndexChanged.connect(self.select_country_combo)
grid_layout.addWidget(self.country_combo, 1, 1, 1, 1)
city_lbl = QtWidgets.QLabel(Lang.company["city"][lang], self)
grid_layout.addWidget(city_lbl, 2, 0, 1, 1)
self.city_combo = QtWidgets.QComboBox(self)
self.city_combo.currentIndexChanged.connect(self.select_city_combo)
grid_layout.addWidget(self.city_combo, 2, 1, 1, 1)
ve son olarak aynı class içerisinde tıklamayı yönettiğim her ComboBox için bir fonksiyon şöyle bir şey:
def select_country_combo(self, i):
city_data = sql.combo_binding("CityName", "city", "CountryID", i+1)
self.city_combo.clear()
self.city_combo.addItems(city_data)
desteğin için tekrar teşekkür ederim üstat.