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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
| 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
import datetime
#Application parameters
#FTP parametrers
CFG_FILE = ConfigParser()
CFG_FILE.optionxform = str
CFG_FILE.read('ini/application.ini')
print(os.getlogin().upper()+' is connected at '+str(datetime.datetime.now().time().replace(microsecond=0)))
APPLICATION_NAME = CFG_FILE.get('APPLICATION_PARAMETERS', 'APPLICATION_NAME')
APP_SHORT_NAME = CFG_FILE.get('APPLICATION_PARAMETERS', 'APPLICATION_SHORT_NAME')
class Main_app(tk.Tk):
def __init__(self,parent):
tk.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
global Myfont, Curseur
Myfont = font.Font(self, ("courier new", 10))
DBconnexion = sqlite3.connect('SQL/GMAO.db')
Curseur = DBconnexion.cursor()
#self.grid_columnconfigure(0,weight=1)
self.Interface()
def Interface(self):
#Creation of main menubar:
Menubar = tk.Menu(self)
#Create a pulldown menu, and add it to the menu bar
Toolmanagement = Menu(Menubar, tearoff=0)
Toolmanagement.add_command(label = "Créer prefixe outillage", command=self.hello)
Toolmanagement.add_command(label = "Supprimer prefixe outillage", command=self.hello)
Toolmanagement.add_separator()
Toolmanagement.add_command(label = "Créer un outillage", command=self.hello)
Toolmanagement.add_command(label = "Modifier un outillage", command=self.hello)
Toolmanagement.add_command(label = "Supprimer un outillage", command=self.hello)
Toolmanagement.add_separator()
Toolmanagement.add_command(label = "Listing des outillages", command=self.hello)
Menubar.add_cascade(label = "Gestion des outillages", menu=Toolmanagement)
Stat = Menu(Menubar, tearoff=0)
Stat.add_command(label = "Pareto par outillages", command=self.hello)
Stat.add_command(label = "Pareto par lignes", command=self.hello)
Menubar.add_cascade(label = "Statistiques", menu=Stat)
Helper = Menu(Menubar, tearoff=0)
Helper.add_command(label = "A propos", command=self.hello)
Helper.add_command(label = "Aide", command=self.Comingsoon)
Menubar.add_cascade(label = "Aide", menu=Helper)
#Display the menu
self.config(menu = Menubar)
#End of menu##############################################################################
label = tk.Label(self, text="QR code outillage:", anchor="w", font=Myfont)
label.grid(row=0, column=0, pady=5, sticky='NW')
global QR_TOOL
QR_TOOL = Entry(self, width=15, font=Myfont, justify='center')
QR_TOOL.grid(row=0, column=1, pady=5, sticky='NW')
QR_TOOL.bind('<Return>', self.ToolCheck)
global LabelInfoTool
LabelInfoTool = tk.Label(self, text="", anchor="w", font=Myfont, relief=GROOVE)
#Here the functions:
def ToolCheck(self, event):
#print("ToolCheck function activated...")
if len(QR_TOOL.get()) != 8:
messagebox.showerror(APP_SHORT_NAME, "Le QR code doit contenir 8 caractères.")
else:
PREFIX_TOOL = QR_TOOL.get()[:4].upper()
NUMBER_TOOL = QR_TOOL.get()[4:]
if not PREFIX_TOOL.isalpha():
messagebox.showerror(APP_SHORT_NAME, "Le prefixe outillage ne doit pas être décimal.")
elif not NUMBER_TOOL.isdigit():
messagebox.showerror(APP_SHORT_NAME, "Le numéro outillage doit être décimal.")
else:
#Check if enter tool exist in DB, if not create one or not
sQR_TOOL = PREFIX_TOOL+NUMBER_TOOL
Curseur.execute("SELECT * FROM idtools WHERE QR_TOOL='"+sQR_TOOL+"';")
result = Curseur.fetchone()
global ID_TOOLTYPE
if result==None:
messagebox.showerror(APP_SHORT_NAME, "Aucune valeur trouvée pour l'outillage "+sQR_TOOL+'.')
else:
ID_TOOLTYPE = result[8]
print("Outillage "+sQR_TOOL+ " trouvé (ID "+str(ID_TOOLTYPE)+").")
LabelInfoTool.config(text=result[6]+ ' [' +result[9]+']')
LabelInfoTool.grid(row=0, column=2, pady=5, sticky='NW')#, padx=5)
self.CreateTabSheet()
def CreateTabSheet(self):
global CELLS
CELLS = []
self.tab_control = ttk.Notebook(self)
self.TabBreakdown = ttk.Frame(self.tab_control)
self.TabIntervention = ttk.Frame(self.tab_control)
self.TabHistory = ttk.Frame(self.tab_control)
self.tab_control.add(self.TabBreakdown, text='Saisie panne')
self.tab_control.add(self.TabIntervention, text='Saisie intervention')
self.tab_control.add(self.TabHistory, text='Historique')
self.lbl_10 = Label(self.TabBreakdown, text='Choisir une ligne:', font=Myfont)
self.lbl_10.grid(row=0, column=0, pady=10)
self.LoadLines()
self.Combo_line = ttk.Combobox(self.TabBreakdown, values=(LINES), state='readonly', font=Myfont)
self.Combo_line.grid(row=0, column=1, pady=10)
self.Combo_line.bind('<<ComboboxSelected>>', self.LoadCells)
self.lbl_11 = Label(self.TabBreakdown, text='Choisir une cellule:', font=Myfont)
self.lbl_11.grid(row=0, column=2, padx=5, pady=10)
self.Combo_cell = ttk.Combobox(self.TabBreakdown, values=(CELLS), state='readonly', font=Myfont)
self.Combo_cell.grid(row=0, column=3, padx=5, pady=10)
self.Combo_cell.bind('<<ComboboxSelected>>', self.hello())
self.lbl_12 = Label(self.TabBreakdown, text='Choisir une emplacement:', font=Myfont)
self.lbl_12.grid(row=0, column=4, padx=5, pady=10)
self.Combo_location = ttk.Combobox(self.TabBreakdown, values=('DEFAULT_LOCATION'), state='readonly', font=Myfont)
self.Combo_location.grid(row=0, column=5, padx=5, pady=10)
self.Combo_location.bind('<<ComboboxSelected>>', self.hello())
self.lbl_13 = Label(self.TabBreakdown, text='Outil mis en place:', font=Myfont)
self.lbl_13.grid(row=1, column=0, padx=5, pady=10)
self.Combo_newtool = ttk.Combobox(self.TabBreakdown, values=('DEFAULT_NEW_TOOL'), state='readonly', font=Myfont)
self.Combo_newtool.grid(row=1, column=1)
self.Combo_newtool.bind('<<ComboboxSelected>>', self.hello())
#Get intervenants
Curseur.execute("SELECT * FROM intervenant;")
global INTERVENANT
INTERVENANT = []
result_intervenant = Curseur.fetchall()
for intervenant in result_intervenant:
INTERVENANT.append(intervenant[2]+' '+intervenant[1])
#print(intervenant[2]+' '+intervenant[1])
self.lbl_14 = Label(self.TabBreakdown, text='Intervenant:', font=Myfont)
self.lbl_14.grid(row=1, column=2, padx=5, pady=10)
self.Combo_intervenant = ttk.Combobox(self.TabBreakdown, values=(INTERVENANT), state='readonly', font=Myfont)
self.Combo_intervenant.grid(row=1, column=3)
self.Combo_intervenant.bind('<<ComboboxSelected>>', self.hello())
self.lbl_15 = Label(self.TabBreakdown, text='Date du retrait:', font=Myfont)
self.lbl_15.grid(row=3, column=0, padx=5, pady=10)
self.lbl_17 = Label(self.TabBreakdown, text='Heure:', font=Myfont)
self.lbl_17.grid(row=3, column=2, padx=5, pady=10)
self.BreakdownHourValue = StringVar(self.TabBreakdown, value=datetime.datetime.now().time().replace(microsecond=0))
self.BreakdownHour = Entry(self.TabBreakdown, textvariable=self.BreakdownHourValue, width=15, font=Myfont, justify='center')
self.BreakdownHour.grid(row=3, column=3, pady=5, sticky='NW')
self.BreakdownHour.bind('<Return>', self.hello)
self.BTfont = ttk.Style()
self.BTfont.configure('my.TButton', font=("courier new", 10))
self.BTBreakdownValidation = ttk.Button(self.TabBreakdown, text='Valider la saisie', style='my.TButton', command=self.hello)
self.BTBreakdownValidation.grid(row=4, column=0, padx=5, pady=10)
self.lbl_16 = Label(self.TabBreakdown, text='Commentaire:', font=Myfont)
self.lbl_16.grid(row=2, column=0, padx=5, pady=10)
self.Comment = Text(self.TabBreakdown, width=50, height=4, wrap=WORD)
self.Comment.grid(row=2, column=1, columnspan=2, padx=20, pady=10)
############################################################################################################
#TabellSheet 2
self.lbl2 = Label(self.TabIntervention, text= 'label2')
self.lbl2.grid(column=0, row=0)
self.tab_control.grid(row=1, column=0, columnspan=50, sticky='EWS', pady=20)
def LoadLines(self):
Curseur.execute("SELECT * FROM lines;")
global LINES
LINES = []
result = Curseur.fetchall()
for line in result:
LINES.append(line[1])
#toto=str.split(';', 1 )
def LoadCells(self, eventObject):
SELECTED_LINE = eventObject.widget.get()
Curseur.execute("SELECT ID FROM lines WHERE LINE_SHORT_NAME='"+SELECTED_LINE+"';")
result = Curseur.fetchone()
#global Cells
if result==None:
messagebox.showerror(APP_SHORT_NAME, "Aucune cellules trouvées pour la ligne "+SELECTED_LINE+'.')
else:
ID_LINE = result[0]
#Curseur.execute("""SELECT * FROM location WHERE ID_LINE=?""", (id,))
CELLS=[]
#Load cells
Curseur.execute("SELECT distinct(ID_CELL), lines.ID, CELL_NUMBER, CELL_NAME FROM location, lines, cells WHERE location.ID_TOOL='"+str(ID_TOOLTYPE)+"' AND cells.ID=location.ID_CELL AND lines.ID=cells.ID_LINE AND lines.ID='"+str(ID_LINE)+"';")
Cells = Curseur.fetchall()
for cell in Cells:
CELLS.append(str(cell[2])+str(' ')+str(cell[3]))
print(str(cell[2])+str(' ')+str(cell[3]))
def hello(self):
print('hello')
def Comingsoon(self): messagebox.showinfo(APP_SHORT_NAME, "Bientôt disponible!")
if __name__ == "__main__":
main_window = Main_app(None)
main_window.title(APPLICATION_NAME)
main_window.iconbitmap(r'ini/logo.ico')
#main_window.state("zoomed")
main_window.mainloop() |
Partager