def loadAndCreateThumbnails(self): x = 0 y = 0 print("cantidad de comics: ", len(self.listaComics)) self.cantidadThumnailsAGenerar = len(self.listaComics) self.cantidadThumnailsGenerados = 0 for comic in self.listaComics: self.cantidadThumnailsGenerados += 1 try: comic.openCbFile() print(comic.path) nombreThumnail = self.pahThumnails + str(comic.comicId) + comic.getPageExtension() cover = None if (not os.path.isfile(nombreThumnail)): cover = comic.getImagePage().resize(self.size, Image.BICUBIC) cover.save(nombreThumnail) else: cover = Image.open(nombreThumnail) #print(nombreThumnail) iconos = Iconos() if (comic.comicVineId != ''): comicvineLogo = Iconos().pilImageCataloged cover.paste(comicvineLogo, (cover.size[0] - 64, cover.size[1] - 64, cover.size[0], cover.size[1]), comicvineLogo) calidadIcon = None if (comic.calidad == 0): calidadIcon = iconos.pilCalidadSinCalificacion if (comic.calidad == 1): calidadIcon = iconos.pilCalidadMala if (comic.calidad == 2): calidadIcon = iconos.pilCalidadMedia if (comic.calidad == 3): calidadIcon = iconos.pilCalidadBuena if (comic.calidad == 4): calidadIcon = iconos.pilCalidadDigital cover.paste(calidadIcon,(0,cover.size[1]-64),calidadIcon) tkimage = ImageTk.PhotoImage(cover) # self.thumbnail.append(ImageTk.PhotoImage(cover)) self.thumbnail.append(tkimage) X = int(x * (self.size[0] + self.space)) Y = int(y * (self.size[1] + self.space)) self.__insertThumnail(X, Y, self.thumbnail[len(self.thumbnail) - 1], comic) x += 1 if x % self.cantidadColumnas == 0: y += 1 x = 0 except NotRarFile: print('error en el archivo ' + comic.path) except BadRarFile: print('error en el archivo ' + comic.path) self.config(scrollregion=self.bbox(ALL)) self.comicActual = 0
def __init__(self, master, listaComics=None, session = None, cnf={}, **kw): Canvas.__init__(self, master, cnf, **kw) self.size = self.size = (int(320 / 2), int(496 / 2)) self.space = 58 if session is not None: self.session = session else: self.session = Entidades.Init.Session() self.pahThumnails = self.session.query(Setup).first().directorioBase+ os.path.sep +"images"+os.path.sep +"coverIssuesThumbnails"+os.path.sep print(self.pahThumnails) print(self.size[0]) self.listaComics = listaComics self.thumbnail = [] self.comicsSelected=[] self.tagAndComic = [] self.halfSize = (int(self.size[0] / 2), int(self.size[1] / 2)) self.bind("<Button-1>", self.comicClicked) self.bind('<Shift-Button-1>', self.multipleComicsClicked) self.bind('<Control-Button-1>', self.addComicClicked) self.paginaDoblada = Iconos().pilImagePaginaDoblada self.cantidadColumnas = 6
def __init__(self, parent, cnf={}, **kw): Frame.__init__(self, parent, cnf, **kw) self.barraHerramientas = Frame(parent) self.barraHerramientas.grid(column=0, row=0, sticky=(E, W)) self.barraHerramientas.config() self.barraHerramientas.columnconfigure(0, weight=1) self.barraHerramientas.rowconfigure(1, weight=1) self.session = Entidades.Init.Session() self.setup = self.session.query(Setup).first() self.root = parent pilImagenLookup = Iconos().pilImagenLookup self.imagenLookup = ImageTk.PhotoImage(pilImagenLookup) self.pilImageFirst = Iconos().pilImageFirst self.imageFirst = ImageTk.PhotoImage(self.pilImageFirst) self.pilImagePrev = Iconos().pilImagePrev self.imagePrev = ImageTk.PhotoImage(self.pilImagePrev) self.pilImageNext = Iconos().pilImageNext self.imageNext = ImageTk.PhotoImage(self.pilImageNext) self.pilImageLast = Iconos().pilImageLast self.imageLast = ImageTk.PhotoImage(self.pilImageLast) '''Aca vamos a guardar las consulta para cada nodo del arbol de biblioteca''' self.listaConsultas = [] self.consultaActual = None self.listaComics = [] self.consulta = ComicBook.path.like("%%") # opciones de barra de tareas self.buscarEntry = ttk.Entry(self.barraHerramientas) image = self.imagenLookup self.buscarBoton = ttk.Button( self.barraHerramientas, width=1, compound=CENTER, image=image, command=lambda: self.buscar(self.statusBar)) self.buscarEntry.grid(column=6, row=0, sticky=E) self.buscarBoton.grid(column=7, row=0, sticky=E) self.buscarEntry.bind('<Return>', self.enterEventEntryBuscar) ttk.Button(self.barraHerramientas, text='refrescar', command=self.refrescar).grid(column=5, row=0, sticky=E) ttk.Button(self.barraHerramientas, image=self.imageFirst, command=self.primero).grid(column=1, row=0, sticky=E) ttk.Button(self.barraHerramientas, image=self.imagePrev, command=self.anterior).grid(column=2, row=0, sticky=E) ttk.Button(self.barraHerramientas, image=self.imageNext, command=self.siguiente).grid(column=3, row=0, sticky=E) ttk.Button(self.barraHerramientas, image=self.imageLast, command=self.ultimo).grid(column=4, row=0, sticky=E) ttk.Button(self.barraHerramientas, text='Salir', command=self.salir).grid(column=0, row=0, sticky=W) self.panedWindow = ttk.Panedwindow(parent, orient=HORIZONTAL) self.panedWindow.grid(column=0, row=1, sticky=(E, W, S, N)) # arbol donde tenenmos las listas de comics. self.treeListas = ttk.Treeview(self.panedWindow) print(self.setup.anchoArbol) self.treeListas.column("#0", minwidth=0, width=self.setup.anchoArbol) self.treeListas.grid() self.biblioteca = '' '''Tomamos el indice o Id del nodo como la longitud de la lista para identificar la consulta asociada al nodo. este nodo indica la raiz del arbol con el nodo Biblioteca este nodo hace una consulta por todo comic sin tener en cuenta editorial, volumen o arco. Trae todo.''' self.biblioteca = self.treeListas.insert('', 'end', len(self.listaConsultas), text='Biblioteca') self.listaConsultas.append( self.session.query(ComicBook).filter(ComicBook.comicVineId == '')) self.editoriales = self.treeListas.insert(self.biblioteca, 'end', len(self.listaConsultas), text='Editoriales') '''1 al igual que el 0 tienen la misma consulta Trae todo.''' self.listaConsultas.append(self.session.query(ComicBook)) self.crearArbolBibiloteca() # creamos menu popup para agregar vistas self.popup = Menu(self.treeListas, tearoff=0) self.popup.add_command(label="Abrir Volumenes", command=self.openVolume) self.treeListas.bind("<Button-3>", self.popupListas) self.treeListas.bind("<<TreeviewSelect>>", self.selectVista) self.panelGrillaComics = Frame(self.panedWindow) self.panelGrillaComics.columnconfigure(0, weight=1) self.panelGrillaComics.rowconfigure(0, weight=1) self.panelGrillaComics.grid(sticky=(N, S, W, E)) #self.scrollbar = ttk.Scrollbar(self.panelGrillaComics) #self.scrollbar.grid(column=1, row=0, sticky=(S, N)) #self.panelComics = PanelThumbnailComics(self.panedWindow, yscrollcommand=self.scrollbar.set) self.panelComics = PanelThumbnailComics(self.panedWindow) self.panelComics.bind("<Configure>", self.on_resize) #self.scrollbar.config(command=self.panelComics.yview) # treeComics.grid() #self.panelComics.bind('<MouseWheel>', self.scrollupMouse) #parent.bind('<Down>', self.scrollupKeyboard) #parent.bind('<Key>', self.scrollupKeyboard) # creamos menu popup para abrir el catalogador el visor el editor de info y calcular el thumnails de nuevo self.popupThumbnails = Menu(self.panelComics, tearoff=0) self.popupThumbnails.add_command(label="Info comic", command=self.openComicEditor) self.popupThumbnails.add_command(label="Leer comic", command=self.openBabelComicVisor) self.popupThumbnails.add_command(label="Catalogar comic", command=self.openComicVine) self.popupThumbnails.add_separator() self.popupThumbnails.add_command( label="Refresh Thumbnail", command=self.panelComics.recreateThumbnails) self.calidad = Menu(self.popupThumbnails, tearoff=0) self.calidad.add_command(label='Mala') self.calidad.add_command(label='Buena') self.calidad.add_command(label='Muy Buena') self.calidad.add_command(label='Digital') self.popupThumbnails.add_cascade(label='Calidad', menu=self.calidad) self.panelComics.bind("<Button-3>", self.popupPanelThumbnails) parent.bind('<Control-m>', lambda x: self.openComicEditor()) parent.bind('<Control-r>', lambda x: self.openComicVine()) parent.bind('<Control-b>', lambda x: self.openBabelComicVisor()) parent.bind('<Control-l>', lambda x: openWindow('Volumen', self.session)) parent.bind('<Control-p>', lambda x: openWindow('Editorial', self.session)) parent.bind('<Control-s>', self.openBabelComicConfig) parent.bind('<Control-x>', self.openBabelComicScanner) parent.bind('<Control-c>', self.copiarInfoComic) parent.bind('<Control-v>', self.pegarInfoComic) self.statusBar = StringVar() ttk.Label(parent, textvariable=self.statusBar, anchor="e", relief='groove').grid(column=0, row=3, sticky=(W, E)) self.panelComics.grid(column=0, row=0, sticky=(N, S, W, E)) self.panedWindow.add(self.treeListas) self.panedWindow.add(self.panelComics) self.paginaActual = 0 # menu # comics = ComicBooks() m, self.buscar(self.statusBar) cantidadColumnas = 4 # variables globales desc = False
def __init__(self, parent, session=None, cnf={}, **kw): Frame.__init__(self, parent, cnf, **kw) config = Config() self.iconos = Iconos() if session is None: self.session = Entidades.Init.Session() else: self.session = session self.comicVineSearcher = ComicVineSearcher( config.getClave('publishers'), session=self.session) self.comicVineSearcher.setEntidad("publishers") self.labelId = Label(self, text="Nombre Editorial: ") self.labelId.grid(row=0, column=0, sticky=W, padx=5, pady=5) self.entradaNombreEditorial = Entry(self, width=50) self.varID = StringVar() self.entradaNombreEditorial.grid(row=0, column=1, sticky=W + E, padx=5, pady=5, columnspan=2) self.botonLookupPublisher = Button(self, command=self.buscar) self.botonLookupPublisher.grid(row=0, column=3) self.pilImagenLookup = self.iconos.pilImagenLookup self.imageLookup = PIL.ImageTk.PhotoImage(self.pilImagenLookup) self.botonLookupPublisher.config(image=self.imageLookup) self.labelImagen = Label(self, text="logo edtorial") self.coverSize = (150, 150) self.labelImagen.grid(column=4, row=1) ##config grilla series self.panelGrilla = Frame(self) self.panelGrilla.grid(column=0, row=1, columnspan=3, sticky=(N, S, E, W), padx=5) self.grillaPublishers = ttk.Treeview(self.panelGrilla, columns=('Id', 'Nombre'), displaycolumns=('Id', 'Nombre')) self.grillaPublishers.grid(column=0, row=0, columnspan=3, sticky=(N, S, E, W)) self.grillaPublishers.bind( '<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() scrollGrid = ttk.Scrollbar(self.panelGrilla, orient=VERTICAL, command=self.grillaPublishers.yview) scrollGrid.grid(column=3, row=0, sticky=(N, S)) self.grillaPublishers.configure(yscrollcommand=scrollGrid.set) self.grillaPublishers.heading('Id', text='Id') self.grillaPublishers.heading('Nombre', text='Nombre') self.grillaPublishers.config(show='headings') # tree, headings self.botonLookupPublisher = Button(self, text="agregar", command=self.agregarEditorial) self.botonLookupPublisher.grid(row=2, column=3, pady=3, sticky=(E))
def __init__(self, parent, cnf={}, session=None, **kw): Frame.__init__(self, parent, cnf, **kw) if session is not None: self.session = session else: self.session = Entidades.Init.Session() self.iconos = Iconos() self.height = 358 self.width = 507 self.labelId = Label(self, text="ID") self.labelId.grid(row=0, column=0, sticky=W, padx=5, pady=5) self.entradaId = Entry(self) self.varID = StringVar() self.entradaId.grid( row=0, column=1, sticky=W + E, padx=5, pady=5, ) self.botonLookupPublisher = Button(self) self.botonLookupPublisher.grid(row=0, column=3) self.pilImagenLookup = self.iconos.pilImagenLookup self.imageLookup = PIL.ImageTk.PhotoImage(self.pilImagenLookup) self.botonLookupPublisher.config(image=self.imageLookup) self.labelNombre = Label(self, text="Nombre") self.labelNombre.grid(row=1, column=0, sticky=W) self.entradaNombre = Entry(self) self.entradaNombre.grid(row=1, column=1, sticky=W + E, padx=5, pady=5) self.labelUrl = Label(self, text='Url') self.labelUrl.grid(row=2, sticky=W, padx=5, pady=5) self.entradaUrl = Entry(self) self.entradaUrl.grid(row=2, column=1, sticky=W + E, padx=5, pady=5, columnspan=5) self.imageLogoCanvas = Canvas(self, width=154, height=154) self.imageLogoCanvas.grid(row=0, column=4, rowspan=4, sticky=E) self.pilImageLogo = self.iconos.pilImageLogo self.imageLogo = PIL.ImageTk.PhotoImage(self.pilImageLogo) self.imageLogoCanvas.create_image(77, 77, image=self.imageLogo) self.labelResumen = Label(self, text="Resumen") self.labelResumen.grid(row=5, column=0, sticky=W, padx=5, pady=5) self.pilImageExpansion = self.iconos.pilImageExpansion self.imageExpansion = PIL.ImageTk.PhotoImage(self.pilImageExpansion) self.botonExpansionResumen = Button(self, text="->", image=self.imageExpansion) self.botonExpansionResumen.grid(row=5, column=1, sticky=W) self.textoDescripcion = Label(self, wraplength=560, justify=LEFT, anchor=N) self.textoDescripcion.config(text='Descripcion') self.textoDescripcion.grid(row=6, column=0, padx=5, columnspan=5, sticky=W + E) self.frameBotonesNavegacion = Frame(self) self.frameBotonesNavegacion.grid(row=7, column=0, sticky=W) self.pilImageFirst = self.iconos.pilImageFirst self.imageFirst = PIL.ImageTk.PhotoImage(self.pilImageFirst) self.botonFirst = Button(self.frameBotonesNavegacion, image=self.imageFirst, command=self.getFirst) self.botonFirst.grid(row=0, column=0) self.pilImagePrev = self.iconos.pilImagePrev self.imagePrev = PIL.ImageTk.PhotoImage(self.pilImagePrev) self.botonPrev = Button(self.frameBotonesNavegacion, image=self.imagePrev, command=self.getPrev) self.botonPrev.grid(row=0, column=1) self.pilImageNext = self.iconos.pilImageNext self.imageNext = PIL.ImageTk.PhotoImage(self.pilImageNext) self.botonNext = Button(self.frameBotonesNavegacion, image=self.imageNext, command=self.getNext) self.botonNext.grid(row=0, column=2) self.pilImageLast = self.iconos.pilImageLast self.imageLast = PIL.ImageTk.PhotoImage(self.pilImageLast) self.botonLast = Button(self.frameBotonesNavegacion, image=self.imageLast, command=self.getLast) self.botonLast.grid(row=0, column=3) # self.frameBotonesAcciones = Frame(self) self.frameBotonesAcciones.grid(row=7, column=4, sticky=E) self.botonGuardar = Button(self.frameBotonesAcciones, text="Guardar") self.botonGuardar.grid(row=0, column=0, sticky=E) self.botonBorrar = Button(self.frameBotonesAcciones, text="Borrar", command=self.clearWindow) self.botonBorrar.grid(row=0, column=1, sticky=E) self.botonEliminar = Button(self.frameBotonesAcciones, text="Eliminar") self.botonEliminar.grid(row=0, column=2, sticky=E) self.botonCargarWeb = Button(self.frameBotonesAcciones, text="Cargar desde Web", command=self.openPublisherComicVine) self.botonCargarWeb.grid(row=0, column=3, sticky=E) self.publishersManager = Publishers.Publishers()
def __init__(self, parent, publisher, cnf={}, **kw): Frame.__init__(self, parent, cnf={}, **kw) self.columnconfigure(0, weight=1) self.publisher = publisher self.rowconfigure(1, weight=1) # panel busqueda opciones entrada y boton buscar self.panelBusqueda = ttk.Frame(self) self.panelBusqueda.grid(column=0, row=0, sticky=(E, W, N)) self.panelBusqueda.columnconfigure(0, weight=1) self.panelBusqueda.columnconfigure(1, weight=4) self.panelBusqueda.columnconfigure(2, weight=1) self.panelBusqueda.columnconfigure(3, weight=4) ttk.Label(self.panelBusqueda, text="Nombre: ").grid(column=0, row=0, sticky=W) self.entradaBuscarPorNombre = ttk.Entry(self.panelBusqueda) self.entradaBuscarPorNombre.grid(column=1, row=0, sticky=(W, E),padx=5) ttk.Button(self.panelBusqueda, text='Buscar', command=self.buscarPublisher).grid(sticky=(E), column=4, row=0) # self.opcionesBusqueda.current(1) # panel de grilla y previsualizacion primer cover de serie self.framePrincipal = LabelFrame(self) self.framePrincipal.grid(sticky=(E, W, S, N), column=0, row=1) self.framePrincipal.columnconfigure(0, weight=1) self.framePrincipal.rowconfigure(0, weight=1) self.coverSize = (240, 372) # lo necesitamos para agruparla con la scroll self.frameGrilla = Frame(self.framePrincipal) self.frameGrilla.grid(sticky=(N, W, E, S)) self.frameGrilla.rowconfigure(0, weight=1) self.frameGrilla.columnconfigure(0, weight=1) ##config grilla series self.grillaPublisher = ttk.Treeview(self.frameGrilla, columns=( 'name', 'Id'), displaycolumns=('Id', 'name')) self.grillaPublisher.grid(column=0, row=0, rowspan=1, sticky=(N, S, E, W)) scrollGrid = ttk.Scrollbar(self.frameGrilla, orient=VERTICAL, command=self.grillaPublisher.yview) scrollGrid.grid(column=1, row=0, rowspan=1, sticky=(N, S)) self.grillaPublisher.configure(yscrollcommand=scrollGrid.set) self.grillaPublisher.heading('Id', text='Id') self.grillaPublisher.heading('name', text='Nombre') self.grillaPublisher.config(show='headings') # tree, headings self.grillaPublisher.heading('name', command=lambda col='name': self.sortby(col)) self.grillaPublisher.heading('Id', command=lambda col='Id': self.sortby(col)) ''' no ordena bien con 70000 registros es lento es mas facil tirar una nueva consutla contra el SQL self.grillaPublisher.heading('start_year', command=lambda col='start_year': self.sortby(self.grillaPublisher, 'start_year', int(True))) self.grillaPublisher.heading('name', command=lambda col='name': self.sortby(self.grillaPublisher, 'name', int(True))) self.grillaPublisher.heading('count_of_issues', command=lambda col='count_of_issues': self.sortby(self.grillaPublisher, 'count_of_issues', int(True))) self.grillaPublisher.heading('publisher', command=lambda col='publisher': self.sortby(self.grillaPublisher, 'publisher', int(True))) ''' self.grillaPublisher.bind('<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() self.labelImagen = Label(self.frameGrilla) self.labelImagen.grid(column=3, row=0) # boton parte inferior formulario ttk.Button(self, text='seleccionar', command=self.seleccionarPublisher).grid(column=0, row=2, sticky=(E)) self.desc = True self.pilImageCoverGenerica = Iconos().pilImageLogo self.cover = ImageTk.PhotoImage(self.pilImageCoverGenerica.resize(self.coverSize)) self.labelImagen['image'] = self.cover
class PublisherLookupGui(Frame): def __init__(self, parent, publisher, cnf={}, **kw): Frame.__init__(self, parent, cnf={}, **kw) self.columnconfigure(0, weight=1) self.publisher = publisher self.rowconfigure(1, weight=1) # panel busqueda opciones entrada y boton buscar self.panelBusqueda = ttk.Frame(self) self.panelBusqueda.grid(column=0, row=0, sticky=(E, W, N)) self.panelBusqueda.columnconfigure(0, weight=1) self.panelBusqueda.columnconfigure(1, weight=4) self.panelBusqueda.columnconfigure(2, weight=1) self.panelBusqueda.columnconfigure(3, weight=4) ttk.Label(self.panelBusqueda, text="Nombre: ").grid(column=0, row=0, sticky=W) self.entradaBuscarPorNombre = ttk.Entry(self.panelBusqueda) self.entradaBuscarPorNombre.grid(column=1, row=0, sticky=(W, E),padx=5) ttk.Button(self.panelBusqueda, text='Buscar', command=self.buscarPublisher).grid(sticky=(E), column=4, row=0) # self.opcionesBusqueda.current(1) # panel de grilla y previsualizacion primer cover de serie self.framePrincipal = LabelFrame(self) self.framePrincipal.grid(sticky=(E, W, S, N), column=0, row=1) self.framePrincipal.columnconfigure(0, weight=1) self.framePrincipal.rowconfigure(0, weight=1) self.coverSize = (240, 372) # lo necesitamos para agruparla con la scroll self.frameGrilla = Frame(self.framePrincipal) self.frameGrilla.grid(sticky=(N, W, E, S)) self.frameGrilla.rowconfigure(0, weight=1) self.frameGrilla.columnconfigure(0, weight=1) ##config grilla series self.grillaPublisher = ttk.Treeview(self.frameGrilla, columns=( 'name', 'Id'), displaycolumns=('Id', 'name')) self.grillaPublisher.grid(column=0, row=0, rowspan=1, sticky=(N, S, E, W)) scrollGrid = ttk.Scrollbar(self.frameGrilla, orient=VERTICAL, command=self.grillaPublisher.yview) scrollGrid.grid(column=1, row=0, rowspan=1, sticky=(N, S)) self.grillaPublisher.configure(yscrollcommand=scrollGrid.set) self.grillaPublisher.heading('Id', text='Id') self.grillaPublisher.heading('name', text='Nombre') self.grillaPublisher.config(show='headings') # tree, headings self.grillaPublisher.heading('name', command=lambda col='name': self.sortby(col)) self.grillaPublisher.heading('Id', command=lambda col='Id': self.sortby(col)) ''' no ordena bien con 70000 registros es lento es mas facil tirar una nueva consutla contra el SQL self.grillaPublisher.heading('start_year', command=lambda col='start_year': self.sortby(self.grillaPublisher, 'start_year', int(True))) self.grillaPublisher.heading('name', command=lambda col='name': self.sortby(self.grillaPublisher, 'name', int(True))) self.grillaPublisher.heading('count_of_issues', command=lambda col='count_of_issues': self.sortby(self.grillaPublisher, 'count_of_issues', int(True))) self.grillaPublisher.heading('publisher', command=lambda col='publisher': self.sortby(self.grillaPublisher, 'publisher', int(True))) ''' self.grillaPublisher.bind('<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() self.labelImagen = Label(self.frameGrilla) self.labelImagen.grid(column=3, row=0) # boton parte inferior formulario ttk.Button(self, text='seleccionar', command=self.seleccionarPublisher).grid(column=0, row=2, sticky=(E)) self.desc = True self.pilImageCoverGenerica = Iconos().pilImageLogo self.cover = ImageTk.PhotoImage(self.pilImageCoverGenerica.resize(self.coverSize)) self.labelImagen['image'] = self.cover def getPublisher(self): print('retornando serie: ' + self.publisher.name) return self.publisher def itemClicked(self, event): if (self.grillaPublisher.selection()): seleccion = self.grillaPublisher.selection() self.publisher = self.publishers[self.grillaPublisher.index(seleccion[0])] self.grillaPublisher.index(seleccion[0]) imagen = self.publisher.getImageCover() self.cover = ImageTk.PhotoImage(imagen.resize(self.coverSize)) self.labelImagen['image'] = self.cover def seleccionarPublisher(self): print(self.publisher.id) # def sortby(self, col): # print('sort: ' + str(self.opcionesBusqueda.current())) # # if col == 'nombre': # self.opcionesBusqueda.current(0) # elif col == 'cantidadNumeros': # self.opcionesBusqueda.current(1) # elif col == 'name': # self.opcionesBusqueda.current(2) # elif col == 'AnioInicio': # print('antes de cambiar sort:') # self.opcionesBusqueda.current(3) # print('despues de cambiar sort: ' + str(self.opcionesBusqueda.current())) # # if (not self.desc): # self.buscarVolume('order by ' + col + ' desc') # else: # self.buscarVolume(('order by ' + col + ' asc') # def buscarPublisher(self, orderBy=None): for item in self.grillaPublisher.get_children(): self.grillaPublisher.delete(item) session = Entidades.Init.Session() self.publishers = session.query(Publisher) for index, publisher in enumerate(self.publishers): self.grillaPublisher.insert('', 'end', index, text='', values=(publisher.id_publisher, publisher.name))
def __init__(self, parent, serie, session=None, cnf={}, **kw): Frame.__init__(self, parent, cnf={}, **kw) self.padre = parent self.columnconfigure(0, weight=1) self.serie = serie if session is None: self.session = Entidades.Init.Session() else: self.session = session self.rowconfigure(1, weight=1) # panel busqueda opciones entrada y boton buscar self.panelBusqueda = ttk.Frame(self) self.panelBusqueda.grid(column=0, row=0, sticky=(E, W, N)) self.panelBusqueda.columnconfigure(0, weight=1) self.panelBusqueda.columnconfigure(1, weight=4) self.panelBusqueda.columnconfigure(2, weight=1) self.panelBusqueda.columnconfigure(3, weight=4) ttk.Label(self.panelBusqueda, text="Nombre: ").grid(column=0, row=0, sticky=W) self.variableBuscarPorNombre = StringVar() self.variableBuscarPorNombre.trace("w", self.callbackVariableBuscarPor) self.entradaBuscarPorNombre = ttk.Entry(self.panelBusqueda,textvariable=self.variableBuscarPorNombre) self.entradaBuscarPorNombre.grid(column=1, row=0, sticky=(W, E),padx=5) ttk.Label(self.panelBusqueda, text="Cantidad Números: ").grid(column=0, row=1, sticky=W) self.entradaBuscarPorCantidadNumeros = ttk.Entry(self.panelBusqueda) self.entradaBuscarPorCantidadNumeros.grid(column=1, row=1, sticky=(W, E),padx=5) ttk.Label(self.panelBusqueda, text="Año Inicio: ").grid(column=2, row=0, sticky=W) self.entradaBuscarPorAñoInicio = ttk.Entry(self.panelBusqueda) self.entradaBuscarPorAñoInicio.grid(column=3, row=0, sticky=(W, E),padx=5) ttk.Label(self.panelBusqueda, text="Editorial: ").grid(column=2, row=1, sticky=W) self.variableBuscarPorEditorial = StringVar() self.variableBuscarPorEditorial.trace("w", self.callbackVariableBuscarPor) self.entradaBuscarPorEditorial = ttk.Entry(self.panelBusqueda,textvariable=self.variableBuscarPorEditorial) self.entradaBuscarPorEditorial.grid(column=3, row=1, sticky=(W, E),padx=5) self.padre.bind("<Control-s>",lambda x: self.seleccionarVolume()) ttk.Button(self.panelBusqueda, text='Buscar', command=self.buscarVolume).grid(sticky=(E), column=4, row=0) # self.opcionesBusqueda.current(1) # panel de grilla y previsualizacion primer cover de serie self.framePrincipal = LabelFrame(self) self.framePrincipal.grid(sticky=(E, W, S, N), column=0, row=1) self.framePrincipal.columnconfigure(0, weight=1) self.framePrincipal.rowconfigure(0, weight=1) self.coverSize = (240, 372) # self.frame.columnconfigure(1,weight=1) # self.frame.rowconfigure(0,weight=1) # lo necesitamos para agruparla con la scroll self.frameGrilla = Frame(self.framePrincipal) self.frameGrilla.grid(sticky=(N, W, E, S)) self.frameGrilla.rowconfigure(0, weight=1) self.frameGrilla.columnconfigure(0, weight=1) ##config grilla series self.grillaVolumes = ttk.Treeview(self.frameGrilla, columns=( 'name', 'count_of_issues', 'description', 'Id', 'image', 'publisher', 'start_year'), displaycolumns=('Id', 'name', 'count_of_issues', 'publisher', 'start_year')) self.grillaVolumes.grid(column=0, row=0, rowspan=1, sticky=(N, S, E, W)) scrollGrid = ttk.Scrollbar(self.frameGrilla, orient=VERTICAL, command=self.grillaVolumes.yview) scrollGrid.grid(column=1, row=0, rowspan=1, sticky=(N, S)) self.grillaVolumes.configure(yscrollcommand=scrollGrid.set) self.grillaVolumes.heading('Id', text='Id') self.grillaVolumes.heading('name', text='Nombre') self.grillaVolumes.heading('count_of_issues', text='Numeros') self.grillaVolumes.heading('publisher', text='Editorial') self.grillaVolumes.heading('start_year', text='Año') self.grillaVolumes.config(show='headings') # tree, headings self.grillaVolumes.heading('start_year',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'start_year', False)) self.grillaVolumes.heading('name',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'name', False)) self.grillaVolumes.heading('count_of_issues',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'count_of_issues', False)) self.grillaVolumes.heading('publisher',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'publisher', False)) self.grillaVolumes.bind('<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() self.labelImagen = Label(self.frameGrilla) self.labelImagen.grid(column=3, row=0) # boton parte inferior formulario ttk.Button(self, text='seleccionar', command=self.seleccionarVolume).grid(column=0, row=2, sticky=(E)) self.desc = True self.pilImageCoverGenerica = Iconos().pilImageCoverGenerica self.cover = ImageTk.PhotoImage(self.pilImageCoverGenerica.resize(self.coverSize)) self.labelImagen['image'] = self.cover
class VolumesLookupGui(Frame): def __init__(self, parent, serie, session=None, cnf={}, **kw): Frame.__init__(self, parent, cnf={}, **kw) self.padre = parent self.columnconfigure(0, weight=1) self.serie = serie if session is None: self.session = Entidades.Init.Session() else: self.session = session self.rowconfigure(1, weight=1) # panel busqueda opciones entrada y boton buscar self.panelBusqueda = ttk.Frame(self) self.panelBusqueda.grid(column=0, row=0, sticky=(E, W, N)) self.panelBusqueda.columnconfigure(0, weight=1) self.panelBusqueda.columnconfigure(1, weight=4) self.panelBusqueda.columnconfigure(2, weight=1) self.panelBusqueda.columnconfigure(3, weight=4) ttk.Label(self.panelBusqueda, text="Nombre: ").grid(column=0, row=0, sticky=W) self.variableBuscarPorNombre = StringVar() self.variableBuscarPorNombre.trace("w", self.callbackVariableBuscarPor) self.entradaBuscarPorNombre = ttk.Entry(self.panelBusqueda,textvariable=self.variableBuscarPorNombre) self.entradaBuscarPorNombre.grid(column=1, row=0, sticky=(W, E),padx=5) ttk.Label(self.panelBusqueda, text="Cantidad Números: ").grid(column=0, row=1, sticky=W) self.entradaBuscarPorCantidadNumeros = ttk.Entry(self.panelBusqueda) self.entradaBuscarPorCantidadNumeros.grid(column=1, row=1, sticky=(W, E),padx=5) ttk.Label(self.panelBusqueda, text="Año Inicio: ").grid(column=2, row=0, sticky=W) self.entradaBuscarPorAñoInicio = ttk.Entry(self.panelBusqueda) self.entradaBuscarPorAñoInicio.grid(column=3, row=0, sticky=(W, E),padx=5) ttk.Label(self.panelBusqueda, text="Editorial: ").grid(column=2, row=1, sticky=W) self.variableBuscarPorEditorial = StringVar() self.variableBuscarPorEditorial.trace("w", self.callbackVariableBuscarPor) self.entradaBuscarPorEditorial = ttk.Entry(self.panelBusqueda,textvariable=self.variableBuscarPorEditorial) self.entradaBuscarPorEditorial.grid(column=3, row=1, sticky=(W, E),padx=5) self.padre.bind("<Control-s>",lambda x: self.seleccionarVolume()) ttk.Button(self.panelBusqueda, text='Buscar', command=self.buscarVolume).grid(sticky=(E), column=4, row=0) # self.opcionesBusqueda.current(1) # panel de grilla y previsualizacion primer cover de serie self.framePrincipal = LabelFrame(self) self.framePrincipal.grid(sticky=(E, W, S, N), column=0, row=1) self.framePrincipal.columnconfigure(0, weight=1) self.framePrincipal.rowconfigure(0, weight=1) self.coverSize = (240, 372) # self.frame.columnconfigure(1,weight=1) # self.frame.rowconfigure(0,weight=1) # lo necesitamos para agruparla con la scroll self.frameGrilla = Frame(self.framePrincipal) self.frameGrilla.grid(sticky=(N, W, E, S)) self.frameGrilla.rowconfigure(0, weight=1) self.frameGrilla.columnconfigure(0, weight=1) ##config grilla series self.grillaVolumes = ttk.Treeview(self.frameGrilla, columns=( 'name', 'count_of_issues', 'description', 'Id', 'image', 'publisher', 'start_year'), displaycolumns=('Id', 'name', 'count_of_issues', 'publisher', 'start_year')) self.grillaVolumes.grid(column=0, row=0, rowspan=1, sticky=(N, S, E, W)) scrollGrid = ttk.Scrollbar(self.frameGrilla, orient=VERTICAL, command=self.grillaVolumes.yview) scrollGrid.grid(column=1, row=0, rowspan=1, sticky=(N, S)) self.grillaVolumes.configure(yscrollcommand=scrollGrid.set) self.grillaVolumes.heading('Id', text='Id') self.grillaVolumes.heading('name', text='Nombre') self.grillaVolumes.heading('count_of_issues', text='Numeros') self.grillaVolumes.heading('publisher', text='Editorial') self.grillaVolumes.heading('start_year', text='Año') self.grillaVolumes.config(show='headings') # tree, headings self.grillaVolumes.heading('start_year',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'start_year', False)) self.grillaVolumes.heading('name',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'name', False)) self.grillaVolumes.heading('count_of_issues',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'count_of_issues', False)) self.grillaVolumes.heading('publisher',command=lambda: self.treeview_sort_column(self.grillaVolumes, 'publisher', False)) self.grillaVolumes.bind('<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() self.labelImagen = Label(self.frameGrilla) self.labelImagen.grid(column=3, row=0) # boton parte inferior formulario ttk.Button(self, text='seleccionar', command=self.seleccionarVolume).grid(column=0, row=2, sticky=(E)) self.desc = True self.pilImageCoverGenerica = Iconos().pilImageCoverGenerica self.cover = ImageTk.PhotoImage(self.pilImageCoverGenerica.resize(self.coverSize)) self.labelImagen['image'] = self.cover def callbackVariableBuscarPor(self,*args): self.buscarVolume() def int(self,t): return(int(t[0])) def treeview_sort_column(self, tv, col, reverse): l = [(tv.set(k, col), k) for k in tv.get_children('')] if col in['start_year','count_of_issues']: l.sort(reverse=reverse,key=self.int) else: l.sort(reverse=reverse) # rearrange items in sorted positions for index, (val, k) in enumerate(l): tv.move(k, '', index) # reverse sort next time tv.heading(col, command=lambda: self.treeview_sort_column(tv, col, not reverse)) def getSerie(self): print('retornando serie: ' + self.serie.nombre) return self.serie def itemClicked(self, event): if (self.grillaVolumes.selection()): seleccion = self.grillaVolumes.selection() id = self.grillaVolumes.item(seleccion,'values')[3] for volume in self.volumes: if volume.id == id: break; self.serie = volume #self.volumes[self.grillaVolumes.index(seleccion[0])] self.grillaVolumes.index(seleccion[0]) imagen = self.serie.getImageCover() self.cover = ImageTk.PhotoImage(imagen.resize(self.coverSize)) self.labelImagen['image'] = self.cover def seleccionarVolume(self): self.padre.destroy() def buscarVolume(self, orderBy=None): for item in self.grillaVolumes.get_children(): self.grillaVolumes.delete(item) consulta = None if self.entradaBuscarPorNombre.get()!='': consulta = self.session.query(Volume).filter(func.lower(Volume.nombre.like("%{}%".format(self.entradaBuscarPorNombre.get())))) else: consulta = self.session.query(Volume) if self.entradaBuscarPorEditorial.get()!='': consulta = consulta.filter(func.lower(Volume.publisher_name.like("%{}%".format(self.entradaBuscarPorEditorial.get())))) self.volumes = consulta.all() for volume in self.volumes: self.grillaVolumes.insert('', 'end', '', text='', values=(volume.nombre, volume.cantidadNumeros, volume.descripcion, volume.id, volume.image_url, volume.publisher_name, volume.anio_inicio))
def __init__(self, parent, comicbooks,session =None, *cnf, **kw): Frame.__init__(self, parent, *cnf, **kw) self.rowconfigure(0, weight=1) self.parent = parent self.rowconfigure(1, weight=1) self.comicCovers = [] # representa lo que vamos a catalogar. tomando como fuente de datos ComicVine self.comicbooks = comicbooks if session is not None: self.session = session else: self.session = Entidades.Init.Session() self.listaAMostrar =[] self.comicbook = self.comicbooks[0] self.comicbooks[0].openCbFile() self.comicbooks[0].goto(0) self.size = (160, 248) self.panelSourceComic = self.__createPanelComic__(self, comicbooks[0], self.comicbooks[0].getImagePage().resize(self.size,resample=Image.BICUBIC), 'Comic info') self.panelSourceComic.grid(column=0,row=0, sticky=(N, W, S, E)) style = ttk.Style() style.configure("BW.TLabel", foreground="black", background="green") self.panelListView=ttk.Frame(self) self.panelListView.grid(row=1, column=0, sticky=(N, W, S, E),columnspan=6) self.panelListView.grid_columnconfigure(0,weight=1) #dsadsadsa #dsdasda self.listViewComics = ttk.Treeview(self.panelListView) self.listViewComics['columns'] = ['Nro','Nombre_Archivo'] self.listViewComics['displaycolumns']=['Nombre_Archivo'] #, 'Total_Paginas', 'Porcentaje_Descargado'] self.listViewComics.heading('#0', text='Nro Comic') self.listViewComics.column('#0', width=100,stretch=True) self.listViewComics.heading('Nombre_Archivo', text='Nombre Archivo') self.listViewComics.column('Nombre_Archivo', width=1000) self.listViewComics.grid(row=0, column=0, sticky=(N, W, S, E),columnspan=2) self.listViewComics.bind("<<TreeviewSelect>>",self.listViewComicsClicked) self.entryPathRe = Entry(self.panelListView) self.entryPathRe.grid(column=0, row=1, sticky=(N, W, S, E), padx=5) self.botonAutoasignar = Button(self.panelListView,text='Auto asignar',command=self.AutoAsignar) self.botonAutoasignar.grid(column=1, row=1, sticky=(N, W, S, E)) self.iconoRedOrb = ImageTk.PhotoImage(Iconos().pilRedOrb) self.iconoGreenOrb = ImageTk.PhotoImage(Iconos().pilGreenOrb) for index,comic in enumerate(self.comicbooks): self.listViewComics.insert('', 'end', image = self.iconoRedOrb, text=comic.numero, values=([index,comic.path])) ##Panel opciones busqueda self.panelBusqueda = LabelFrame(self) self.panelBusqueda.grid(column=1, row=0, sticky=(N, W, S, E)) #self.entryTitulo = StringVar() self.entrySerie = StringVar() self.entryNumeroDesde = IntVar() self.entryNumeroHasta = IntVar() self.spinAnio = IntVar() self.seriesLookupFrame = ttk.Frame(self.panelBusqueda) self.seriesLookupFrame.grid(column=1, row=0, sticky=(W,E), pady=5) panelVolumenLookup=ttk.Frame(self.seriesLookupFrame) panelVolumenLookup.grid(column=1, row=0,sticky=(W,E)) ttk.Label(self.seriesLookupFrame, text='Volumen:').grid(column=0, row=0, sticky=(W), pady=5) self.pilImagenLookup = Iconos().pilImagenLookup self.lookupImage = ImageTk.PhotoImage(self.pilImagenLookup) ttk.Button(panelVolumenLookup, image=self.lookupImage, command=self.openSerieLookup).grid(column=2, row=0, sticky=(E), pady=5) ttk.Entry(panelVolumenLookup, textvariable=self.entrySerie).grid(column=1, row=0, sticky=(W), pady=5) ttk.Label(self.seriesLookupFrame, text='Número Desde/Hasta:').grid(column=0, row=1, sticky=(W), pady=5) Entry(self.seriesLookupFrame, textvariable=self.entryNumeroDesde).grid(column=1, row=1, sticky=(W), pady=5) Entry(self.seriesLookupFrame, textvariable=self.entryNumeroHasta).grid(column=2, row=1, sticky=(W), pady=5) self.botonCopiarGrupo = ttk.Button(self.seriesLookupFrame, text='Copiar Grupo', command=self.copiarInfoGrupoBtn) self.botonCopiarGrupo.grid(column=3, row=2, pady=5) botonBuscar = ttk.Button(self.seriesLookupFrame, text='Traer Todo', command=self.traerTodos) botonBuscar.grid(column=0, row=2, pady=5) botonBuscar = ttk.Button(self.seriesLookupFrame, text='Buscar', command=self.buscarSerie) botonBuscar.grid(column=1, row=2, pady=5) ##config grilla comics self.grillaComics = ttk.Treeview(self.seriesLookupFrame, columns=('numero','titulo','idComic'), displaycolumns=('numero','titulo')) self.grillaComics.heading('titulo', text='Título', command=lambda: self.treeview_sort_column(self.grillaComics, 'titulo', False)) self.grillaComics.heading('numero', text='Número', command=lambda: self.treeview_sort_column(self.grillaComics, 'numero', False)) self.grillaComics.config(show='headings') # tree, headings self.grillaComics.grid(column=0, row=3, columnspan=10, sticky=(N, E, S, W)) self.grillaComics.bind('<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() self.grillaComics.column('numero',width=65) self.grillaComics.column('titulo', width=400) # boton copiar datos ttk.Button(self.seriesLookupFrame, text='copiar info', command=self.copiarInfo).grid(column=2, row=2) print('--------------------------------------') ''' cargamos los datos que se guardaron de la ultima vez ''' self.setup = self.session.query(Setup).first() self.entryNumeroDesde.set(self.setup.ultimoNumeroConsultadoDesde) self.entryNumeroHasta.set(self.setup.ultimoNumeroConsultadoHasta) self.entrySerie.set(self.setup.ultimoVolumeIdUtilizado) self.entryPathRe.insert(0, self.setup.expresionRegularNumero)