Beispiel #1
0
class MY_GUI():
    def __init__(self, init_window_name):
        self.init_window_name = init_window_name

    #设置窗口
    def set_init_window(self):
        ft1 = tkFont.Font(family='Arial', size=10, weight=tkFont.BOLD)
        ft_text = tkFont.Font(family='Arial', size=15)
        self.init_window_name.title("math quiz generator")
        #self.init_window_name.geometry('320x160+10+10')
        self.init_window_name.geometry('1000x700+10+10')
        # self.init_window_name["bg"] = "pink"
        # self.init_window_name.attributes("-alpha",0.9)

        self.choose_lable = Label(self.init_window_name,
                                  text="Please choose a Knowledge Component",
                                  font=ft1)
        self.choose_lable.grid(row=0, column=0, columnspan=2)

        # Drop down box
        from tkinter import ttk
        # self.drop_down_box = Combobox_Autocomplete(self.init_window_name, kc_list, listbox_width=150, highlightthickness=1)
        # self.drop_down_box.focus()
        self.drop_down_box = AutocompleteCombobox(self.init_window_name,
                                                  completevalues=kc_list,
                                                  width=150)
        self.drop_down_box.grid(row=1, column=0, columnspan=2)

        self.choose_language_label = Label(self.init_window_name,
                                           text="Please choose language",
                                           font=ft1)
        self.choose_language_label.grid(row=2, column=0)
        self.choose_language_box = ttk.Combobox(self.init_window_name,
                                                values=['English', 'Dutch'],
                                                width=50)
        self.choose_language_box.grid(row=3, column=0)
        self.is_retrieve = BooleanVar()
        self.choose_retrieve_button = ttk.Checkbutton(
            self.init_window_name,
            text='Retrieve Image or Not',
            variable=self.is_retrieve)
        self.choose_retrieve_button.grid(row=3, column=1)

        # Button
        self.str_generate_button = Button(self.init_window_name,
                                          text="Generate",
                                          bg="lightblue",
                                          width=10,
                                          command=self.generator)
        self.str_generate_button.grid(row=4, column=0, columnspan=2)
        self.result_data_label = Label(self.init_window_name,
                                       text="Generated question",
                                       font=ft1)
        self.result_data_label.grid(row=9, column=0)

        self.result_data_Text = Text(self.init_window_name, width=50)
        self.result_data_Text.grid(row=10, column=0)
        self.answer_label = Label(self.init_window_name,
                                  text="Answer",
                                  font=ft1)
        self.answer_label.grid(row=9, column=1)
        self.answer_data_Text = Text(self.init_window_name, width=50)
        self.answer_data_Text.grid(row=10, column=1)
        self.image_label = Label(self.init_window_name, text="Image", font=ft1)
        self.image_label.grid(row=11, column=0, columnspan=2)
        self.image_data_Text = Text(self.init_window_name, width=100)
        self.image_data_Text.grid(row=12, column=0, columnspan=2)
        self.img_label = Label(self.init_window_name, image=None)

    def generator(self):
        self.img_label.grid_forget()
        kc = self.drop_down_box.get()
        language = self.choose_language_box.get()
        kc_no = kc[0:kc.index('-') - 1]
        from overall_menu import Menu
        if language == 'Dutch':
            m = Menu(int(kc_no), 'nl', self.is_retrieve.get())
        else:
            m = Menu(int(kc_no), 'en', self.is_retrieve.get())
        question, answer, img_dir_list = m.menu()
        if len(question) == 0:
            question = "Sorry we can not generate text question for this KC"
        self.result_data_Text.delete(1.0, 'end')
        self.result_data_Text.insert(END, question)
        self.answer_data_Text.delete(1.0, 'end')
        self.answer_data_Text.insert(END, answer)
        from PIL import Image, ImageTk
        self.image_data_Text.delete(1.0, 'end')
        for img_dir in img_dir_list:
            self.image_data_Text.insert(END, str(img_dir))
            self.image_data_Text.insert(END, '\n')
            # img = Image.open(img_dir)
            # w, h = img.size
            # ws = 500
            # hs = h * ws / w
            # img = img.resize((ws,int(hs)), Image.ANTIALIAS)
            # photo = ImageTk.PhotoImage(img)
            # self.img_label.config(image=photo)
            # self.img_label.grid(row=12, column=0, columnspan=2)

        self.init_window_name.mainloop()
Beispiel #2
0
class AdminWindow(tk.Tk):
    def __init__(self, restart_var, session):

        tk.Tk.__init__(self)
        self.restart_var = restart_var
        self.session = session
        self.window_config = {
            "title": "IGuard Desktop Admin",
            "cam-nav-text": "Cameras",
            "user-nav-text": "Users",
            "filter-btn-text": "Search",
            "filter-reset-btn-text": "Show All",
            "filter-label": 'Select User:'******'#cfebff',
                                     'white',
                                     '#3A79D1',
                                     text=self.window_config['cam-nav-text'],
                                     font="Arial 15",
                                     height=3)
        self.camBtn.bind("<Button-1>", lambda e: self.showCameras())
        self.camBtn.pack(side=tk.LEFT, fill='both', expand=True)

        self.usersBtn = ClickableLabel(
            self.navbar,
            '#cfebff',
            'white',
            '#3A79D1',
            text=self.window_config['user-nav-text'],
            font="Arial 15",
            height=3)
        self.usersBtn.bind("<Button-1>", lambda e: self.showUsers())
        self.usersBtn.pack(side=tk.RIGHT, fill='both', expand=True)

        self.camBtn.click()

        self.protocol("WM_DELETE_WINDOW", self.logOut)

        self.cam_frame = CamerasFrame(self)
        self.cam_frame.pack(side=tk.TOP, fill='both', expand=True)

        self.users_frame = UsersList(
            self,
            bg='#3A79D1',
            list_of_users=self.cam_frame.list_of_users,
            list_of_ids=self.cam_frame.list_of_ids,
            session=self.session)

        self.filter_frame = tk.Frame(self, bg='white')
        self.filter_frame.pack(side=tk.BOTTOM, fill=tk.X)

        tk.Label(self.filter_frame,
                 text=self.window_config['filter-label'],
                 bg='white',
                 font='Arial 11').pack(side=tk.LEFT, fill=tk.Y, pady=10)

        self.filter_user_combobox = AutocompleteCombobox(
            self.filter_frame, completevalues=self.cam_frame.list_of_users)
        self.filter_user_combobox.pack(side=tk.LEFT,
                                       fill=tk.Y,
                                       pady=10,
                                       padx=10)

        self.filter_button = FocusButton(
            self.filter_frame,
            in_color='#325080',
            out_color='#3A79D1',
            text=self.window_config['filter-btn-text'],
            command=self.filterByUser,
            fg='white',
            relief=tk.FLAT)
        self.filter_button.pack(side=tk.LEFT, fill=tk.Y, pady=10, padx=10)

        self.filter_reset_button = FocusButton(
            self.filter_frame,
            in_color='#325080',
            out_color='#3A79D1',
            text=self.window_config['filter-reset-btn-text'],
            command=self.resetFilter,
            fg='white',
            relief=tk.FLAT)
        self.filter_reset_button.pack(side=tk.LEFT,
                                      fill=tk.Y,
                                      pady=10,
                                      padx=10)

    def resetFilter(self):
        if (self.usersBtn.disabled):
            self.users_frame.findAndShowUser("")
        else:
            self.cam_frame.findByUser(None, True)

    def filterByUser(self):
        username = self.filter_user_combobox.get()
        print(username)
        if (self.usersBtn.disabled):
            self.users_frame.findAndShowUser(username)
        else:
            self.cam_frame.findByUser(username)

    def showCameras(self):
        if (self.camBtn.disabled):
            return
        self.camBtn.click()
        self.usersBtn.click()
        self.users_frame.pack_forget()
        self.cam_frame.pack(side=tk.TOP, fill='both', expand=True)

    def showUsers(self):
        if (self.usersBtn.disabled):
            return
        self.usersBtn.click()
        self.camBtn.click()
        self.cam_frame.pack_forget()
        self.users_frame.pack(side=tk.TOP, fill='both', expand=True)

    def logOut(self):
        self.restart_var[0] = True
        del self.session
        self.destroy()
class Interfaz(object):
    """ Programa para la filtración de bases de datos SQL, la personalización a través
    de una interfaz gráfica y la exportación de esos resultados en HTML"""
    def __init__(
            self,
            root):  #Widgets que conformarán la interfaz gráfica del programa.

        self.root = root
        self.root.title("Programa base de datos Anla")
        self.root.iconbitmap(r'icono.ico')
        self.canvas = tk.Canvas(self.root, height=500, width=1000)
        self.canvas.pack()
        self.imagen_fondo = PhotoImage(file='montaña.png')
        self.frame = tk.Frame(self.root, bg=None)  #"#20CDC8"
        self.frame.place(relheight=1, relwidth=1)
        self.imagen_Label = tk.Label(self.frame, image=self.imagen_fondo)
        self.imagen_Label.place(relheight=1, relwidth=1)
        self.autocompletar = AutocompleteCombobox(self.frame,
                                                  completevalues=self.combo())
        self.autocompletar.place(relheight=0.07,
                                 relwidth=0.65,
                                 relx=0.2,
                                 rely=0.08)
        self.boton = tk.Button(self.frame,
                               text="Agregar Componente",
                               relief="flat",
                               fg="#FFDBA9",
                               bg="#578FBE",
                               font=("Helvetica", 10, "bold"),
                               bd=1,
                               command=self.adicionar_componentes)
        self.boton.place(relheight=0.07, relwidth=0.18, relx=0.018, rely=0.08)
        self.style = ttk.Style()
        self.style.configure("Treeview.Heading",
                             font=("Helvetica", 12, "bold"))
        self.style.configure("mystyle.Treeview",
                             highlightthickness=0,
                             bd=0,
                             font=('Helvetica',
                                   11))  # Modify the font of the body
        self.arbol = ttk.Treeview(self.frame,
                                  height=5,
                                  style="mystyle.Treeview")
        self.arbol.place(relheight=0.65, relwidth=0.7, relx=0.15, rely=0.25)
        self.arbol.heading('#0',
                           text='COMPONENTES SELECCIONADOS',
                           anchor=CENTER)
        self.fuente = font.Font(family='Helvetica', size=10, weight='bold')
        self.boton_delete = tk.Button(self.frame,
                                      text="Eliminar componente",
                                      bg="#FFC16B",
                                      fg="#4F3F2A",
                                      relief="flat",
                                      font=("Helvetica", 10, "bold"),
                                      command=self.eliminar_seleccion)
        self.boton_delete.place(relheight=0.07,
                                relwidth=0.15,
                                relx=0.15,
                                rely=0.92)
        self.boton_delete_all = tk.Button(self.frame,
                                          text="Eliminar todo",
                                          relief="flat",
                                          bg="#FF976B",
                                          fg="#4F3F2A",
                                          font=("Helvetica", 10, "bold"),
                                          command=self.eliminar_todo)
        self.boton_delete_all.place(relheight=0.07,
                                    relwidth=0.14,
                                    relx=0.72,
                                    rely=0.92)
        self.mensaje = tk.Label(self.frame,
                                text="",
                                anchor="center",
                                font=self.fuente,
                                bg="#20CDC8")
        self.mensaje.place(relx=0.2, rely=0.15)
        self.boton_prueba = tk.Button(self.frame,
                                      text="Conoce tus requisitos",
                                      relief="flat",
                                      bg="#52C496",
                                      fg="#4F3F2A",
                                      font=("Helvetica", 10, "bold"),
                                      command=self.otra_cosa)
        self.boton_prueba.place(relheight=0.07,
                                relwidth=0.16,
                                relx=0.43,
                                rely=0.92)

    def combo(
        self
    ):  #Formar una lista de los elementos seleccionados en la tabla de la base de datos
        #Función para desplegar los datos en un Autocomplete Combobox
        conn = sqlite3.connect("anla.db")
        c = conn.cursor()
        lista_nueva = c.execute(
            "SELECT DISTINCT COMPONENTE FROM diccionario_nuevo WHERE CÓDIGO != 'T' ORDER BY COMPONENTE"
        )
        vacio = []
        for componente in lista_nueva:
            vacio.append(componente[0])
        return vacio

    def adicionar_componentes(
            self
    ):  #Función que despliega los elementos seleccionados del Combobox
        #La información es desplegada en un Treeview widget

        add = self.autocompletar.get()
        if add not in self.combo():
            self.mensaje = tk.Label(self.frame,
                                    text="",
                                    anchor="center",
                                    font=self.fuente,
                                    bg="#20CDC8")
            self.mensaje["text"] = "{} no es un componente".format(add)
            self.mensaje.place(relx=0.2, rely=0.15)
            return self.mensaje
        else:
            return self.arbol.insert('', tk.END, text=add,
                                     value=""), self.mensaje.destroy()

    def eliminar_seleccion(
            self):  #Función para el botón de eliminar la selección una por una
        selected_item = self.arbol.selection()

        try:
            self.arbol.delete(selected_item)
            self.mensaje_seleccion.destroy()
        except:
            self.mensaje_seleccion = tk.Label(self.frame,
                                              text="Seleccione un componente",
                                              font=self.fuente,
                                              bg="#20CDC8")
            self.mensaje_seleccion.place(relx=0.8, rely=0.17)

    def eliminar_todo(
        self
    ):  #Botón para eliminar todas las selecciones presentes en el Treeview
        for componente in self.arbol.get_children():
            eliminar = self.arbol.delete(componente)
        return eliminar

    def otra_cosa(
        self
    ):  #Crea una ventana en donde se desplegarán los resultados de la selección hecha

        self.otra_ventana = Toplevel()
        self.otra_ventana.title("Resultados")
        self.otra_ventana.iconbitmap(r'icono.ico')
        self.otro_canvas = Canvas(self.otra_ventana, height=600, width=1000)
        self.otro_canvas.pack()
        self.imagen_otro = PhotoImage(file='rosa.png')
        self.imagen_Label_otro = tk.Label(self.otra_ventana,
                                          image=self.imagen_otro)
        self.imagen_Label_otro.place(relheight=1, relwidth=1)
        self.arbol_otro = ttk.Treeview(self.otra_ventana,
                                       height=20,
                                       column=("column1", "column2",
                                               "column3"),
                                       show='headings')
        self.arbol_otro.column("#0", width=500, stretch=0, anchor="w")
        self.arbol_otro.place(relheight=0.65,
                              relwidth=0.7,
                              relx=0.15,
                              rely=0.25)

        self.arbol_otro.heading("column1", text="Capas geográficas")
        self.arbol_otro.heading("column2", text="Tipo de información")
        self.arbol_otro.heading("column3", text="Geometría")
        self.boton_exportar = tk.Button(self.otra_ventana,
                                        text="Exportar",
                                        command=self.exportar)
        self.boton_exportar.place(relheight=0.07,
                                  relwidth=0.15,
                                  relx=0.15,
                                  rely=0.92)

        conn = sqlite3.connect("anla.db")
        c = conn.cursor()

        for componente in self.arbol.get_children(
        ):  #Filtra la información de la tabla, de acuerdo a la selección hecha.
            c_individual = self.arbol.item(componente)["text"]
            insert = self.arbol_otro.insert("", tk.END, values=c_individual)

            if c_individual == "ANALISIS_RIESGO":
                anali_riesgo = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'ANALISIS_RIESGO' "
                )
                for i in anali_riesgo.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "AREAS_CONSER_PROTEC_AMBIENTAL":
                area_conservacion = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'AREAS_CONSER_PROTEC_AMBIENTAL'"
                )
                for i in area_conservacion.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "AREAS_REGLAMENTACION_ESPECIAL":
                areas_reglamentacion = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'AREAS_REGLAMENTACION_ESPECIAL'"
                )
                for i in areas_reglamentacion.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "ARQUEOLOGIA":
                arqueologia = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'ARQUEOLOGIA'"
                )
                for i in arqueologia.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "ATMOSFERA":
                atmosfera = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'ATMOSFERA' OR Medio = 'ATMOSFERA'"
                )
                for i in atmosfera.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "BIOTICO_CONTI_COSTE":
                biotico = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'BIOTICO_CONTI_COSTE' or Medio = 'BIOTICO_CONTI_COSTE'"
                )
                for i in biotico.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "CLIMA":
                clima = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'CLIMA' or Medio = 'CLIMA'"
                )
                for i in clima.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "COMPENSACION":
                compensacion = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'COMPENSACION' OR Medio = 'COMPENSACION'"
                )
                for i in compensacion.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "CONTINGENCIAS":
                contingencias = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'CONTINGENCIAS' OR Medio = 'CONTINGENCIAS'"
                )
                for i in contingencias.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "ECONOMICO":
                economico = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'ECONOMICO'"
                )
                for i in economico.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "GEOLOGIA":
                geologia = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'GEOLOGIA' OR Medio = 'GEOLOGIA'"
                )
                for i in geologia.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "GEOMORFOLOGIA":
                geomorfologia = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'GEOMORFOLOGIA'"
                )
                for i in geomorfologia.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "GEOTECNIA":
                geotecnia = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'GEOTECNIA'"
                )
                for i in geotecnia.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "GESTION_RIESGO":
                gestion_riesgo = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'GESTION_RIESGO'"
                )
                for i in gestion_riesgo.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "HIDROGEOLOGIA":
                hidrogeologia = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'HIDROGEOLOGIA' OR Medio = 'HIDROGEOLOGIA'"
                )
                for i in hidrogeologia.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "HIDROLOGIA":
                hidrologia = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'HIDROLOGIA' OR Medio = 'HIDROLOGIA'"
                )
                for i in hidrologia.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "INVERSION_1_POR_CIENTO":
                inversion1 = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'INVERSION_1_POR_CIENTO' OR Medio = 'INVERSION_1_POR_CIENTO'"
                )
                for i in inversion1.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "MARINO":
                marino = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'MARINO' OR Medio = 'MARINO'"
                )
                for i in marino.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "PAISAJE":
                paisaje = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'PAISAJE'"
                )
                for i in paisaje.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "POLITICO_ADMINISTRATIVO ":
                politico = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'POLITICO_ADMINISTRATIVO ' OR Medio = 'POLITICO_ADMINISTRATIVO'"
                )
                for i in politico.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "PROYECTO":
                proyecto = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'PROYECTO' OR Medio = 'PROYECTO'"
                )
                for i in proyecto.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "SOCIOCULTURAL":
                sociocultural = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'SOCIOCULTURAL'"
                )
                for i in sociocultural.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "SUELOS":
                suelos = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'SUELOS' OR Medio = 'SUELOS'"
                )
                for i in suelos.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            elif c_individual == "ZONIFICACION":
                zonificacion = c.execute(
                    "SELECT DISTINCT CAPAS, CÓDIGO, GEOMETRÍA FROM diccionario_nuevo WHERE COMPONENTE = 'ZONIFICACION'"
                )
                for i in zonificacion.fetchall():
                    insert_2 = self.arbol_otro.insert(insert,
                                                      tk.END,
                                                      values=(i[0], i[1],
                                                              i[2]),
                                                      open=True)
                insert_2

            else:
                pass

    def export_pdf(self):  #Extrae la información del Treeview en un Dataframe
        vacio = []

        valores = self.arbol_otro.get_children()
        for individuos in valores:
            c_individual = self.arbol_otro.item(individuos)["values"]
            vacio.append(c_individual)
            for child in self.arbol_otro.get_children(individuos):
                data = self.arbol_otro.item(child)["values"]
                vacio.append(data)

        df = pd.DataFrame(
            vacio,
            columns=["Capas geográficas", "Tipo de información", "Geometria"])
        mask = df.applymap(lambda x: x is None)
        cols = df.columns[(mask).any()]
        for col in df[cols]:
            df.loc[mask[col], col] = ''

        return df

    def boton_pdf(self):  #Devuelve la información como una tabla HTML

        df_2 = self.export_pdf()

        tabla = df_2.to_html("Resultados.html", justify="center", index=False)
        return tabla

    def exportar(self):  #Exporta la selección
        return self.boton_pdf()
Beispiel #4
0
class Interfaz(object):
    def __init__(self, root):
        
        self.root = root
        self.root.title("Programa base de datos Anla")
        self.canvas = tk.Canvas(self.root, height = 400, width =700)
        self.canvas.pack()
        self.imagen_fondo = PhotoImage(file='fondo.png')
        self.frame = tk.Frame(self.root, bg = None ) #"#20CDC8"
        self.frame.place(relheight = 1, relwidth= 1)
        self.imagen_Label = tk.Label(self.frame, image= self.imagen_fondo)
        self.imagen_Label.place(relheight = 1, relwidth= 1)
        #self.desplegable = ttk.Combobox(self.frame, height = 10, textvariable = StringVar, values = self.combo())
        #self.desplegable.place(relheight = 0.05, relwidth = 0.65, relx = 0.2, rely = 0.08)
        self.autocompletar = AutocompleteCombobox(self.frame, completevalues = self.combo())
        self.autocompletar.place(relheight = 0.05, relwidth = 0.65, relx = 0.2, rely = 0.08)
        self.boton = tk.Button(self.frame, text = "Agregar Componente", bg = "#4CE37C", bd = 0.5, command = self.adicionar_componentes)
        self.boton.place(relheight = 0.07, relwidth = 0.18, relx = 0.018, rely = 0.08)
        #self.new_frame = tk.Frame(self.frame, bd = 2, bg = "white")
        #self.new_frame.place(relheight = 0.65, relwidth = 0.7, relx = 0.15, rely = 0.3)
        
        self.style = ttk.Style()
        self.style.configure("Treeview.Heading", font=("Helvetica", 12, "bold"))
        
        self.arbol = ttk.Treeview(self.frame, height = 5)
        self.arbol.place(relheight = 0.65, relwidth = 0.7, relx = 0.15, rely = 0.25)
        self.arbol.heading('#0', text = 'COMPONENTES SELECCIONADOS', anchor = CENTER)
        
        self.fuente = font.Font(family='Helvetica', size=10, weight='bold')
        
        self.boton_delete = tk.Button(self.frame, text = "Eliminar componente", command = self.eliminar_seleccion)
        self.boton_delete.place(relheight = 0.07, relwidth = 0.18)
        
        self.boton_delete_all = tk.Button(self.frame, text = "Eliminar todo", command = self.eliminar_todo)
        self.boton_delete_all.place(relheight = 0.07, relwidth = 0.18, relx = 0.5, rely = 0.5)
        self.mensaje = tk.Label(self.frame, text = "", anchor = "center", font = self.fuente, bg = "#20CDC8" )
        self.mensaje.place(relx = 0.2, rely = 0.15)
        
    
    def combo(self):
        conn = sqlite3.connect("anla.db")
        c = conn.cursor()
        lista_nueva = c.execute("SELECT DISTINCT COMPONENTE FROM diccionario_nuevo WHERE CÓDIGO != 'T' ORDER BY COMPONENTE")
        vacio = []
        for componente in lista_nueva:
            vacio.append(componente[0])
        return vacio
    
    def adicionar_componentes(self):
        add = self.autocompletar.get()
        if add not in self.combo():
            self.mensaje = tk.Label(self.frame, text = "", anchor = "center", font = self.fuente, bg = "#20CDC8" )
            self.mensaje["text"] = "{} no es un componente".format(add)
            self.mensaje.place(relx = 0.2, rely = 0.15)
            return self.mensaje
        else:
            return self.arbol.insert('', 0, text = add, value = ""), self.mensaje.destroy()
    
    def eliminar_seleccion(self):
        selected_item = self.arbol.selection() 
        
        try:
            self.arbol.delete(selected_item)
            self.mensaje_seleccion.destroy()
        except:
            self.mensaje_seleccion = tk.Label(self.frame, text = "Seleccione un componente", font = self.fuente)
            self.mensaje_seleccion.place(relx = 0.8, rely = 0.9, anchor = "se")
            
            
    def eliminar_todo(self):
        for componente in self.arbol.get_children():
            eliminar = self.arbol.delete(componente)
        return eliminar
    
     def otra_cosa(self):
        
        self.otra_ventana = Toplevel()
        self.otra_ventana.title("Resultados")
        self.otro_canvas = Canvas(self.otra_ventana, height = 400, width =700)
        self.otro_canvas.pack()
        self.imagen_otro = PhotoImage(file='cielo.png')
        self.imagen_Label_otro = tk.Label(self.otra_ventana, image= self.imagen_otro)
        self.imagen_Label_otro.place(relheight = 1, relwidth= 1)

        conn = sqlite3.connect("anla.db")
        c = conn.cursor()
        
        for componente in self.arbol.get_children():
            c_individual = self.arbol.item(componente)["text"]
            
            if c_individual == "ANALISIS_RIESGO":
                anali_riesgo = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'ANALISIS_RIESGO' ")
                print(anali_riesgo)
            
            elif c_individual == "AREAS_CONSER_PROTEC_AMBIENTAL":
                area_conservacion = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'AREAS_CONSER_PROTEC_AMBIENTAL'")
                print(area_conservacion)
            
            elif c_individual == "AREAS_REGLAMENTACION_ESPECIAL":
                areas_reglamentacion = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'AREAS_REGLAMENTACION_ESPECIAL'")
                print(areas_reglamentacion)
            
            elif c_individual == "ARQUEOLOGIA":
                arqueologia = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'ARQUEOLOGIA'")
                print(arqueologia)
            
            elif c_individual == "ATMOSFERA":
                atmosfera = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'ATMOSFERA' OR Medio = 'ATMOSFERA'")
                print(atmosfera)
                
            elif c_individual == "BIOTICO_CONTI_COSTE":
                biotico = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'BIOTICO_CONTI_COSTE' or Medio = 'BIOTICO_CONTI_COSTE'")
                print(biotico)
                
            elif c_individual == "CLIMA":
                clima = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'CLIMA' or Medio = 'CLIMA'")
                print(clima)
                
            elif c_individual == "COMPENSACION":
                compensacion = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'COMPENSACION' OR Medio = 'COMPENSACION'")
                print(compensacion)
            
            elif c_individual == "CONTINGENCIAS":
                contingencias = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'CONTINGENCIAS' OR Medio = 'CONTINGENCIAS'")
                print(contingencias)
            
            elif c_individual == "ECONOMICO":
                economico = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'ECONOMICO'")
                print(economico)
            
            elif c_individual == "GEOLOGIA":
                geologia = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'GEOLOGIA' OR Medio = 'GEOLOGIA'")
                print(geologia)
                
            elif c_individual == "GEOMORFOLOGIA":
                geomorfologia = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'GEOMORFOLOGIA'")
                print(geomorfologia)
            
            elif c_individual == "GEOTECNIA":
                geotecnia = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'GEOTECNIA'")
                print(geotecnia)
                
            elif c_individual == "GESTION_RIESGO":
                gestion_riesgo = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'GESTION_RIESGO'")
                print(gestion_riesgo)
            
            elif c_individual == "HIDROGEOLOGIA":
                hidrogeologia = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'HIDROGEOLOGIA' OR Medio = 'HIDROGEOLOGIA'")
                print(hidrogeologia)
            
            elif c_individual == "HIDROLOGIA":
                hidrologia = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'HIDROLOGIA' OR Medio = 'HIDROLOGIA'")
                print(hidrologia)
            
            elif c_individual == "INVERSION_1_POR_CIENTO":
                inversion1 = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'INVERSION_1_POR_CIENTO' OR Medio = 'INVERSION_1_POR_CIENTO'")
                print(inversion1)
            
            elif c_individual == "MARINO":
                marino = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'MARINO' OR Medio = 'MARINO'")
                print(marino)
            
            elif c_individual == "PAISAJE":
                paisaje = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'PAISAJE'")
            
            elif c_individual == "POLITICO_ADMINISTRATIVO":
                politico = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'POLITICO_ADMINISTRATIVO' Medio = 'POLITICO_ADMINISTRATIVO'")
                print(politico)
            
            elif c_individual == "PROYECTO":
                proyecto = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'PROYECTO' OR Medio = 'PROYECTO'")
                print(proyecto)
            
            elif c_individual == "SOCIOCULTURAL":
                sociocultural = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'SOCIOCULTURAL'")
                print(sociocultural)
            
            elif c_individual == "SUELOS":
                suelos = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'SUELOS' OR Medio = 'SUELOS'")
                print(suelos)
            
            elif c_individual == "ZONIFICACION":
                zonificacion = c.execute("SELECT DISTINCT CAPAS, CÓDIGO FROM diccionario_nuevo WHERE COMPONENTE = 'ZONIFICACION'")
                print(zonificacion)
            
            else:
                pass
Beispiel #5
0
class IsogeoSearchForm(ttk.Frame):
    def __init__(self, master=None, async_loop=None):
        tk.Frame.__init__(self, master)
        self.async_loop = async_loop

        # basics
        # master.resizable(width=True, height=True)
        master.title(
            "Isogeo Python SDK v{} - Sample desktop search form".format(pysdk_version)
        )
        master.focus_force()
        self.grid(sticky="NSWE")
        self.grid_propagate(1)

        # styling
        self.style = ttk.Style(self)

        self.s1 = tk.PhotoImage(
            master=self, name="search1", data=data, format="gif -index 0"
        )
        self.s2 = tk.PhotoImage(
            master=self, name="search2", data=data, format="gif -index 1"
        )

        self.style.element_create(
            "Search.field",
            "image",
            "search1",
            ("focus", "search2"),
            border=[22, 7, 14],
            sticky="ew",
        )

        self.style.layout(
            "Search.entry",
            [
                (
                    "Search.field",
                    {
                        "sticky": "nswe",
                        "border": 1,
                        "children": [
                            (
                                "Entry.padding",
                                {
                                    "sticky": "nswe",
                                    "children": [
                                        ("Entry.textarea", {"sticky": "nswe"})
                                    ],
                                },
                            )
                        ],
                    },
                )
            ],
        )
        self.style.configure("Search.entry")

        # frames
        fr_global = ttk.Frame(self, name="global")
        fr_search = ttk.Frame(self, name="search_form")

        # UI vars
        self.app_name = StringVar(fr_global, "Sample desktop form")
        self.app_total = StringVar(fr_global, "0")
        self.app_url = StringVar(fr_global, "http://isogeo-api-pysdk.readthedocs.io")
        self.app_results = StringVar(fr_search, "0")

        # -- WIDGETS CREATION -------------------------------------------------
        # add widgets
        lbl_app_name = tk.Label(fr_global, textvariable=self.app_name)
        lbl_app_total = ttk.Label(fr_global, textvariable=self.app_total)
        btn_app_url = ttk.Button(
            fr_global,
            text="APP Website",
            command=lambda: self.worker_allocator(
                async_loop=self.async_loop, to_do="open_web", **{"url": self.app_url}
            ),
        )

        lbl_actions = ttk.Label(fr_search, text="Linked action")
        lbl_contacts = ttk.Label(fr_search, text="Contact")
        lbl_formats = ttk.Label(fr_search, text="Source format")
        lbl_inspires = ttk.Label(fr_search, text="INSPIRE theme")
        lbl_keywords = ttk.Label(fr_search, text="Keyword")
        lbl_licenses = ttk.Label(fr_search, text="License")
        lbl_owners = ttk.Label(fr_search, text="Owner")
        lbl_shares = ttk.Label(fr_search, text="Share")
        lbl_srs = ttk.Label(fr_search, text="Source spatial reference system")
        lbl_types = ttk.Label(fr_search, text="Type")

        # add form widgets
        self.ent_search = AutocompleteEntry(
            fr_search, style="Search.entry", width=20, completevalues=list()
        )

        self.cb_actions = AutocompleteCombobox(fr_search)
        self.cb_contacts = AutocompleteCombobox(fr_search)
        self.cb_formats = AutocompleteCombobox(fr_search)
        self.cb_inspires = AutocompleteCombobox(fr_search)
        self.cb_keywords = AutocompleteCombobox(fr_search)
        self.cb_licenses = AutocompleteCombobox(fr_search)
        self.cb_owners = AutocompleteCombobox(fr_search)
        self.cb_shares = AutocompleteCombobox(fr_search)
        self.cb_srs = AutocompleteCombobox(fr_search)
        self.cb_types = AutocompleteCombobox(fr_search)

        lbl_results = ttk.Label(fr_search, textvariable=self.app_results)

        btn_reset = ttk.Button(
            master,
            text="Reset",
            command=lambda: self.worker_allocator(
                async_loop=self.async_loop, to_do="form_clear", **{"clear": 1}
            ),
        )
        btn_close = ttk.Button(master, text="Close", command=master.destroy)

        # after UI build
        self.worker_allocator(
            async_loop=self.async_loop, to_do="form_clear", **{"clear": 1}
        )

        # -- WIDGETS PLACEMENT ------------------------------------------------
        d_pad = {"padx": 5, "pady": 5, "sticky": "NSEW"}

        lbl_app_name.grid(row=0, column=0, **d_pad)
        btn_app_url.grid(row=1, column=0, **d_pad)
        lbl_app_total.grid(row=2, column=0, **d_pad)

        self.ent_search.grid(row=1, columnspan=3, **d_pad)

        self.cb_actions.grid(row=3, column=0, **d_pad)
        self.cb_contacts.grid(row=3, column=1, **d_pad)
        self.cb_formats.grid(row=3, column=2, **d_pad)
        self.cb_inspires.grid(row=5, column=0, **d_pad)
        self.cb_keywords.grid(row=5, column=1, **d_pad)
        self.cb_licenses.grid(row=5, column=2, **d_pad)
        self.cb_owners.grid(row=7, column=0, **d_pad)
        self.cb_shares.grid(row=7, column=1, **d_pad)
        self.cb_srs.grid(row=7, column=2, **d_pad)
        self.cb_types.grid(row=9, column=1, **d_pad)

        lbl_actions.grid(row=2, column=0, **d_pad)
        lbl_contacts.grid(row=2, column=1, **d_pad)
        lbl_formats.grid(row=2, column=2, **d_pad)
        lbl_inspires.grid(row=4, column=0, **d_pad)
        lbl_keywords.grid(row=4, column=1, **d_pad)
        lbl_licenses.grid(row=4, column=2, **d_pad)
        lbl_owners.grid(row=6, column=0, **d_pad)
        lbl_shares.grid(row=6, column=1, **d_pad)
        lbl_srs.grid(row=6, column=2, **d_pad)
        lbl_types.grid(row=8, column=1, **d_pad)

        lbl_results.grid(row=22, column=0, columnspan=2, **d_pad)

        fr_global.grid(row=0, columnspan=1, **d_pad)
        fr_search.grid(row=1, columnspan=1, **d_pad)

        btn_reset.grid(row=2, column=0, sticky="NSW", padx=5, pady=5)
        btn_close.grid(row=2, column=0, sticky="NSE", padx=5, pady=5)

        # connecting comboboxes event
        self.cb_actions.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_contacts.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_formats.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_inspires.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_keywords.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_licenses.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_owners.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_shares.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_srs.bind("<<ComboboxSelected>>", self.cbs_manager)
        self.cb_types.bind("<<ComboboxSelected>>", self.cbs_manager)

    # -- TASKS HUB ------------------------------------------------------------
    def cbs_manager(self, event):
        self.worker_allocator(
            async_loop=self.async_loop, to_do="form_update", **{"clear": 0}
        )

    def worker_allocator(self, async_loop, to_do, **kwargs):
        """ Handler starting the asyncio part. """
        d = kwargs
        threading.Thread(
            target=self._asyncio_thread, args=(async_loop, to_do, d)
        ).start()

    def _asyncio_thread(self, async_loop, to_do, kwargus):
        if to_do == "form_clear":
            async_loop.run_until_complete(self.fill_form(clear=1))
        elif to_do == "form_update":
            async_loop.run_until_complete(self.fill_form(clear=0))
        elif to_do == "open_web":
            async_loop.run_until_complete(self.open_url(kwargus.get("url").get()))
        else:
            pass

    # -- ASYNC METHODS --------------------------------------------------------
    async def open_url(self, url):
        open_new_tab(url)

    async def fill_form(self, clear=0):
        if not hasattr(self, "isogeo"):
            self._init_isogeo()
        else:
            logging.info("App is already connected to Isogeo API")
            pass

        # search
        if clear:
            # clear
            self.ent_search.delete(0, "end")
            self.cb_actions.set("")
            self.cb_contacts.set("")
            self.cb_formats.set("")
            self.cb_inspires.set("")
            self.cb_keywords.set("")
            self.cb_licenses.set("")
            self.cb_owners.set("")
            self.cb_shares.set("")
            self.cb_srs.set("")
            self.cb_types.set("")
            # new search
            search = self.isogeo.search(
                self.token, page_size=0, whole_share=0, augment=1, tags_as_dicts=1
            )
            app_total = results_total = search.get("total")
            self.app_total.set("Total: {} metadata".format(app_total))
        else:
            query = self.ent_search.get() + " "
            query += self.tags.get("actions").get(self.cb_actions.get(), "") + " "
            query += self.tags.get("contacts").get(self.cb_contacts.get(), "") + " "
            query += self.tags.get("formats").get(self.cb_formats.get(), "") + " "
            query += self.tags.get("inspires").get(self.cb_inspires.get(), "") + " "
            query += self.tags.get("keywords").get(self.cb_keywords.get(), "") + " "
            query += self.tags.get("licenses").get(self.cb_licenses.get(), "") + " "
            query += self.tags.get("owners").get(self.cb_owners.get(), "") + " "
            query += self.tags.get("shares").get(self.cb_shares.get(), "") + " "
            query += self.tags.get("srs").get(self.cb_srs.get(), "") + " "
            query += self.tags.get("types").get(self.cb_types.get(), "") + " "
            search = self.isogeo.search(
                self.token,
                page_size=0,
                whole_share=0,
                augment=1,
                tags_as_dicts=1,
                query=query,
            )
            results_total = search.get("total")
            logging.debug(search.get("query"))
        self.tags = search.get("tags")

        # set values
        self.app_results.set("Results count: {} metadata".format(results_total))
        self.ent_search.set_completion_list(list(self.tags.get("keywords").values()))
        self.cb_actions.set_completion_list(list(self.tags.get("actions")))
        self.cb_contacts.set_completion_list(list(self.tags.get("contacts")))
        self.cb_formats.set_completion_list(list(self.tags.get("formats")))
        self.cb_inspires.set_completion_list(list(self.tags.get("inspires")))
        self.cb_keywords.set_completion_list(list(self.tags.get("keywords")))
        self.cb_licenses.set_completion_list(list(self.tags.get("licenses")))
        self.cb_owners.set_completion_list(list(self.tags.get("owners")))
        self.cb_shares.set_completion_list(list(self.tags.get("shares")))
        self.cb_srs.set_completion_list(list(self.tags.get("srs")))
        self.cb_types.set_completion_list(list(self.tags.get("types")))

    def _init_isogeo(self):
        api_credentials = utils.credentials_loader("client_secrets.json")
        self.isogeo = Isogeo(
            client_id=api_credentials.get("client_id"),
            client_secret=api_credentials.get("client_secret"),
        )
        self.token = self.isogeo.connect()
        # app properties
        self.isogeo.get_app_properties(self.token)
        self.app_props = self.isogeo.app_properties
        self.app_name.set(
            "Authenticated application: {}".format(self.app_props.get("name"))
        )
        self.app_url.set(self.app_props.get("url", "https://www.isogeo.com"))