Apertura parametrizada del fichero mediante GUI

parent 1ad000ff
UMBRAL_T=1#<<Parametrizar esto UMBRAL_T=1#<<Parametrizar esto
def getFormatosFromCSV(cad):
if cad != "" and cad[len(cad)-1]!=';':
cad=cad+';'
ret=[]
c=0
aux=""
while c < len(cad):
if cad[c] == ';':
if aux[0]!='.':
aux='.'+aux
ret.append(aux)
aux=""
else:
aux+=cad[c]
c+=1
return ret
def ordenarPorSesion(registros): def ordenarPorSesion(registros):
for i in range(len(registros)): for i in range(len(registros)):
for j in range(len(registros)): for j in range(len(registros)):
......
from tkinter import filedialog from tkinter import filedialog
from tkinter import* from tkinter import *
from tkinter import ttk from tkinter import ttk
from tkinter import messagebox from tkinter import messagebox
from ObtencionRegistro import obtenerRegistros from ObtencionRegistro import obtenerRegistros
from Dato import Dato from Dato import Dato
from Filtros import getFormatosFromCSV
from VentanaAbrir import VentanaAbrir
from Gestor import * 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)
...@@ -13,9 +15,25 @@ def f_abrir(): ...@@ -13,9 +15,25 @@ def f_abrir():
RUTA_ARCHIVO = filedialog.askopenfilename(initialdir="/", title="Seleccione fichero", RUTA_ARCHIVO = filedialog.askopenfilename(initialdir="/", title="Seleccione fichero",
filetypes=( filetypes=(
("all files", "*.*"), ("txt files", "*.txt"), ("log files", "*.log"))) ("all files", "*.*"), ("txt files", "*.txt"), ("log files", "*.log")))
v=VentanaAbrir()
global EXTENSIONES_ADMITIDAS
EXTENSIONES_ADMITIDAS= getFormatosFromCSV(v.formadmin.get())
global EXTENSIONES_NOADMITIDAS
EXTENSIONES_NOADMITIDAS = getFormatosFromCSV(v.formnoadmin.get())
global E_SPIDERING
E_SPIDERING=v.es==1
global UMBRAL_SESIONES
try:
UMBRAL_SESIONES=int(float(v.umb.get()))
except:
UMBRAL_SESIONES = 1800
v.cerrarVentana()
global REG global REG
REG = obtenerRegistros(RUTA_ARCHIVO, E_SPIDERING, EXTENSIONES_ADMITIDAS, EXTENSIONES_NOADMITIDAS, REG = obtenerRegistros(RUTA_ARCHIVO, E_SPIDERING, EXTENSIONES_ADMITIDAS, EXTENSIONES_NOADMITIDAS,
UMBRAL_SESIONES) UMBRAL_SESIONES)
insertaRegistros() insertaRegistros()
...@@ -41,6 +59,15 @@ def barraMenu(ventana): ...@@ -41,6 +59,15 @@ def barraMenu(ventana):
menu2 = Menu(barramenu) menu2 = Menu(barramenu)
barramenu.add_cascade(menu=menu2, label='Analisis') barramenu.add_cascade(menu=menu2, label='Analisis')
# Boton Abrir
'''menu2.add_command(label='Abrir...',
command=f_abrir,
underline=0, compound=RIGHT)
menu2.add_separator() # Agrega un separador
# Boton Salir
menu2.add_command(label='Salir', command=f_salir,
underline=0, compound=RIGHT)'''
menu3 = Menu(barramenu) menu3 = Menu(barramenu)
barramenu.add_cascade(menu=menu3, label='Ayuda') barramenu.add_cascade(menu=menu3, label='Ayuda')
...@@ -56,6 +83,7 @@ def getDatosRegistro(registro, atributos): ...@@ -56,6 +83,7 @@ def getDatosRegistro(registro, atributos):
return aux return aux
def insertaRegistros(): def insertaRegistros():
tabla.delete(*tabla.get_children())
global REG global REG
for r in REG: for r in REG:
tabla.insert("", END, values=getDatosRegistro(r, atributos)) tabla.insert("", END, values=getDatosRegistro(r, atributos))
......
import tkinter as ttk
from tkinter import *
class VentanaAbrir:
def __init__(self):
self.es=IntVar()
self.app = Tk()
self.app.geometry('450x200')
checkb = ttk.Checkbutton(self.app, text="eSpidering",variable=self.es,onvalue=1,offvalue=0)
checkb.place(x=40, y=30)
self.lb1 = ttk.Label(self.app, text="Formatos admitidos (separar con ;):")
self.lb1.place(x=40, y=60)
self.formadmin = ttk.Entry(self.app)
self.formadmin.place(x=300, y=60)
self.lb2 = ttk.Label(self.app, text="Formatos no admitidos (separar con ;):")
self.lb2.place(x=40, y=90)
self.umb = ttk.Entry(self.app)
self.umb.place(x=150, y=120)
self.lb3 = ttk.Label(self.app, text="Umbral sesiones:")
self.lb3.place(x=40, y=120)
self.formnoadmin = ttk.Entry(self.app, text="Formatos no admitidos (separar con ;)")
self.formnoadmin.place(x=300, y=90)
self.boton = ttk.Button(self.app, text="Aceptar", command=self.app.quit)
self.boton.place(x=150, y=160)
self.app.mainloop()
print("destruido...")
def cerrarVentana(self):
self.app.destroy()
\ No newline at end of file
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