Как уже упоминалось в моем комментарии, проблема в том, что ваша app_id
в appcall
не меняется.Вместо этого вам нужно получить ID
из ID_OPTIONS
.
def appcall(*args):
app_id = ID_OPTIONS[APP_OPTIONS.index(var.get())] # Add this line
app_status = session.get('https://getapplicationstatus.myurl.com?Id=' + app_id)
...
app_id
теперь установлен на ID_OPTIONS
того же индекса на основе app_name
(посколькупорядок вставки тот же).
Однако , лучше бы вместо этого инициализировать ваши параметры в виде словаря:
# instead of APP_OPTIONS / ID_OPTIONS, create:
apps = {}
...
for application in root.findall('application'):
app_name = application.find('name').text
app_id = application.find('id').text
# add to dictionary here:
apps[app_name] = app_id
def appcall(*args):
# Change the app_id to apps.get(var.get())
app_status = session.get('https://getapplicationstatus.myurl.com?Id=' + apps.get(var.get())
...
Посмотрите, насколько это прощевспомнить ту же ссылку?
Если вы чувствуете себя комфортно в отношении языка, вы можете даже выбрать словарь:
...
root = ET.fromstring(applications_xml)
app_id = {application.find('name').text: application.find('id').text for application in root.findall('application')}
...