Есть такой код, как можно сократить его до 1 функции, в которую будут передаваться параметры, чтобы не делать отдельную функцию для каждого города. В
self.ui_map.pb_shadow_isles.clicked.connect
параметры не передаются, как можно решить эту проблему, какие есть варианты?
def start_map(self):
self.ui_map.setupUi(self)
self.ui_map.pb_shadow_isles.clicked.connect(self.start_city_shadow_isles_info)
self.ui_map.pb_bilgewater.clicked.connect(self.start_city_bilgewater_info)
self.show()
def start_city_shadow_isles_info(self):
self.ui_city_info.setupUi(self, "SHADOW ISLES_BACK", "SHADOW ISLES_BACKGROUND", "SHADOW ISLES_3D")
self.ui_city_info.pb_cancel_city_info.clicked.connect(self.start_map)
result = sq.get_city_info(1)
self.ui_city_info.l_city_name.setText(str(result[1]))
self.ui_city_info.l_city_s_name.setText(str(result[2]))
self.ui_city_info.l_city_edit_info_1.setText(str(result[3]))
self.ui_city_info.l_city_edit_info_2.setText(str(result[4]))
self.ui_city_info.l_city_edit_info_3.setText(str(result[6]))
self.ui_city_info.l_city_edit_info_4.setText(str(result[5]))
self.ui_city_info.l_city_edit_info_5.setText(str(result[7]))
self.show()
def start_city_bilgewater_info(self):
self.ui_city_info.setupUi(self, "BILGEWATER_BACK", "BILGEWATER_BACKGROUND", "BILGEWATER_3D")
self.ui_city_info.pb_cancel_city_info.clicked.connect(self.start_map)
result = sq.get_city_info(2)
self.ui_city_info.l_city_name.setText(str(result[1]))
self.ui_city_info.l_city_s_name.setText(str(result[2]))
self.ui_city_info.l_city_edit_info_1.setText(str(result[3]))
self.ui_city_info.l_city_edit_info_2.setText(str(result[4]))
self.ui_city_info.l_city_edit_info_3.setText(str(result[6]))
self.ui_city_info.l_city_edit_info_4.setText(str(result[5]))
self.ui_city_info.l_city_edit_info_5.setText(str(result[7]))
self.show()