import tkinter as tk from tkinter import * from tkinter import filedialog import tkinter.font as tkFont import fnmatch import os import ntpath from pathlib import Path from pathlib import PureWindowsPath filename = '' ###### SETUP DE LA FENETRE DU LOGICIEL ###### GUI = Tk() GUI.title('SYMMETRA MW LOG ANALYZER v1.0 - PRIVAS FACTORY SUPPORT ENGINEERING') GUI.geometry('1200x800') GUI.configure(background = '#0BBB10') GUI.maxsize(1200,800) GUI.minsize(1200,800) ###### MENU (NON UTILISE)###### menu1 = Menu(GUI) menu1.add_cascade(label="Files") menu1.add_cascade(label="Options") menu1.add_cascade(label="Help") GUI.config(menu = menu1) ###### FONCTION OUVERTURE DE FICHIER ###### def openfile(): global cmd_file cmd_file = filedialog.askopenfilename(title="Open SMW Log file", filetypes=(("Text Files", "*.log"),)) filename = os.path.basename(cmd_file) path_entry.insert(END, cmd_file) cmd_file = open(cmd_file, 'r') log_data = cmd_file.read() log_area.insert(END, log_data) cmd_file.close() ###### BOUTON OUVERTURE DU FICHIER ###### Openbutton = tk.Button(GUI) Openbutton["bg"] = "#757575" ft = tkFont.Font(family = 'Arial', size = 12, weight = "bold") Openbutton["font"] = ft Openbutton["fg"] = "#FFFFFF" Openbutton["justify"] = "center" Openbutton["text"] = "OPEN FILE" Openbutton.place(x = 200, y = 705, width = 175, height = 49) Openbutton["command"] = openfile ###### AFFICHAGE DU CHEMIN D'ACCES ###### path_entry = tk.Entry(GUI) path_entry["bg"] = "#FFFFFF" path_entry["borderwidth"] = "2px" ft = tkFont.Font(family = 'Arial', size = 10) path_entry["font"] = ft path_entry["fg"] = "#333333" path_entry["justify"] = "center" path_entry["text"] = "path" path_entry.place(x = 400, y = 715, width = 300, height = 30) ###### BOX TEXTE AFFICHAGE DU LOG ###### log_area = tk.Text(GUI) log_area["bg"] = "#FFFFFF" log_area["borderwidth"] = "4px" ft = tkFont.Font(family = 'Arial', size = 13) log_area["font"] = ft log_area["fg"] = "#333333" log_area.place(x = 10, y = 30, width = 715, height = 640) scrollbar = Scrollbar(GUI, orient = "vertical") log_area.config(yscrollcommand = scrollbar.set) scrollbar.config(command = log_area.yview) scrollbar.place(x = 733, y = 30) ###### TEXTE EN ENTETE DU LOG ###### box_title = tk.Label(GUI) box_title["bg"] = "#0BBB10" ft = tkFont.Font(family = 'Arial', size = 12, weight = "bold") box_title["font"] = ft box_title["fg"] = "#FFFFFF" box_title["justify"] = "center" box_title["text"] = "Display log from Symmetra MW" box_title.place(x = 5, y = 1, width = 282, height = 25) ###### TEXTE EN ENTETE DES INFORMATIONS ###### gen_info = tk.Label(GUI) gen_info["bg"] = "#0BBB10" ft = tkFont.Font(family = 'Arial', size = 10, weight = "bold") gen_info["font"] = ft gen_info["fg"] = "#FFFFFF" gen_info["justify"] = "center" gen_info["text"] = "GENERAL LOGS INFORMATIONS" gen_info.place(x = 810, y = 10, width = 302, height = 32) ###### BOUTON ANALYZE ###### Analyze_button = tk.Button(GUI) Analyze_button["bg"] = "#757575" ft = tkFont.Font(family = 'Arial', size = 12, weight = "bold") Analyze_button["font"] = ft Analyze_button["fg"] = "#FFFFFF" Analyze_button["justify"] = "center" Analyze_button["text"] = "Analyze" Analyze_button.place(x = 875, y = 240, width = 175, height = 49) #Analyze_button["command"] = self.Openbutton_command ###### BOUTON IMPRIMER ###### print_button = tk.Button(GUI) print_button["bg"] = "#f0f0f0" ft = tkFont.Font(family = 'Arial', size = 10, weight = "bold") print_button["font"] = ft print_button["fg"] = "#000000" print_button["justify"] = "center" print_button["text"] = "Print" print_button.place(x = 1070, y = 750, width = 70, height = 30) #print_button["command"] = self.print_button_command ###### TEXTBOX DE DEFAUTS ###### fault_box = tk.Listbox(GUI) fault_box["bg"] = "#D8D8D8" fault_box["borderwidth"] = "1px" ft = tkFont.Font(family = 'Arial', size = 10) fault_box["font"] = ft fault_box["fg"] = "#333333" fault_box["justify"] = "right" fault_box.place(x = 780, y = 300, width = 360, height = 372) ###### ESPACE AFFICHAGE DES DONNEES : TAILLE DE LA FRAME ###### Frame_entry = tk.Entry(GUI) Frame_entry["bg"] = "#D8D8D8" Frame_entry["borderwidth"] = "2px" ft = tkFont.Font(family = 'Arial', size = 10) Frame_entry["font"] = ft Frame_entry["fg"] = "#333333" Frame_entry["justify"] = "center" Frame_entry["text"] = "FRAME SIZE" Frame_entry.insert(0, "awaiting log_data...") Frame_entry.place(x = 820, y = 80, width = 124, height = 30) ###### ESPACE AFFICHAGE DES DONNEES : DATE###### date_entry = tk.Entry(GUI) date_entry["bg"] = "#D8D8D8" date_entry["borderwidth"] = "2px" ft = tkFont.Font(family = 'Arial', size = 10) date_entry["font"] = ft date_entry["fg"] = "#333333" date_entry["justify"] = "center" date_entry["text"] = "Entry" date_entry.insert(0, "awaiting log_data...") date_entry.place(x = 820, y = 160, width = 123, height = 30) ###### ESPACE AFFICHAGE DES DONNEES : serial ###### serial_get = tk.Label(GUI) #serial_get["bg"] = "#0BBB10" #ft = tkFont.Font(family='Arial', size=10, weight="bold") #serial_get["font"] = ft serial_get["fg"] = "#FFFFFF" serial_get["justify"] = "center" serial_get["text"] = filename serial_get.place(x=988, y=85, width=110, height=25) ###### ESPACE AFFICHAGE DES DONNEES : OPERATEUR ###### operator_Entry = tk.Entry(GUI) operator_Entry["borderwidth"] = "2px" ft = tkFont.Font(family = 'Arial', size = 10) operator_Entry["font"] = ft operator_Entry["fg"] = "#333333" operator_Entry["justify"] = "center" operator_Entry["text"] = "Operator" operator_Entry.insert(0, '') operator_Entry.place(x = 990, y = 160, width = 124, height = 30) ###### TEXTE DATE ###### date_label = tk.Label(GUI) date_label["bg"] = "#0BBB10" ft = tkFont.Font(family = 'Arial', size = 10, weight = "bold") date_label["font"] = ft date_label["fg"] = "#FFFFFF" date_label["justify"] = "center" date_label["text"] = "LOG DATE" date_label.place(x = 820, y = 135, width = 70, height = 25) ###### TAILLE DE LA FRAME ###### frame_label = tk.Label(GUI) frame_label["bg"] = "#0BBB10" ft = tkFont.Font(family = 'Arial', size = 10, weight = "bold") frame_label["font"] = ft frame_label["fg"] = "#FFFFFF" frame_label["justify"] = "center" frame_label["text"] = "FRAME SIZE" frame_label.place(x = 820, y = 55, width = 80, height = 25) ###### TEXTE serial ###### serial_label = tk.Label(GUI) serial_label["bg"] = "#0BBB10" ft = tkFont.Font(family = 'Arial', size = 10, weight = "bold") serial_label["font"] = ft serial_label["fg"] = "#FFFFFF" serial_label["justify"] = "center" serial_label["text"] = "SERIAL NUMBER" serial_label.place(x = 988, y = 55, width = 110, height = 25) ###### TEXTE OPERATEUR ###### operator_label = tk.Label(GUI) operator_label["bg"] = "#0BBB10" ft = tkFont.Font(family = 'Arial', size = 10, weight = "bold") operator_label["font"] = ft operator_label["fg"] = "#FFFFFF" operator_label["justify"] = "center" operator_label["text"] = "OPERATOR" operator_label.place(x = 988, y = 135, width = 85, height = 25) ###### COMMANDE NON UTILISEE 1 ###### def Openbutton_command(self): ft = tkFont.Font(family = 'Arial', size = 10) date_label["font"] = ft date_label["fg"] = "#333333" date_label["justify"] = "center" date_label["text"] = "label" print("command") ###### COMMANDE NON UTILISEE 2 ###### def print_button_command(self): ft = tkFont.Font(family = 'Arial', size = 10) date_label["font"] = ft date_label["fg"] = "#333333" date_label["justify"] = "center" date_label["text"] = "label" print("command") ###### MODULE POUR GERER LES EXCEPTIONS EN CAS D'ERREUR (NON UTILISE) ###### def build_window(error_message): ###### MODULE DE SORTIE DE LA FENETRE (EXIT) ###### def quitHandler(): GUI.destroy() ###### BOUTON EXIT ###### exitbutton = tk.Button(GUI) exitbutton["bg"] = "#f0f0f0" ft = tkFont.Font(family = 'Arial', size = 10, weight = "bold") exitbutton["font"] = ft exitbutton["fg"] = "#000000" exitbutton["justify"] = "center" exitbutton["text"] = "EXIT" exitbutton.place(x = 20, y = 750, width = 70, height = 30) exitbutton["command"] = quitHandler mainloop() ###### DEFINITION DE LA FABRICATION DE LA FENETRE ###### def call_build_window(): build_window("initial value") build_window("Error!") call_build_window() GUI.mainloop() GUI.close()