1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| import sqlite3
from configparser import ConfigParser
import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter.ttk import *
from tkinter import font
from tkinter import Listbox
import ftplib
import os
from datetime import datetime, timedelta
from pytz import timezone
import string
import array
from io import BytesIO
import numpy
from tkinter import messagebox
#Application parameters
#FTP parametrers
CFG_FILE = ConfigParser()
CFG_FILE.optionxform = str
CFG_FILE.read('ini/application.ini')
print(os.getlogin()+' connected')
APPLICATION_NAME = CFG_FILE.get('APPLICATION_PARAMETERS', 'APPLICATION_NAME')
APP_SHORT_NAME = CFG_FILE.get('APPLICATION_PARAMETERS', 'APPLICATION_SHORT_NAME')
def SQLConnexion():
#Connexion to SQLite database
#print('Connexion to local SQLite GMAO.db')
global QR_TOOL, Curseur
QR_TOOL = []
DBconnexion = sqlite3.connect('SQL/GMAO.db')
Curseur = DBconnexion.cursor()
Curseur.execute("SELECT * FROM idtools order by QR_TOOL asc;")
TOOLS = Curseur.fetchall()
for tool in TOOLS:
QR_TOOL.append(tool[2])
#print(tool)
DisplayGUI()
def DisplayGUI():
global main_window, Mainfont
main_window = tk.Tk()
main_window.state("zoomed")
main_window.title(APPLICATION_NAME)
main_window.iconbitmap(r'ini/logo.ico')
Mainfont = font.Font(main_window, family='Courier new', size='10')
#Création de la barre de menu:
barremenu = tk.Menu(main_window)
#Création du menu "Fichier"
fichier = tk.Menu(barremenu, tearoff=0)
barremenu.add_cascade(label="Gestion des outillages", underline=0, menu=fichier)
fichier.add_command(label="Créer un outillage", underline=0, command=Toolcreation)
fichier.add_command(label="Saisir une panne", underline=0, command=AddBreakdown)
fichier.add_command(label="Saisir une intervention", underline=0, command=AddIntervention)
#Création menu statistiques
stat = tk.Menu(barremenu, tearoff=0)
barremenu.add_cascade(label="Statistiques", underline=0, menu=stat)
stat.add_command(label="Emplacement outillage sur ligne", underline=0, command = WhereIam)
stat.add_command(label="Pareto par ligne", underline=0, command = Pareto_Line)
stat.add_command(label="Pareto par outillage", underline=0, command = Pareto_Tool)
stat.add_command(label="Listing outillage", underline=0, command = Listing_Tool)
#Création du menu "Aide"
aide = tk.Menu(barremenu, tearoff=0)
barremenu.add_cascade(label="Aide", underline=0, menu=aide)
aide.add_command(label="Manuel", underline=0, command = manuel)
aide.add_command(label="A propos", underline=0, command = apropos)
#Afficher le menu
main_window.config(menu=barremenu)
#Other control
LabelOfChoiceTool = ttk.Label(main_window, text="Select a tool:", font=Mainfont)
LabelOfChoiceTool.place(x=5, y=10)
Combo_tool = ttk.Combobox(values=QR_TOOL, state="readonly", font=Mainfont)
Combo_tool.place(x=160, y=10)
Combo_tool.bind('<<ComboboxSelected>>', LoadDataOf)
global VarInfoTool
VarInfoTool = tk.StringVar()
LabelInfoTool = ttk.Label(main_window, text=VarInfoTool, font=Mainfont)
LabelInfoTool.place(x=360, y=10)
main_window.mainloop()
###########################################################################################################
def Toolcreation(): messagebox.showinfo(APP_SHORT_NAME, "Vous allez créer un outillage")
def AddBreakdown(): messagebox.showinfo(APP_SHORT_NAME, "Vous allez ajouter une panne")
def AddIntervention(): messagebox.showinfo(APP_SHORT_NAME, "Vous allez saisir une réparation")
def WhereIam(): messagebox.showinfo(APP_SHORT_NAME, "Connaître l'emplacement de votre outillage")
def Pareto_Line(): messagebox.showinfo(APP_SHORT_NAME, "Pareto des pannes par ligne")
def Pareto_Tool(): messagebox.showinfo(APP_SHORT_NAME, "Pareto des pannes par outillages")
def Listing_Tool(): messagebox.showinfo(APP_SHORT_NAME, "Liste des outillages existants")
def manuel(): print ("manuel")
def apropos(): print ("apropos")
def LoadDataOf(eventObject):
#print(eventObject.widget.get())
SELECTED_QR_TOOL = eventObject.widget.get()
Curseur.execute("SELECT * FROM idtools WHERE QR_TOOL='"+SELECTED_QR_TOOL+"';")
ToolInfos = Curseur.fetchall()
for infos in ToolInfos:
VarInfoTool.set(infos[0])
print(infos)
###########################################################################################################
if __name__ == "__main__":
SQLConnexion() |
Partager