Carga de fichero en GUI hecha

parent cbfff972
......@@ -7,14 +7,15 @@ from Filtros import eliminarComportamientoAutomatico
from AnalisisTMedioPagina import analisisTiempoMedioPorPagina
from AnalisisPaginasVisitadas import getEstadisticasPaginasVisitadas
RUTA_ARCHIVO = "../access_log_Aug95_reducido"
RUTA_ARCHIVO = ""#"../access_log_Aug95_reducido"
E_SPIDERING = True
EXTENSIONES_ADMITIDAS = []
EXTENSIONES_NOADMITIDAS = []
UMBRAL_SESIONES = 1800
FACTOR_UMBRAL = 0.5
REG=[]
'''
def printRegistro(registros):
print("RESULTADOS: ")
informe = (
......@@ -67,7 +68,7 @@ r = obtenerRegistros(RUTA_ARCHIVO, E_SPIDERING, EXTENSIONES_ADMITIDAS, EXTENSION
num_reg = len(r)
# printRegistro(r)
'''
# Se obtienen los directorios con contadores y la cesta
umbral = int(num_reg * FACTOR_UMBRAL / 100)
d, cont, ses = obtenerDirectorios(r, umbral)
......
from tkinter import filedialog
from tkinter import*
from tkinter import ttk
from tkinter import messagebox
from Gui_Utils import rellenarTablaRegistros
from ObtencionRegistro import obtenerRegistros
from Dato import Dato
from Gestor import *
r = obtenerRegistros(RUTA_ARCHIVO, E_SPIDERING, EXTENSIONES_ADMITIDAS, EXTENSIONES_NOADMITIDAS, UMBRAL_SESIONES)
#r = obtenerRegistros(RUTA_ARCHIVO, E_SPIDERING, EXTENSIONES_ADMITIDAS, EXTENSIONES_NOADMITIDAS, UMBRAL_SESIONES)
def f_abrir():
global RUTA_ARCHIVO
RUTA_ARCHIVO = filedialog.askopenfilename(initialdir="/", title="Seleccione fichero",
filetypes=(
("all files", "*.*"), ("txt files", "*.txt"), ("log files", "*.log")))
global REG
REG = obtenerRegistros(RUTA_ARCHIVO, E_SPIDERING, EXTENSIONES_ADMITIDAS, EXTENSIONES_NOADMITIDAS,
UMBRAL_SESIONES)
insertaRegistros()
def f_salir():
quit()
def barraMenu(ventana):
# DEFINIR BARRA DE MENÚ DE LA APLICACION:
barramenu = Menu(ventana)
ventana['menu'] = barramenu
menu1 = Menu(barramenu)
barramenu.add_cascade(menu=menu1, label='Fichero')
# Boton Abrir
menu1.add_command(label='Abrir...',
command=f_abrir,
underline=0, compound=RIGHT)
menu1.add_separator() # Agrega un separador
# Boton Salir
menu1.add_command(label='Salir', command=f_salir,
underline=0, compound=RIGHT)
menu2 = Menu(barramenu)
barramenu.add_cascade(menu=menu2, label='Analisis')
menu3 = Menu(barramenu)
barramenu.add_cascade(menu=menu3, label='Ayuda')
def getDatosRegistro(registro, atributos):
ret = []
for a in atributos:
ret.append(getattr(registro, a))
aux = []
for i in range(1, len(ret)):
aux.append(ret[i])
aux.append(ret[0])
return aux
def insertaRegistros():
global REG
for r in REG:
tabla.insert("", END, values=getDatosRegistro(r, atributos))
#Creo la ventana
......@@ -29,17 +80,22 @@ tabla.config(show='headings')
tabla.grid(row=0, column=0,sticky='ns')
c=0
ventana.update()
x=ventana.winfo_width()
ancho=ventana.winfo_width()
for i in nombresAtributos:
tabla.heading('#' + str(c) + '', text=i)
tabla.column('#' + str(c) + '', width=(x//len(nombresAtributos)), anchor=CENTER)
tabla.column('#' + str(c) + '', width=(ancho//len(nombresAtributos)), anchor=CENTER)
c+=1
tabla.heading('#' + str(c) + '', text=nombresAtributos[0])
rellenarTablaRegistros(r,tabla,nombresAtributos)
#Scrollbar
vsb = ttk.Scrollbar(ventana, orient="vertical", command=tabla.yview)
vsb.place(x=ancho-15, y=25, height=ventana.winfo_height()-35)
tabla.configure(yscrollcommand=vsb.set)
barraMenu(ventana)
......
from tkinter import *
def getDatosRegistro(registro,atributos):
ret=[]
for a in atributos:
ret.append(getattr(registro,a))
aux=[]
for i in range(1,len(ret)):
aux.append(ret[i])
aux.append(ret[0])
return aux
def rellenarTablaRegistros(registros, tabla,atributos):
index = iid = 0
for r in registros:
tabla.insert("", END, values=getDatosRegistro(r,atributos))
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment