Пример #1
0
def handle_settings(appObj):
    """Handler to update the settings file."""
    try:
        appObj.new_settings['pics-folder'] = appObj.pics_folder.get()
        appObj.new_settings['fav-pics-folder'] = appObj.fav_pics_folder.get()
    except AttributeError:
        messagebox.showwarning("AttributeError", "Folder not selected")
        return
    sites = []
    if appObj.unsplash.get():
        sites.append("https://unsplash.com/new")
    if appObj.reddit.get():
        reddit_sites = retrieve_textbox_input(appObj, appObj.sub_entry).split()
        sites.extend(reddit_sites)
    if appObj.desktoppr.get():
        sites.append("https://api.desktoppr.co/1/wallpapers")
    appObj.new_settings['website'] = sites
    try:
        appObj.new_settings['timeout'] = int(appObj.timeout_val.get()) * 60
    except ValueError:
        messagebox.showwarning("AttributeError", "Invalid value for timeout")
        return
    try:
        appObj.new_settings['no-of-images'] = int(appObj.count_val.get())
    except ValueError:
        messagebox.showwarning("AttributeError",
                               "Invalid value for no of images")
        return
    update_settings(appObj.new_settings)
Пример #2
0
def update_settings_view(appObj, mainFrame, settings):
    """Update and view default settings when Reset is pressed."""
    appObj.pics_folder.set(settings['pics-folder'])
    appObj.fav_pics_folder.set(settings['fav-pics-folder'])
    appObj.sites_list = check_sites(settings)
    appObj.unsplash.set(appObj.sites_list['unsplash'])
    appObj.desktoppr.set(appObj.sites_list['desktoppr'])
    if appObj.sites_list['reddit']:
        appObj.reddit.set(True)
        toggle_subreddit(appObj, mainFrame)
    else:
        appObj.reddit.set(False)
        toggle_subreddit(appObj, mainFrame)
    appObj.timeout_val.set(int(int(settings['timeout']) / 60))
    appObj.count_val.set(settings["no-of-images"])
    appObj.root.update_idletasks()
    update_settings(settings)