def set_service(widget, label, liststore2, combobox_weather_lang, weather_lang, store):
    global gw_config
    Load_Config()
    i = data.services_list[widget.get_active()]
    load_data(i, label, liststore2, combobox_weather_lang, weather_lang, store)
    gw_config['service'] = i
    gw_config['weather_lang'] = weather_lang_list[combobox_weather_lang.get_active()]
    try:
        gw_config['city_id'] = gw_config[data.get_city_list(i)][0].split(';')[0]
    except:
        pass
    gw_config['max_days'] = data.get_max_days(i)
    if gw_config['n'] > gw_config['max_days']:
        gw_config['n'] = gw_config['max_days']
    if data.get_need_appid(i):
        grid_appid.show()
    else:
        grid_appid.hide()

    Save_Config()
def load_data(service, label, liststore2, combobox_weather_lang, weather_lang,
              store):
    global url, example, code, dict_weather_lang, weather_lang_list, gw_config, loading
    loading = True
    url, example, code, dict_weather_lang, weather_lang_list = data.get(
        service)
    text = _("Choose your city on")+" <a href='%s'>%s</a>\n" %(url, url)+\
        _("and copy the city code below")+"\n"+\
        _("For example")+ ":\n<u><span foreground='blue'>%s/</span></u>\n" %example+\
        _("City code")+" %s" %code
    label.set_markup(text)
    liststore2.clear()
    for i in range(len(weather_lang_list)):
        try:
            liststore2.append([dict_weather_lang[weather_lang_list[i]]])
        except:
            if weather_lang_list[i] != '':
                liststore2.append([weather_lang_list[i]])
        if service + '_weather_lang' in gw_config.keys():
            if weather_lang_list[i] == gw_config[service + '_weather_lang']:
                combobox_weather_lang.set_active(i)
    if combobox_weather_lang.get_active() == -1:
        combobox_weather_lang.set_active(0)
    Load_Config()
    try:
        city_list = gw_config[data.get_city_list(service)]
    except:
        city_list = []
    store.clear()
    for item in city_list:
        store.append([item.split(';')[0], item.split(';')[1]])
    if data.get_need_appid(service):
        grid_appid.show()
        try:
            entrybox_appid.set_text(gw_config[data.get_appid(service)])
        except:
            entrybox_appid.set_text('')
    else:
        grid_appid.hide()
    loading = False
Beispiel #3
0
def load_data(service, label, liststore2, combobox_weather_lang, weather_lang, store):
    global url, example, code, dict_weather_lang, weather_lang_list, gw_config, loading
    loading = True
    url, example, code, dict_weather_lang, weather_lang_list = data.get(service)
    text = _("Choose your city on")+" <a href='%s'>%s</a>\n" %(url, url)+\
        _("and copy the city code below")+"\n"+\
        _("For example")+ ":\n<u><span foreground='blue'>%s/</span></u>\n" %example+\
        _("City code")+" %s" %code
    label.set_markup(text)
    liststore2.clear()
    for i in range(len(weather_lang_list)):
        try:
            liststore2.append([dict_weather_lang[weather_lang_list[i]]])
        except:
            if weather_lang_list[i] != '':
                liststore2.append([weather_lang_list[i]])
        if service+'_weather_lang' in gw_config.keys():
            if weather_lang_list[i] == gw_config[service+'_weather_lang']:
                combobox_weather_lang.set_active(i)
    if combobox_weather_lang.get_active() == -1:
        combobox_weather_lang.set_active(0)
    Load_Config()
    try:
        city_list = gw_config[data.get_city_list(service)]
    except:
        city_list = []
    store.clear()
    for item in city_list:
        store.append([item.split(';')[0], item.split(';')[1]])
    if data.get_need_appid(service):
        grid_appid.show()
        try: entrybox_appid.set_text(gw_config[data.get_appid(service)])
        except: entrybox_appid.set_text('')
    else:
        grid_appid.hide()
    loading = False