コード例 #1
0
    def _confirm(self):
        if self.confirmcommand:
            if not self.confirmcommand():
                return

        Data._dict.update(self._data)
        Data.store()
コード例 #2
0
        def moveFiles():
            keyLabel['text'], file = next(items, ('', None))

            if file:
                pfile = pathlib.Path(file)
                parent = pfile.parent
                parents = pfile.parents

                if parent != tempDir:
                    if destDir in parents or len(
                            selectDirs.intersection(parents)) == 0:
                        SauceNao.Data.add(file)
                    else:
                        fileLabel['text'] = file

                        with PIL.Image.open(file) as image:
                            pass  # just open and close it again, data stays in image object

                        if tempDir not in parents:
                            file = data.moveFileTo(file, tempDir)

                        Data.add(file)

                self.after_idle(moveFiles)
            else:
                data.clear()
                data.store()
                oframe.destroy()

                Data.store()
                SauceNao.Data.store()

                self.after_idle(self._initSelect)
コード例 #3
0
    def process(self):
        self._after = None

        file = next(self._files, None)

        if not file:
            if len(self._dirs) == 0:
                Data.store()

                return self.skip()

            dir = self._dirs.pop()

            if not dir in self._ignore:
                self._files = pathlib.Path(dir).iterdir()

                self._dirLabel['text'] = dir
                self._fileLabel['text'] = ''
        else:
            if file.is_dir():
                self._dirs.add(file)
            else:
                if Data.add(file):
                    self._fileLabel['text'] = file.name

        self._after = self.after_idle(self.process)
コード例 #4
0
ファイル: Trash.py プロジェクト: Shiska/dubNao
        def step():
            file = next(items, None)

            if file:
                fileLabel['text'] = file.name

                if file.exists():
                    file.unlink()

                self.after_idle(step)
            else:
                for k, v in Data._dict.items():
                    v.clear()

                Data.store()

                self._empty()
コード例 #5
0
    def _delete(self, event=None):
        if self._deleteButton['state'] != tkinter.DISABLED:
            index = self._index
            file = str(self._items.pop(index))

            with Trash.Data as trashData:
                Data.remove(file)
                trashData.add(file)
                # recreate generator because dict has changed
                self._getGenerator()

                if len(self._items) == index:
                    self._showIndex(index - 1)
                else:
                    self._showIndex(index)

            Data.store()
コード例 #6
0
ファイル: Trash.py プロジェクト: Shiska/dubNao
import pathlib
import tkinter

import widgets.Data as Data
import widgets.Media as Media
import widgets.SauceNao as SauceNao

Data = Data.ImageMap(Data.Data('trash'))

class Frame(tkinter.Frame):
    def __init__(self, master, command = None):
        super().__init__(master)

        self.command = command

        self.focus_set()

        self.bind('<Left>',     self.previous)
        self.bind('<Up>',       self.restore)
        self.bind('<Down>',     self.delete)
        self.bind('<Right>',    self.next)

        oframe = tkinter.LabelFrame(self, text = 'Trash')
        oframe.pack()

        iframe = tkinter.Frame(oframe)
        iframe.pack(expand = True, fill = tkinter.X)

        self._previousButton = tkinter.Button(iframe, text = 'Previous (Left)', command = self.previous)
        self._previousButton.pack(expand = True, fill = tkinter.X, side = tkinter.LEFT)
コード例 #7
0
    def ignoreDirs(self):
        return self.getRootFolders(
            {dir
             for dir, cboxes in self.directories.items() if cboxes[2]})

    @staticmethod
    def getRootFolders(folders: set):
        folders = [pathlib.Path(f).resolve() for f in folders]

        for f in folders:
            folders = [x for x in folders if f not in list(x.parents)]

        return set(folders)


Data = Settings(Data.Data('settings'))


class Frame(tkinter.LabelFrame):
    column = ('Dir', 'Index', 'Select', 'Ignore', 'Delete')
    column = type('Enum', (), dict((v, i) for i, v in enumerate(column)))

    def __init__(self, master, confirmcommand=None, cancelcommand=None):
        super().__init__(master, text='Settings')

        self.confirmcommand = confirmcommand
        self.cancelcommand = cancelcommand

        self._copy()

        self._duplicates = tkinter.BooleanVar()
コード例 #8
0
import pathlib
import slugify
import tkinter
import traceback
import threading
import pysaucenao
import collections
import urllib.request
import PIL.Image, PIL.ImageTk

import widgets.Data as Data
import widgets.Media as Media
import widgets.Trash as Trash
import widgets.Setting as Setting

Data = Data.ImageMap(Data.Data('sauceNao'))


class Frame(tkinter.Frame):
    def __init__(self, master, command=None, browse=None):
        super().__init__(master)

        self.command = command or self._browse
        self.browse = browse

        self._snao = pysaucenao.SauceNao(api_key=Setting.Data.apiKey)

        self._tempDir = pathlib.Path(Setting.Data.tempDir).resolve()
        self._destDir = pathlib.Path(Setting.Data.destDir).resolve()
        self._event_loop = asyncio.new_event_loop()
コード例 #9
0
import pathlib
import tkinter

import PIL.ImageTk
import PIL.ImageChops

import widgets.Data as Data
import widgets.Index as Index
import widgets.Media as Media
import widgets.Trash as Trash
import widgets.Setting as Setting
import widgets.SauceNao as SauceNao

Data = Data.ImageMap(Data.Data('select'))


class Frame(tkinter.Frame):
    thumbnailSize = 300
    maxImagesPerRow = 6

    colors = dict(enumerate([
        'green',
        'red',
        'blue',
        'violet',
        'orange',
    ]))

    def __init__(self, master, command=None):
        super().__init__(master)
コード例 #10
0
import pathlib
import tkinter

import widgets.Data as Data
import widgets.Setting as Setting

Data = Data.ImageMap(Data.Data('index'))

class Frame(tkinter.Frame):
    def __init__(self, master, command = None):
        super().__init__(master)

        self._command = command

        oframe = tkinter.Frame(self)
        oframe.pack()

        frame = tkinter.LabelFrame(oframe, text = 'Scanning for files')
        frame.grid_columnconfigure(1, weight = 1)
        frame.grid(sticky = 'ew')

        tkinter.Label(frame, text = 'Directory:').grid(row = 0, column = 0, sticky = 'e')
        tkinter.Label(frame, text = 'File:').grid(row = 1, column = 0, sticky = 'e')

        self._dirLabel = tkinter.Label(frame)
        self._dirLabel.grid(row = 0, column = 1, sticky = 'w')
        self._fileLabel = tkinter.Label(frame)
        self._fileLabel.grid(row = 1, column = 1, sticky = 'w')

        frame = tkinter.Frame(oframe)
        frame.grid(sticky = 'ew')