Saving the images

The logic to save the images is pretty straightforward. Here it is:

def save():    if not config.get('images'):        _alert('No images to save')        return    if _save_method.get() == 'img':        dirname = filedialog.askdirectory(mustexist=True)        _save_images(dirname)    else:        filename = filedialog.asksaveasfilename(            initialfile='images.json',            filetypes=[('JSON', '.json')])        _save_json(filename)def _save_images(dirname):    if dirname and config.get('images'):        for img in config['images']:            img_data = requests.get(img['url']).content            filename = os.path.join(dirname, img['name'])            with open(filename, 'wb') as f:                f.write(img_data)        _alert('Done')def _save_json(filename):    if filename and config.get('images'):        data = {}        for img in config['images']: img_data ...

Get Learn Python Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.