示例#1
0
def add_files():
    filenames = filedialog.askopenfilenames()
    from wallpapoz_gui.wallpapoz_main_window import tree
    tree_selection = tree.selection()
    if '_' in tree_selection[0]:
        showerror(_("Empty tree parent selection"), _("Must choose at least one tree parent."))
    else:
        for selection in tree_selection:
            if '_' not in selection:
                n = len(tree.get_children(selection))
                for filename in filenames:
                    if _is_valid_image(filename):
                        tree.insert(selection, 'end', selection + '_' + str(n+1), text=filename)
                        n += 1
示例#2
0
def add_directory():
    directory = filedialog.askdirectory()
    if not directory:
        return
    from wallpapoz_gui.wallpapoz_main_window import tree
    tree_selection = tree.selection()
    if '_' in tree_selection[0]:
        showerror(_("Empty tree parent selection"), _("Must choose at least one tree parent."))
    else:
        for selection in tree_selection:
            n = len(tree.get_children(selection))
            for root, dirs, filenames in os.walk(directory):
                for filename in filenames:
                    image_path = root + '/' + filename
                    if _is_valid_image(image_path):
                        tree.insert(selection, 'end', selection + '_' + str(n+1), text=image_path)
                        n += 1