Beispiel #1
0
    def buscardatos():
        for i in range(0, len(peliculas)):
            peliculas.pop()
        for i in range(0, len(listaPelis)):
            listaPelis.pop()
        Productora = comboBoxProductoraProductoras.get()
        if not Productora:
            comboBoxProductoraNombre.config(state="disabled")
            messagebox.showerror("Error",
                                 "Por favor ingrese una Productora válida.")
        else:
            idprod = colors.getIdByName(productoras, Productora)
            res = colors.buscarPorProductoraDatos(idprod)
            if res.status_code == requests.codes.ok:
                if len(res.json()) == 0:
                    comboBoxProductoraNombre.config(state="disabled")
                    messagebox.showinfo(
                        "Disculpe",
                        "No se encontró una película de esa Productora.")
                else:
                    for i in range(0, len(res.json())):
                        peliculas.append(res.json()[i])
                    nombres = colors.getListaNombres(peliculas)
                    for i in range(0, len(nombres)):
                        listaPelis.append(nombres[i])
                    comboBoxProductoraNombre.config(state="readonly")
                    comboBoxProductoraNombre["values"] = listaPelis
                    comboBoxProductoraNombre.current(0)
                    return cargarInfo("event")
            else:
                comboBoxProductoraNombre.config(state="disabled")
                messagebox.showerror(
                    "Error",
                    "No se pudo establecer comunicación con el servidor por favor intente más tarde"
                )
        entryProductoraGenero.config(state="normal")
        entryProductoraAnno.config(state="normal")

        entryProductoraGenero.delete(0, END)
        entryProductoraAnno.delete(0, END)

        entryProductoraGenero.config(state="readonly")
        entryProductoraAnno.config(state="readonly")
Beispiel #2
0
def agregarPeliWindow(root):
    #ventana principal
    frameAgregarPeli = Frame(root,
                             width=700,
                             height=500,
                             bg=backgroundColor[0])

    #frames

    frameAgregarNombre = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarGenero = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarDirector = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarFranquicia = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarPais = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarAnno = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarDuracion = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarActores = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarProductoras = Frame(frameAgregarPeli, bg=backgroundColor[0])
    frameAgregarPeliBotones = Frame(frameAgregarPeli, bg=backgroundColor[0])
    #labels
    labelAgregarPeli = Label(frameAgregarPeli,
                             text="Agregar Nueva Película",
                             font=("Arial Bold", 20),
                             fg=foregroundColor[0],
                             bg=backgroundColor[0])
    labelAgregarNombre = Label(frameAgregarNombre,
                               text="Nombre",
                               font=("Arial Bold", 11),
                               fg=foregroundColor[0],
                               bg=backgroundColor[0])
    labelAgregarGenero = Label(frameAgregarGenero,
                               text="Género",
                               font=("Arial Bold", 11),
                               fg=foregroundColor[0],
                               bg=backgroundColor[0])
    labelAgregarDirector = Label(frameAgregarDirector,
                                 text="Director",
                                 font=("Arial Bold", 11),
                                 fg=foregroundColor[0],
                                 bg=backgroundColor[0])
    labelAgregarFranquicia = Label(frameAgregarFranquicia,
                                   text="Franquicia (si corresponde)",
                                   font=("Arial Bold", 11),
                                   fg=foregroundColor[0],
                                   bg=backgroundColor[0])
    labelAgregarPais = Label(frameAgregarPais,
                             text="País",
                             font=("Arial Bold", 11),
                             fg=foregroundColor[0],
                             bg=backgroundColor[0])
    labelAgregarDuracion = Label(frameAgregarDuracion,
                                 text="Duración (en minutos)",
                                 font=("Arial Bold", 11),
                                 fg=foregroundColor[0],
                                 bg=backgroundColor[0])
    labelAgregarAnno = Label(frameAgregarAnno,
                             text="Año",
                             font=("Arial Bold", 11),
                             fg=foregroundColor[0],
                             bg=backgroundColor[0])
    labelAgregarActores = Label(frameAgregarActores,
                                text="Actores (separados por coma)",
                                font=("Arial Bold", 11),
                                fg=foregroundColor[0],
                                bg=backgroundColor[0])
    labelAgregarProductoras = Label(frameAgregarProductoras,
                                    text="Compañia Productora",
                                    font=("Arial Bold", 11),
                                    fg=foregroundColor[0],
                                    bg=backgroundColor[0])

    #funciones

    def cancelar():
        frameAgregarPeli.pack_forget()
        return

    #entrys
    productoras = cargarProductoras()
    if productoras == []:
        messagebox.showerror(
            "Error",
            "No existen compañías productoras, por favor agregue una antes de continuar."
        )
        return cancelar()
    elif productoras[0] == []:
        messagebox.showerror(
            "Error",
            "No se pudo establecer comunicación con el servidor, por favor intentelo más tarde."
        )
        return cancelar()
    listaProductoras = colors.getListaNombres(productoras)

    entryAgregarNombre = Entry(frameAgregarNombre,
                               width=40,
                               font=("Arial Bold", 11))
    entryAgregarGenero = Entry(frameAgregarGenero,
                               width=40,
                               font=("Arial Bold", 11))
    entryAgregarDirector = Entry(frameAgregarDirector,
                                 width=40,
                                 font=("Arial Bold", 11))
    entryAgregarFranquicia = Entry(frameAgregarFranquicia,
                                   width=40,
                                   font=("Arial Bold", 11))
    entryAgregarPais = Entry(frameAgregarPais,
                             width=40,
                             font=("Arial Bold", 11))
    entryAgregarAnno = Entry(frameAgregarAnno,
                             width=40,
                             font=("Arial Bold", 11))
    entryAgregarDuracion = Entry(frameAgregarDuracion,
                                 width=40,
                                 font=("Arial Bold", 11))
    entryAgregarActores = Entry(frameAgregarActores,
                                width=40,
                                font=("Arial Bold", 11))
    comboboxAgregarProductoras = ttk.Combobox(frameAgregarProductoras,
                                              width=40,
                                              font=("Arial Bold", 11),
                                              state="readonly")
    comboboxAgregarProductoras["values"] = listaProductoras
    comboboxAgregarProductoras.current(0)

    def agregar():
        year = datetime.date.today().year

        nombre = entryAgregarNombre.get()
        genero = entryAgregarGenero.get()
        director = entryAgregarDirector.get()
        franquicia = entryAgregarFranquicia.get()
        pais = entryAgregarPais.get()
        anno = entryAgregarAnno.get()
        duracion = entryAgregarDuracion.get()
        actores = entryAgregarActores.get()
        productora = comboboxAgregarProductoras.get()
        id_productora = colors.getIdByName(productoras, productora)

        if not nombre or not genero or not director or not pais or not anno or not duracion or not actores or not productora:
            messagebox.showerror(
                "Error", "Todos los campos menos franquicia son obligatorios")
        else:
            valido = False
            try:
                anno = int(anno)
                duracion = int(duracion)
                valido = True
            except ValueError:
                messagebox.showerror("Error",
                                     "El año y la duración deben ser números")
                valido = False
            if valido:
                if anno > year or anno < 1900 or duracion < 0:
                    messagebox.showerror(
                        "Error",
                        "Por favor inserte un año y una duración válidas")
                else:
                    actores = actores.split(",")
                    body = {
                        "nombre": nombre,
                        "genero": genero,
                        "nombreDirector": director,
                        "franquicia": franquicia,
                        "pais": pais,
                        "anno": anno,
                        "duracion": duracion,
                        "actores": actores,
                        "productora": id_productora
                    }
                    try:
                        res = colors.agregarPelicula(body)
                        messagebox.showinfo(
                            "Listo!", "Se agregó la película nueva con éxito.")
                        frameAgregarPeli.pack_forget()
                    except requests.exceptions.ConnectionError:
                        messagebox.showerror(
                            "Error",
                            "No se pudo establecer comunicación con el servidor, por favor intentelo más tarde."
                        )
                    return

    #botones

    botonAceptarAgregarPeli = Button(frameAgregarPeliBotones,
                                     text="Agregar",
                                     width=10,
                                     font=("Arial Bold", 11),
                                     bg=backgroundColor[4],
                                     command=agregar)
    botonCancelarAgregarPeli = Button(frameAgregarPeliBotones,
                                      text="Cancelar",
                                      width=10,
                                      font=("Arial Bold", 11),
                                      bg=backgroundColor[4],
                                      command=cancelar)

    #packs
    frameAgregarPeli.pack(fill=BOTH)
    labelAgregarPeli.pack()
    frameAgregarNombre.pack(fill=X)
    frameAgregarGenero.pack(fill=X)
    frameAgregarDirector.pack(fill=X)
    frameAgregarFranquicia.pack(fill=X)
    frameAgregarPais.pack(fill=X)
    frameAgregarAnno.pack(fill=X)
    frameAgregarDuracion.pack(fill=X)
    frameAgregarActores.pack(fill=X)
    frameAgregarProductoras.pack(fill=X, pady=10)
    frameAgregarPeliBotones.pack(fill=X)

    labelAgregarNombre.pack()
    labelAgregarGenero.pack()
    labelAgregarDirector.pack()
    labelAgregarFranquicia.pack()
    labelAgregarPais.pack()
    labelAgregarAnno.pack()
    labelAgregarDuracion.pack()
    labelAgregarActores.pack()
    labelAgregarProductoras.pack()

    entryAgregarNombre.pack()
    entryAgregarGenero.pack()
    entryAgregarDirector.pack()
    entryAgregarFranquicia.pack()
    entryAgregarPais.pack()
    entryAgregarAnno.pack()
    entryAgregarDuracion.pack()
    entryAgregarActores.pack()
    comboboxAgregarProductoras.pack()

    botonCancelarAgregarPeli.pack(side=RIGHT, padx=150)
    botonAceptarAgregarPeli.pack(side=RIGHT, padx=50)
Beispiel #3
0
def productoraPeliWindow(root):
    #ventana principal
    frameProductoraPeli = Frame(root,
                                width=700,
                                height=500,
                                bg=backgroundColor[0])

    #frames

    frameProductoraNombre = Frame(frameProductoraPeli, bg=backgroundColor[0])
    frameProductoraGenero = Frame(frameProductoraPeli, bg=backgroundColor[0])
    frameProductoraAnno = Frame(frameProductoraPeli, bg=backgroundColor[0])
    frameProductoraProductoras = Frame(frameProductoraPeli,
                                       bg=backgroundColor[0])
    frameProductoraPeliBotonesDatos = Frame(frameProductoraPeli,
                                            bg=backgroundColor[0])
    frameProductoraCantidad = Frame(frameProductoraPeli, bg=backgroundColor[0])
    frameProductoraDuracionMaxima = Frame(frameProductoraPeli,
                                          bg=backgroundColor[0])
    frameProductoraDuracionMinima = Frame(frameProductoraPeli,
                                          bg=backgroundColor[0])
    frameProductoraDuracionPromedio = Frame(frameProductoraPeli,
                                            bg=backgroundColor[0])
    frameProductoraPeliBotonesDuracion = Frame(frameProductoraPeli,
                                               bg=backgroundColor[0])

    #labels
    labelProductoraPeli = Label(frameProductoraPeli,
                                text="Consultar película por Productora",
                                font=("Arial Bold", 20),
                                fg=foregroundColor[0],
                                bg=backgroundColor[0])
    labelProductoraNombre = Label(frameProductoraNombre,
                                  text="Título",
                                  font=("Arial Bold", 10),
                                  fg=foregroundColor[0],
                                  bg=backgroundColor[0])
    labelProductoraGenero = Label(frameProductoraGenero,
                                  text="Género",
                                  font=("Arial Bold", 10),
                                  fg=foregroundColor[0],
                                  bg=backgroundColor[0])
    labelProductoraAnno = Label(frameProductoraAnno,
                                text="Año",
                                font=("Arial Bold", 10),
                                fg=foregroundColor[0],
                                bg=backgroundColor[0])
    labelProductoraProductoras = Label(frameProductoraProductoras,
                                       text="Compañia Productora",
                                       font=("Arial Bold", 10),
                                       fg=foregroundColor[0],
                                       bg=backgroundColor[0])
    labelProductoraCantidad = Label(frameProductoraCantidad,
                                    text="Cantidad",
                                    font=("Arial Bold", 10),
                                    fg=foregroundColor[0],
                                    bg=backgroundColor[0])
    labelProductoraDuracionMaxima = Label(frameProductoraDuracionMaxima,
                                          text="Duración Máxima",
                                          font=("Arial Bold", 10),
                                          fg=foregroundColor[0],
                                          bg=backgroundColor[0])
    labelProductoraDuracionMinima = Label(frameProductoraDuracionMinima,
                                          text="Duración Mínima",
                                          font=("Arial Bold", 10),
                                          fg=foregroundColor[0],
                                          bg=backgroundColor[0])
    labelProductoraDuracionPromedio = Label(frameProductoraDuracionPromedio,
                                            text="Duración Promedio",
                                            font=("Arial Bold", 10),
                                            fg=foregroundColor[0],
                                            bg=backgroundColor[0])

    #entrys
    productoras = cargarProductoras()
    if productoras == []:
        messagebox.showerror(
            "Error",
            "No existen compañías productoras, por favor agregue una antes de continuar."
        )
        return cancelar()
    elif productoras[0] == []:
        messagebox.showerror(
            "Error",
            "No se pudo establecer comunicación con el servir, por favor intentelo más tarde."
        )
        return cancelar()
    listaProduc = colors.getListaNombres(productoras)
    peliculas = []
    listaPelis = []

    comboBoxProductoraNombre = ttk.Combobox(frameProductoraNombre,
                                            width=40,
                                            font=("Arial Bold", 10),
                                            state="disabled")
    entryProductoraGenero = Entry(frameProductoraGenero,
                                  width=40,
                                  font=("Arial Bold", 10),
                                  state="readonly")
    entryProductoraAnno = Entry(frameProductoraAnno,
                                width=40,
                                font=("Arial Bold", 10),
                                state="readonly")
    entryProductoraCantidad = Entry(frameProductoraCantidad,
                                    width=40,
                                    font=("Arial Bold", 10),
                                    state="readonly")
    entryProductoraDuracionMaxima = Entry(frameProductoraDuracionMaxima,
                                          width=40,
                                          font=("Arial Bold", 10),
                                          state="readonly")
    entryProductoraDuracionMinima = Entry(frameProductoraDuracionMinima,
                                          width=40,
                                          font=("Arial Bold", 10),
                                          state="readonly")
    entryProductoraDuracionPromedio = Entry(frameProductoraDuracionPromedio,
                                            width=40,
                                            font=("Arial Bold", 10),
                                            state="readonly")

    comboBoxProductoraProductoras = ttk.Combobox(frameProductoraProductoras,
                                                 width=40,
                                                 font=("Arial Bold", 10),
                                                 state="readonly")
    comboBoxProductoraProductoras["values"] = listaProduc

    def cargarInfo(event):
        nombre = comboBoxProductoraNombre.get()
        indice = 0
        for i in range(0, len(listaPelis)):
            if listaPelis[i] == nombre:
                indice = i
                break

        entryProductoraGenero.config(state="normal")
        comboBoxProductoraNombre.config(state="normal")
        entryProductoraAnno.config(state="normal")

        entryProductoraGenero.delete(0, END)
        entryProductoraAnno.delete(0, END)

        nombreProd = "Productora no encontrada"
        entryProductoraGenero.insert(0, peliculas[indice]["genero"])
        entryProductoraAnno.insert(0, peliculas[indice]["anno"])
        comboBoxProductoraNombre.config(state="readonly")
        entryProductoraGenero.config(state="readonly")
        entryProductoraAnno.config(state="readonly")

    comboBoxProductoraNombre.bind("<<ComboboxSelected>>", cargarInfo)

    def buscardatos():
        for i in range(0, len(peliculas)):
            peliculas.pop()
        for i in range(0, len(listaPelis)):
            listaPelis.pop()
        Productora = comboBoxProductoraProductoras.get()
        if not Productora:
            comboBoxProductoraNombre.config(state="disabled")
            messagebox.showerror("Error",
                                 "Por favor ingrese una Productora válida.")
        else:
            idprod = colors.getIdByName(productoras, Productora)
            res = colors.buscarPorProductoraDatos(idprod)
            if res.status_code == requests.codes.ok:
                if len(res.json()) == 0:
                    comboBoxProductoraNombre.config(state="disabled")
                    messagebox.showinfo(
                        "Disculpe",
                        "No se encontró una película de esa Productora.")
                else:
                    for i in range(0, len(res.json())):
                        peliculas.append(res.json()[i])
                    nombres = colors.getListaNombres(peliculas)
                    for i in range(0, len(nombres)):
                        listaPelis.append(nombres[i])
                    comboBoxProductoraNombre.config(state="readonly")
                    comboBoxProductoraNombre["values"] = listaPelis
                    comboBoxProductoraNombre.current(0)
                    return cargarInfo("event")
            else:
                comboBoxProductoraNombre.config(state="disabled")
                messagebox.showerror(
                    "Error",
                    "No se pudo establecer comunicación con el servidor por favor intente más tarde"
                )
        entryProductoraGenero.config(state="normal")
        entryProductoraAnno.config(state="normal")

        entryProductoraGenero.delete(0, END)
        entryProductoraAnno.delete(0, END)

        entryProductoraGenero.config(state="readonly")
        entryProductoraAnno.config(state="readonly")

    #funciones

    def buscarduracion():
        Productora = comboBoxProductoraProductoras.get()
        if not Productora:
            comboBoxProductoraNombre.config(state="disabled")
            messagebox.showerror("Error",
                                 "Por favor ingrese una Productora válida.")
        else:
            idprod = colors.getIdByName(productoras, Productora)
            res = colors.buscarPorProductoraDuracion(idprod)
            if res.status_code == requests.codes.ok:
                if len(res.json()) == 0:
                    messagebox.showinfo(
                        "Disculpe",
                        "No se encontró una película de esa Productora.")
                else:
                    valores = res.json()[0]["value"]
                    print(res.json()[0])
                    entryProductoraCantidad.config(state="normal")
                    entryProductoraDuracionMaxima.config(state="normal")
                    entryProductoraDuracionMinima.config(state="normal")
                    entryProductoraDuracionPromedio.config(state="normal")

                    entryProductoraCantidad.delete(0, END)
                    entryProductoraDuracionMaxima.delete(0, END)
                    entryProductoraDuracionMinima.delete(0, END)
                    entryProductoraDuracionPromedio.delete(0, END)

                    entryProductoraCantidad.insert(0, valores["cantidad"])
                    entryProductoraDuracionMaxima.insert(
                        0, valores["duracionMaxima"])
                    entryProductoraDuracionMinima.insert(
                        0, valores["duracionMinima"])
                    entryProductoraDuracionPromedio.insert(
                        0, valores["duracionPromedio"])

                    entryProductoraCantidad.config(state="readonly")
                    entryProductoraDuracionMaxima.config(state="readonly")
                    entryProductoraDuracionMinima.config(state="readonly")
                    entryProductoraDuracionPromedio.config(state="readonly")

    def cancelar():
        frameProductoraPeli.pack_forget()
        return

    #botones

    botonBuscarProductoraPeli = Button(frameProductoraPeliBotonesDatos,
                                       text="Buscar datos de películas",
                                       font=("Arial Bold", 10),
                                       bg=backgroundColor[4],
                                       command=buscardatos)
    botonCancelarProductoraPeli = Button(frameProductoraDuracionPromedio,
                                         text="Cancelar",
                                         font=("Arial Bold", 10),
                                         bg=backgroundColor[4],
                                         command=cancelar)
    botonBuscarDuracionProductoraPeli = Button(
        frameProductoraPeliBotonesDuracion,
        text="Buscar información de duración",
        font=("Arial Bold", 10),
        bg=backgroundColor[4],
        command=buscarduracion)

    #packs

    frameProductoraPeli.pack(fill=BOTH)
    labelProductoraPeli.pack()
    frameProductoraProductoras.pack(fill=X, pady=5)
    frameProductoraPeliBotonesDatos.pack(fill=X)
    frameProductoraNombre.pack(fill=X)
    frameProductoraGenero.pack(fill=X)
    frameProductoraAnno.pack(fill=X, pady=5)
    frameProductoraPeliBotonesDuracion.pack(fill=X)
    frameProductoraCantidad.pack(fill=X)
    frameProductoraDuracionMaxima.pack(fill=X)
    frameProductoraDuracionMinima.pack(fill=X)
    frameProductoraDuracionPromedio.pack(fill=X, pady=5)

    labelProductoraNombre.pack()
    labelProductoraGenero.pack()
    labelProductoraAnno.pack()
    labelProductoraCantidad.pack()
    labelProductoraDuracionMaxima.pack()
    labelProductoraDuracionMinima.pack()
    labelProductoraDuracionPromedio.pack()

    comboBoxProductoraNombre.pack()
    entryProductoraGenero.pack()
    entryProductoraAnno.pack()
    comboBoxProductoraProductoras.pack()
    entryProductoraCantidad.pack()
    entryProductoraDuracionMaxima.pack()
    entryProductoraDuracionMinima.pack()
    entryProductoraDuracionPromedio.pack()

    botonBuscarProductoraPeli.pack(side=TOP)
    botonBuscarDuracionProductoraPeli.pack(side=TOP)
    botonCancelarProductoraPeli.pack(side=TOP, pady=10)
Beispiel #4
0
    def buscar():
        for i in range (0, len(peliculas)):
            peliculas.pop()
        for i in range (0, len(listaPelis)):
            listaPelis.pop()
        annoInicial = entryAnnoAnnoInicial.get()
        annoFinal = entryAnnoAnnoFinal.get()
        year = datetime.date.today().year

        if not annoInicial or not annoFinal:
            comboBoxAnnoNombre.config(state="disabled")
            messagebox.showerror("Error", "Por favor ingrese años válidos.")
        else:
            try:
                annoInicial = int (annoInicial)
                annoFinal = int (annoFinal)
                valido = True
            except ValueError:
                messagebox.showerror("Error", "El año debe ser un número")
                valido = False
            if valido:
                if annoFinal > year or annoInicial < 1900:
                    messagebox.showerror("Error", "Por favor ingrese años válidos.")
                else:
                    res = colors.buscarPorAnno(annoInicial, annoFinal)
                    if res.status_code == requests.codes.ok:

                        if len(res.json()) == 0:
                            comboBoxAnnoNombre.config(state="disabled")
                            messagebox.showinfo("Disculpe", "No se encontraron películas en esos años.")             

                        else:
                            for i in range (0, len (res.json())):
                                peliculas.append(res.json()[i])
                            nombres = colors.getListaNombres(peliculas)
                            for i in range (0, len(nombres)):
                                listaPelis.append(nombres[i])
                            comboBoxAnnoNombre.config(state="readonly")
                            comboBoxAnnoNombre["values"] = listaPelis
                            comboBoxAnnoNombre.current(0)
                            return cargarInfo("event")
                    else:
                        messagebox.showerror("Error", "No se pudo establecer comunicación con el servidor, por favor intentelo más tarde.")
                        comboBoxAnnoNombre.config(state="disabled")
            else:
                comboBoxAnnoNombre.config(state="disabled")
        entryAnnoGenero.config(state="normal")
        entryAnnoDirector.config(state="normal")
        entryAnnoPais.config(state="normal")
        entryAnnoFranquicia.config(state="normal")
        entryAnnoDuracion.config(state="normal")
        entryAnnoActores.config(state="normal")
        entryAnnoProductoras.config(state="normal")

        entryAnnoGenero.delete(0, END)
        entryAnnoDirector.delete(0, END)
        entryAnnoPais.delete(0, END)
        entryAnnoFranquicia.delete(0, END)
        entryAnnoDuracion.delete(0, END)
        entryAnnoActores.delete(0, END)
        entryAnnoProductoras.delete(0, END)

        entryAnnoGenero.config(state="readonly")
        entryAnnoDirector.config(state="readonly")
        entryAnnoPais.config(state="readonly")
        entryAnnoFranquicia.config(state="readonly")
        entryAnnoDuracion.config(state="readonly")
        entryAnnoActores.config(state="readonly")
        entryAnnoProductoras.config(state="readonly")
Beispiel #5
0
def leerPeliWindow(root):
    #ventana principal
    frameLeerPeli = Frame(root, width = 700, height = 500, bg = backgroundColor[0]) 

    #frames

    frameLeerNombre = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerGenero = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerDirector = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerFranquicia = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerPais = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerAnno = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerDuracion = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerActores = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerProductoras = Frame(frameLeerPeli, bg = backgroundColor[0])
    frameLeerPeliBotones = Frame(frameLeerPeli, bg = backgroundColor[0])
    #labels
    labelLeerPeli = Label(frameLeerPeli, text = "Consultar Información de Películas", font= ("Arial Bold", 20), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerNombre = Label(frameLeerNombre, text= "Nombre", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerGenero = Label(frameLeerGenero, text= "Género", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerDirector = Label(frameLeerDirector, text= "Director", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerFranquicia = Label(frameLeerFranquicia, text= "Franquicia", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerPais = Label(frameLeerPais, text= "País", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerAnno = Label(frameLeerAnno, text= "Año", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerDuracion = Label(frameLeerDuracion, text= "Duración (en minutos)", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerActores = Label(frameLeerActores, text= "Actores (separados por coma)", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])
    labelLeerProductoras = Label(frameLeerProductoras, text= "Compañia Productora", font= ("Arial Bold", 11), fg= foregroundColor[0], bg=backgroundColor[0])

    #entrys
    productoras = cargarProductoras()
    if productoras == []:
        messagebox.showerror("Error", "No existen compañías productoras, por favor agregue una antes de continuar.")
        return cancelar()
    elif productoras[0] == []:
        messagebox.showerror("Error", "No se pudo establecer comunicación con el servir, por favor intentelo más tarde.")
        return cancelar()

    peliculas = cargarPeliculas()
    if peliculas == []:
        messagebox.showerror("Error", "No existen películas, por favor agregue una antes de continuar.")
        return cancelar()
    elif peliculas[0] == []:
        messagebox.showerror("Error", "No se pudo establecer comunicación con el servidor, por favor intentelo más tarde.")
        return cancelar()
    

    listaPelis = colors.getListaNombres(peliculas)
    comboboxLeerNombre = ttk.Combobox(frameLeerNombre, width = 40, font= ("Arial Bold", 11), state = "readonly")
    comboboxLeerNombre["values"] = listaPelis
    entryLeerGenero = Entry(frameLeerGenero, width = 40, font= ("Arial Bold", 11), state = "readonly")
    entryLeerDirector = Entry(frameLeerDirector, width = 40, font= ("Arial Bold", 11), state = "readonly")
    entryLeerFranquicia = Entry(frameLeerFranquicia, width = 40, font= ("Arial Bold", 11), state = "readonly")
    entryLeerPais= Entry(frameLeerPais, width = 40, font= ("Arial Bold", 11), state = "readonly")
    entryLeerAnno = Entry(frameLeerAnno, width = 40, font= ("Arial Bold", 11), state = "readonly")
    entryLeerDuracion = Entry(frameLeerDuracion, width = 40, font= ("Arial Bold", 11), state = "readonly")
    entryLeerActores = Entry(frameLeerActores, width = 40, font= ("Arial Bold", 11), state = "readonly")
    entryLeerProductoras = Entry(frameLeerProductoras, width = 40, font= ("Arial Bold", 11),  state= "readonly")

    def cargarInfo(event):
        indice = 0
        for i in range (0, len(listaPelis)):
            if listaPelis[i] == comboboxLeerNombre.get():
                indice = i
                break
        nombreProd = "Productora no encontrada"
        for i in range(0, len (productoras)):
            if productoras[i]["_id"] == peliculas[indice]["productora"]:
                nombreProd = productoras[i]["nombre"]
                break
        actores = ""
        cantActores = len(peliculas[indice]["actores"])
        for i in range (0, cantActores):
            actores = actores + peliculas[indice]["actores"][i]
            if i + 1 < cantActores:
                actores = actores + ", "
            

        entryLeerGenero.config(state="normal")
        entryLeerDirector.config(state="normal")
        entryLeerFranquicia.config(state="normal")
        entryLeerPais.config(state="normal")
        entryLeerAnno.config(state="normal")
        entryLeerDuracion.config(state="normal")
        entryLeerActores.config(state="normal")
        entryLeerProductoras.config(state="normal")
    
        entryLeerGenero.delete(0, END)
        entryLeerDirector.delete(0, END)
        entryLeerFranquicia.delete(0, END)
        entryLeerPais.delete(0, END)
        entryLeerAnno.delete(0, END)
        entryLeerDuracion.delete(0, END)
        entryLeerActores.delete(0, END)
        entryLeerProductoras.delete(0, END)

        entryLeerGenero.insert(0,peliculas[indice]["genero"])
        entryLeerDirector.insert(0,peliculas[indice]["nombreDirector"])
        entryLeerFranquicia.insert(0,peliculas[indice]["franquicia"])
        entryLeerPais.insert(0,peliculas[indice]["pais"])
        entryLeerAnno.insert(0,peliculas[indice]["anno"])
        entryLeerDuracion.insert(0,peliculas[indice]["duracion"])
        entryLeerActores.insert(0, actores)
        entryLeerProductoras.insert(0,nombreProd)

        entryLeerGenero.config(state="readonly")
        entryLeerDirector.config(state="readonly")
        entryLeerFranquicia.config(state="readonly")
        entryLeerPais.config(state="readonly")
        entryLeerAnno.config(state="readonly")
        entryLeerDuracion.config(state="readonly")
        entryLeerActores.config(state="readonly")
        entryLeerProductoras.config(state="readonly")
    
    
    comboboxLeerNombre.bind("<<ComboboxSelected>>", cargarInfo)

    #funciones

    def volver():
        frameLeerPeli.pack_forget()
        return    
    #botones

    botonVolverLeerPeli = Button(frameLeerPeliBotones, text="Volver" , width= 10, font= ("Arial Bold", 11), bg = backgroundColor[4], command= volver)

    #packs
    frameLeerPeli.pack(fill = BOTH)
    labelLeerPeli.pack()
    frameLeerNombre.pack(fill = X)
    frameLeerGenero.pack(fill = X)
    frameLeerDirector.pack(fill = X)
    frameLeerFranquicia.pack(fill = X)
    frameLeerPais.pack(fill = X)
    frameLeerAnno.pack(fill = X)
    frameLeerDuracion.pack(fill = X)
    frameLeerActores.pack(fill = X)
    frameLeerProductoras.pack(fill = X, pady = 10)
    frameLeerPeliBotones.pack(fill=X)

    labelLeerNombre.pack()
    labelLeerGenero.pack()
    labelLeerDirector.pack()
    labelLeerFranquicia.pack()
    labelLeerPais.pack()
    labelLeerAnno.pack()
    labelLeerDuracion.pack()
    labelLeerActores.pack()
    labelLeerProductoras.pack()

    comboboxLeerNombre.pack()
    entryLeerGenero.pack()
    entryLeerDirector.pack()
    entryLeerFranquicia.pack()
    entryLeerPais.pack()
    entryLeerAnno.pack()
    entryLeerDuracion.pack()
    entryLeerActores.pack()
    entryLeerProductoras.pack()

    botonVolverLeerPeli.pack(side = TOP)
Beispiel #6
0
def eliminarPeliWindow(root):
    #ventana principal
    frameEliminarPeli = Frame(root,
                              width=700,
                              height=500,
                              bg=backgroundColor[0])

    #frames

    frameEliminarNombre = Frame(frameEliminarPeli, bg=backgroundColor[0])
    frameEliminarPeliBotones = Frame(frameEliminarPeli, bg=backgroundColor[0])
    #labels
    labelEliminarPeli = Label(frameEliminarPeli,
                              text="Eliminar Película",
                              font=("Arial Bold", 20),
                              fg=foregroundColor[0],
                              bg=backgroundColor[0])
    labelEliminarNombre = Label(frameEliminarNombre,
                                text="Nombre",
                                font=("Arial Bold", 15),
                                fg=foregroundColor[0],
                                bg=backgroundColor[0])

    #entrys

    peliculas = cargarPeliculas()
    if peliculas == []:
        messagebox.showerror(
            "Error",
            "No existen películas, por favor agregue una antes de continuar.")
        return cancelar()
    elif peliculas[0] == []:
        messagebox.showerror(
            "Error",
            "No se pudo establecer comunicación con el servidor, por favor intentelo más tarde."
        )
        return cancelar()

    listaNombres = colors.getListaNombres(peliculas)

    comboboxEliminarNombre = ttk.Combobox(frameEliminarNombre,
                                          width=40,
                                          font=("Arial Bold", 15),
                                          state="readonly")
    comboboxEliminarNombre["values"] = listaNombres
    comboboxEliminarNombre.current(0)

    #funciones

    def cancelar():
        frameEliminarPeli.pack_forget()
        return

    def eliminar():
        nombre = comboboxEliminarNombre.get()
        id = colors.getIdByName(peliculas, nombre)
        res = colors.borrarPelicula(id)
        if res.status_code == requests.codes.ok:
            messagebox.showinfo("Listo!", "Se eliminó la película con éxito")
            frameEliminarPeli.pack_forget()
            return
        else:
            messagebox.showerror(
                "Error",
                "No se pudo establecer comunicación con el servidor, por favor intentelo más tarde."
            )

    #botones

    botonAceptarEliminarPeli = Button(frameEliminarPeliBotones,
                                      text="Eliminar",
                                      width=10,
                                      font=("Arial Bold", 15),
                                      bg=backgroundColor[4],
                                      command=eliminar)
    botonCancelarEliminarPeli = Button(frameEliminarPeliBotones,
                                       text="Cancelar",
                                       width=10,
                                       font=("Arial Bold", 15),
                                       bg=backgroundColor[4],
                                       command=cancelar)

    #packs
    frameEliminarPeli.pack(fill=BOTH)
    labelEliminarPeli.pack()
    frameEliminarNombre.pack(fill=X, pady=100)
    frameEliminarPeliBotones.pack(fill=X)

    labelEliminarNombre.pack()

    comboboxEliminarNombre.pack()

    botonCancelarEliminarPeli.pack(side=RIGHT, padx=100, pady=50)
    botonAceptarEliminarPeli.pack(side=RIGHT, padx=100, pady=50)
Beispiel #7
0
def leerProduWindow(root):
    #ventana principal
    frameLeerProdu = Frame(root, width=700, height=500, bg=backgroundColor[0])

    #frames

    frameLeerNombreProdu = Frame(frameLeerProdu, bg=backgroundColor[0])
    frameLeerAnnoProdu = Frame(frameLeerProdu, bg=backgroundColor[0])
    frameLeerDireccionProdu = Frame(frameLeerProdu, bg=backgroundColor[0])
    frameLeerProduBotones = Frame(frameLeerProdu, bg=backgroundColor[0])
    #labels
    labelLeerProdu = Label(frameLeerProdu,
                           text="Leer Nueva Compañía Productora",
                           font=("Arial Bold", 20),
                           fg=foregroundColor[0],
                           bg=backgroundColor[0])
    labelLeerNombreProdu = Label(frameLeerNombreProdu,
                                 text="Nombre",
                                 font=("Arial Bold", 15),
                                 fg=foregroundColor[0],
                                 bg=backgroundColor[0])
    labelLeerAnnoProdu = Label(frameLeerAnnoProdu,
                               text="Año de creación",
                               font=("Arial Bold", 15),
                               fg=foregroundColor[0],
                               bg=backgroundColor[0])
    labelLeerDireccionProdu = Label(frameLeerDireccionProdu,
                                    text="Dirección",
                                    font=("Arial Bold", 15),
                                    fg=foregroundColor[0],
                                    bg=backgroundColor[0])

    #funciones

    def volver():
        frameLeerProdu.pack_forget()
        return

    #entrys
    productoras = cargarProductoras()
    if productoras == []:
        messagebox.showerror(
            "Error",
            "No existen compañías productoras, por favor agregue una antes de continuar."
        )
        return volver()
    elif productoras[0] == []:
        messagebox.showerror(
            "Error",
            "No se pudo establecer comunicación con el servir, por favor intentelo más tarde."
        )
        return volver()

    listaProductoras = colors.getListaNombres(productoras)
    comboboxLeerNombreProdu = ttk.Combobox(frameLeerNombreProdu,
                                           width=40,
                                           font=("Arial Bold", 15),
                                           state="readonly")
    comboboxLeerNombreProdu["values"] = listaProductoras
    entryLeerAnnoProdu = Entry(frameLeerAnnoProdu,
                               width=40,
                               font=("Arial Bold", 15),
                               state="readonly")
    entryLeerDireccionProdu = Entry(frameLeerDireccionProdu,
                                    width=40,
                                    font=("Arial Bold", 15),
                                    state="readonly")

    def cargarInfo(event):

        indice = 0
        for i in range(0, len(listaProductoras)):
            if listaProductoras[i] == comboboxLeerNombreProdu.get():
                indice = i
                break

        entryLeerAnnoProdu.config(state="normal")
        entryLeerDireccionProdu.config(state="normal")

        entryLeerAnnoProdu.delete(0, END)
        entryLeerDireccionProdu.delete(0, END)

        entryLeerAnnoProdu.insert(0, productoras[indice]["anno"])
        entryLeerDireccionProdu.insert(0, productoras[indice]["direccion"])

    comboboxLeerNombreProdu.bind("<<ComboboxSelected>>", cargarInfo)
    #botones

    botonVolverLeerProdu = Button(frameLeerProduBotones,
                                  text="Volver",
                                  width=10,
                                  font=("Arial Bold", 15),
                                  bg=backgroundColor[4],
                                  command=volver)

    #packs
    frameLeerProdu.pack(fill=BOTH)
    labelLeerProdu.pack()
    frameLeerNombreProdu.pack(fill=X, pady=25)
    frameLeerAnnoProdu.pack(fill=X, pady=25)
    frameLeerDireccionProdu.pack(fill=X, pady=25)
    frameLeerProduBotones.pack(fill=X, pady=20)

    labelLeerNombreProdu.pack()
    labelLeerAnnoProdu.pack()
    labelLeerDireccionProdu.pack()

    comboboxLeerNombreProdu.pack()
    entryLeerAnnoProdu.pack()
    entryLeerDireccionProdu.pack()

    botonVolverLeerProdu.pack(side=TOP)
Beispiel #8
0
    def buscar():
        for i in range(0, len(peliculas)):
            peliculas.pop()
        for i in range(0, len(listaPelis)):
            listaPelis.pop()
        franquicia = entryFranquiciaFranquicia.get()
        if not franquicia:
            comboBoxFranquiciaNombre.config(state="disabled")

            messagebox.showerror("Error",
                                 "Por favor ingrese una franquicia válida.")
        else:
            res = colors.buscarPorFranquicia(franquicia)
            if res.status_code == requests.codes.ok:
                if len(res.json()) == 0:
                    comboBoxFranquiciaNombre.config(state="disabled")
                    messagebox.showinfo(
                        "Disculpe",
                        "No se encontró una película en esa franquicia.")

                else:

                    for i in range(0, len(res.json())):
                        peliculas.append(res.json()[i])
                    nombres = colors.getListaNombres(peliculas)
                    for i in range(0, len(nombres)):
                        listaPelis.append(nombres[i])

                    comboBoxFranquiciaNombre.config(state="readonly")
                    comboBoxFranquiciaNombre["values"] = listaPelis
                    comboBoxFranquiciaNombre.current(0)
                    return cargarInfo("event")
            else:
                comboBoxFranquiciaNombre.config(state="disabled")
                messagebox.showerror(
                    "Error",
                    "No se pudo establecer comunicación con el servidor por favor intente más tarde"
                )
        entryFranquiciaGenero.config(state="normal")
        entryFranquiciaDirector.config(state="normal")
        entryFranquiciaPais.config(state="normal")
        entryFranquiciaAnno.config(state="normal")
        entryFranquiciaDuracion.config(state="normal")
        entryFranquiciaActores.config(state="normal")
        entryFranquiciaProductoras.config(state="normal")

        entryFranquiciaGenero.delete(0, END)
        entryFranquiciaDirector.delete(0, END)
        entryFranquiciaPais.delete(0, END)
        entryFranquiciaAnno.delete(0, END)
        entryFranquiciaDuracion.delete(0, END)
        entryFranquiciaActores.delete(0, END)
        entryFranquiciaProductoras.delete(0, END)

        entryFranquiciaGenero.config(state="readonly")
        entryFranquiciaDirector.config(state="readonly")
        entryFranquiciaPais.config(state="readonly")
        entryFranquiciaAnno.config(state="readonly")
        entryFranquiciaDuracion.config(state="readonly")
        entryFranquiciaActores.config(state="readonly")
        entryFranquiciaProductoras.config(state="readonly")
def actualizarProduWindow(root):
    #ventana principal
    frameActualizarProdu = Frame(root,
                                 width=700,
                                 height=500,
                                 bg=backgroundColor[0])

    #frames

    frameActualizarNombreProdu = Frame(frameActualizarProdu,
                                       bg=backgroundColor[0])
    frameActualizarAnnoProdu = Frame(frameActualizarProdu,
                                     bg=backgroundColor[0])
    frameActualizarDireccionProdu = Frame(frameActualizarProdu,
                                          bg=backgroundColor[0])
    frameActualizarProduBotones = Frame(frameActualizarProdu,
                                        bg=backgroundColor[0])
    #labels
    labelActualizarProdu = Label(frameActualizarProdu,
                                 text="Actualizar Compañía Productora",
                                 font=("Arial Bold", 20),
                                 fg=foregroundColor[0],
                                 bg=backgroundColor[0])
    labelActualizarNombreProdu = Label(frameActualizarNombreProdu,
                                       text="Nombre",
                                       font=("Arial Bold", 15),
                                       fg=foregroundColor[0],
                                       bg=backgroundColor[0])
    labelActualizarAnnoProdu = Label(frameActualizarAnnoProdu,
                                     text="Año de creación",
                                     font=("Arial Bold", 15),
                                     fg=foregroundColor[0],
                                     bg=backgroundColor[0])
    labelActualizarDireccionProdu = Label(frameActualizarDireccionProdu,
                                          text="Direccion",
                                          font=("Arial Bold", 15),
                                          fg=foregroundColor[0],
                                          bg=backgroundColor[0])

    #funciones

    def cancelar():
        frameActualizarProdu.pack_forget()
        return

    #entrys
    productoras = cargarProductoras()
    if productoras == []:
        messagebox.showerror(
            "Error",
            "No existen compañías productoras, por favor agregue una antes de continuar."
        )
        return cancelar()
    elif productoras[0] == []:
        messagebox.showerror(
            "Error",
            "No se pudo establecer comunicación con el servir, por favor intentelo más tarde."
        )
        return cancelar()

    listaProductoras = colors.getListaNombres(productoras)
    comboboxActualizarNombreProdu = ttk.Combobox(frameActualizarNombreProdu,
                                                 width=40,
                                                 font=("Arial Bold", 15),
                                                 state="readonly")
    comboboxActualizarNombreProdu["values"] = listaProductoras
    entryActualizarAnnoProdu = Entry(frameActualizarAnnoProdu,
                                     width=40,
                                     font=("Arial Bold", 15))
    entryActualizarDireccionProdu = Entry(frameActualizarDireccionProdu,
                                          width=40,
                                          font=("Arial Bold", 15))

    def actualizar():
        idProd = colors.getIdByName(productoras,
                                    comboboxActualizarNombreProdu.get())
        year = datetime.date.today().year
        anno = entryActualizarAnnoProdu.get()
        nombre = comboboxActualizarNombreProdu.get()
        direccion = entryActualizarDireccionProdu.get()
        if not nombre or not direccion:
            messagebox.showerror("Error", "Debe llenar todos los campos")
        elif not anno:
            messagebox.showerror("Error", "Por favor inserte un año válido")
        else:
            valido = False
            try:
                anno = int(anno)
                valido = True
            except ValueError:
                messagebox.showerror("Error", "El año debe ser un número")
                valido = False
            if valido:
                if anno > year or anno < 1900:
                    messagebox.showerror("Error",
                                         "Por favor inserte un año válido")

                else:
                    body = {
                        "nombre": nombre,
                        "anno": anno,
                        "direccion": direccion
                    }
                    try:
                        res = colors.actualizarProductora(body, idProd)
                        messagebox.showinfo(
                            "Listo!", "Se actualizó la productora con éxito.")
                        frameActualizarProdu.pack_forget()
                    except requests.exceptions.ConnectionError:
                        messagebox.showerror(
                            "Error",
                            "No se pudo establecer comunicación con el servidor, por favor intentelo más tarde."
                        )
                    return

    def cargarInfo(event):
        indice = 0
        for i in range(0, len(listaProductoras)):
            if listaProductoras[i] == comboboxActualizarNombreProdu.get():
                indice = i
                break

        entryActualizarAnnoProdu.config(state="normal")
        entryActualizarDireccionProdu.config(state="normal")

        entryActualizarAnnoProdu.delete(0, END)
        entryActualizarDireccionProdu.delete(0, END)

        entryActualizarAnnoProdu.insert(0, productoras[indice]["anno"])
        entryActualizarDireccionProdu.insert(0,
                                             productoras[indice]["direccion"])

    comboboxActualizarNombreProdu.bind("<<ComboboxSelected>>", cargarInfo)

    #botones

    botonAceptarActualizarProdu = Button(frameActualizarProduBotones,
                                         text="Actualizar",
                                         width=10,
                                         font=("Arial Bold", 15),
                                         bg=backgroundColor[4],
                                         command=actualizar)
    botonCancelarActualizarProdu = Button(frameActualizarProduBotones,
                                          text="Cancelar",
                                          width=10,
                                          font=("Arial Bold", 15),
                                          bg=backgroundColor[4],
                                          command=cancelar)

    #packs
    frameActualizarProdu.pack(fill=BOTH)
    labelActualizarProdu.pack()
    frameActualizarNombreProdu.pack(fill=X, pady=25)
    frameActualizarAnnoProdu.pack(fill=X, pady=25)
    frameActualizarDireccionProdu.pack(fill=X, pady=25)
    frameActualizarProduBotones.pack(fill=X, pady=20)

    labelActualizarNombreProdu.pack()
    labelActualizarAnnoProdu.pack()
    labelActualizarDireccionProdu.pack()

    comboboxActualizarNombreProdu.pack()
    entryActualizarAnnoProdu.pack()
    entryActualizarDireccionProdu.pack()

    botonCancelarActualizarProdu.pack(side=RIGHT, padx=100)
    botonAceptarActualizarProdu.pack(side=RIGHT, padx=100)