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 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.