[mod] auto pep8
This commit is contained in:
parent
91fc3b286b
commit
e91c3b69b8
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import sys, os
|
import sys
|
||||||
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import locale
|
import locale
|
||||||
import ntpath
|
import ntpath
|
||||||
|
|
@ -16,6 +17,7 @@ __BDD__ = "bdd/main.db"
|
||||||
__CONFDIR__ = os.path.dirname(os.path.realpath("MesCigares.py"))
|
__CONFDIR__ = os.path.dirname(os.path.realpath("MesCigares.py"))
|
||||||
__CONFIGFILE__ = "conf/mescigares.conf"
|
__CONFIGFILE__ = "conf/mescigares.conf"
|
||||||
|
|
||||||
|
|
||||||
class MesCigares:
|
class MesCigares:
|
||||||
|
|
||||||
def on_window_main_destroy(self, widget, data=None):
|
def on_window_main_destroy(self, widget, data=None):
|
||||||
|
|
@ -31,7 +33,7 @@ class MesCigares:
|
||||||
self.aboutdialog.hide()
|
self.aboutdialog.hide()
|
||||||
|
|
||||||
# Mise à jour de la quantité en fonction du cigare choisi dans la liste déroulante
|
# Mise à jour de la quantité en fonction du cigare choisi dans la liste déroulante
|
||||||
def on_cbchoixcigqte_changed(self,object,data=None):
|
def on_cbchoixcigqte_changed(self, object, data=None):
|
||||||
item = self.cbchoixcigqte.get_active()
|
item = self.cbchoixcigqte.get_active()
|
||||||
|
|
||||||
# Si aucune séléction, pas besoin de traitement.
|
# Si aucune séléction, pas besoin de traitement.
|
||||||
|
|
@ -60,7 +62,7 @@ class MesCigares:
|
||||||
rs2 = cursor.fetchall()
|
rs2 = cursor.fetchall()
|
||||||
# top = 5 premier items de la liste par meilleure note [2] pour la note seulement
|
# top = 5 premier items de la liste par meilleure note [2] pour la note seulement
|
||||||
top = sorted(rs2, reverse=True)[0:5]
|
top = sorted(rs2, reverse=True)[0:5]
|
||||||
print (top)
|
print(top)
|
||||||
# top5 = juste les id
|
# top5 = juste les id
|
||||||
top5 = list()
|
top5 = list()
|
||||||
for i in top:
|
for i in top:
|
||||||
|
|
@ -103,37 +105,37 @@ class MesCigares:
|
||||||
# Il n'y a pas de outer join en sqlite du coup je suis obligé d'alimenter les notes à part
|
# Il n'y a pas de outer join en sqlite du coup je suis obligé d'alimenter les notes à part
|
||||||
for item2 in rs2:
|
for item2 in rs2:
|
||||||
itr = self.table.get_iter_first()
|
itr = self.table.get_iter_first()
|
||||||
while ( itr != None ):
|
while (itr != None):
|
||||||
# itr, 5 = id de la table cigare (colonne 4 invisible), item2[2] = id_cigare table degustation
|
# itr, 5 = id de la table cigare (colonne 4 invisible), item2[2] = id_cigare table degustation
|
||||||
if self.table.get_value (itr, 5) == item2[2]:
|
if self.table.get_value(itr, 5) == item2[2]:
|
||||||
self.table.set(itr, 6, item2[1], 7, item2[0])
|
self.table.set(itr, 6, item2[1], 7, item2[0])
|
||||||
itr= self.table.iter_next(itr)
|
itr = self.table.iter_next(itr)
|
||||||
for item3 in rs3:
|
for item3 in rs3:
|
||||||
itr = self.table.get_iter_first ()
|
itr = self.table.get_iter_first()
|
||||||
while ( itr != None ):
|
while (itr != None):
|
||||||
# itr, 5 = id de la table cigare (colonne 4 invisible), item3[1] = id_cigare table achats
|
# itr, 5 = id de la table cigare (colonne 4 invisible), item3[1] = id_cigare table achats
|
||||||
if self.table.get_value (itr, 5) == item3[1]:
|
if self.table.get_value(itr, 5) == item3[1]:
|
||||||
# .2f pour 2 decimales
|
# .2f pour 2 decimales
|
||||||
it = '%.2f' % item3[0]
|
it = '%.2f' % item3[0]
|
||||||
self.table.set(itr, 8, it + " €", 10, float(item3[0]))
|
self.table.set(itr, 8, it + " €", 10, float(item3[0]))
|
||||||
itr= self.table.iter_next(itr)
|
itr = self.table.iter_next(itr)
|
||||||
for item4 in rs4:
|
for item4 in rs4:
|
||||||
itr = self.table.get_iter_first ()
|
itr = self.table.get_iter_first()
|
||||||
while ( itr != None ):
|
while (itr != None):
|
||||||
# itr, 4 = id de la table cigare (colonne 4 invisible), item4[1] = id_cigare table achats
|
# itr, 4 = id de la table cigare (colonne 4 invisible), item4[1] = id_cigare table achats
|
||||||
if self.table.get_value (itr, 5) == item4[1]:
|
if self.table.get_value(itr, 5) == item4[1]:
|
||||||
self.table.set(itr, 9, item4[0])
|
self.table.set(itr, 9, item4[0])
|
||||||
itr= self.table.iter_next(itr)
|
itr = self.table.iter_next(itr)
|
||||||
|
|
||||||
# On calcule le nombre de cigares et le prix
|
# On calcule le nombre de cigares et le prix
|
||||||
nbcigares = 0
|
nbcigares = 0
|
||||||
montant = 0
|
montant = 0
|
||||||
itr = self.table.get_iter_first ()
|
itr = self.table.get_iter_first()
|
||||||
while ( itr != None ):
|
while (itr != None):
|
||||||
nbcigares += int(self.table.get_value(itr, 4))
|
nbcigares += int(self.table.get_value(itr, 4))
|
||||||
if self.table.get_value(itr, 8) is not None:
|
if self.table.get_value(itr, 8) is not None:
|
||||||
montant += float(self.table.get_value(itr, 10)) * int(self.table.get_value(itr, 4))
|
montant += float(self.table.get_value(itr, 10)) * int(self.table.get_value(itr, 4))
|
||||||
itr= self.table.iter_next(itr)
|
itr = self.table.iter_next(itr)
|
||||||
montant = '%.2f' % montant
|
montant = '%.2f' % montant
|
||||||
|
|
||||||
# On calcule le prix total
|
# On calcule le prix total
|
||||||
|
|
@ -174,14 +176,14 @@ class MesCigares:
|
||||||
new_size = self.window.get_size()[0] - 20
|
new_size = self.window.get_size()[0] - 20
|
||||||
if(pixbuf.get_width() > new_size):
|
if(pixbuf.get_width() > new_size):
|
||||||
w, h = pixbuf.get_width(), pixbuf.get_height()
|
w, h = pixbuf.get_width(), pixbuf.get_height()
|
||||||
pixbuf = pixbuf.scale_simple( new_size, new_size * h / w, GdkPixbuf.InterpType.HYPER)
|
pixbuf = pixbuf.scale_simple(new_size, new_size * h / w, GdkPixbuf.InterpType.HYPER)
|
||||||
# Si la largeur de l'image est plus petite que la hauteur on fait pivoter
|
# Si la largeur de l'image est plus petite que la hauteur on fait pivoter
|
||||||
if(pixbuf.get_width() < pixbuf.get_height()):
|
if(pixbuf.get_width() < pixbuf.get_height()):
|
||||||
pixbuf = pixbuf.rotate_simple(270)
|
pixbuf = pixbuf.rotate_simple(270)
|
||||||
# Si la hauteur est dépasse la moitié de la fenêtre principale, on re-dimensionne
|
# Si la hauteur est dépasse la moitié de la fenêtre principale, on re-dimensionne
|
||||||
if(pixbuf.get_height() > self.window.get_size()[1]/2):
|
if(pixbuf.get_height() > self.window.get_size()[1] / 2):
|
||||||
w, h = pixbuf.get_width(), pixbuf.get_height()
|
w, h = pixbuf.get_width(), pixbuf.get_height()
|
||||||
pixbuf = pixbuf.scale_simple( (w * self.window.get_size()[1]/2)/h, self.window.get_size()[1]/2 , GdkPixbuf.InterpType.HYPER)
|
pixbuf = pixbuf.scale_simple((w * self.window.get_size()[1] / 2) / h, self.window.get_size()[1] / 2, GdkPixbuf.InterpType.HYPER)
|
||||||
self.image_preview.set_from_pixbuf(pixbuf)
|
self.image_preview.set_from_pixbuf(pixbuf)
|
||||||
else:
|
else:
|
||||||
# Si la photo n'existe plus ou a été renommée
|
# Si la photo n'existe plus ou a été renommée
|
||||||
|
|
@ -191,8 +193,8 @@ class MesCigares:
|
||||||
|
|
||||||
# Si la fenêtre principale change de taille on re-dimensionne le preview aussi
|
# Si la fenêtre principale change de taille on re-dimensionne le preview aussi
|
||||||
def on_window_main_check_resize(self, widget):
|
def on_window_main_check_resize(self, widget):
|
||||||
#print(self.window.get_size()[1],self.window_last_h)
|
# print(self.window.get_size()[1],self.window_last_h)
|
||||||
if (( abs(self.window_last_h - self.window.get_size()[1]) > 40) | ( abs(self.window_last_w - self.window.get_size()[0]) > 5) ):
|
if ((abs(self.window_last_h - self.window.get_size()[1]) > 40) | (abs(self.window_last_w - self.window.get_size()[0]) > 5)):
|
||||||
self.window_last_h = self.window.get_size()[1]
|
self.window_last_h = self.window.get_size()[1]
|
||||||
self.window_last_w = self.window.get_size()[0]
|
self.window_last_w = self.window.get_size()[0]
|
||||||
|
|
||||||
|
|
@ -203,14 +205,14 @@ class MesCigares:
|
||||||
new_size = self.window.get_size()[0] - 20
|
new_size = self.window.get_size()[0] - 20
|
||||||
if(pixbuf.get_width() > new_size):
|
if(pixbuf.get_width() > new_size):
|
||||||
w, h = pixbuf.get_width(), pixbuf.get_height()
|
w, h = pixbuf.get_width(), pixbuf.get_height()
|
||||||
pixbuf = pixbuf.scale_simple( new_size, new_size * h / w, GdkPixbuf.InterpType.HYPER)
|
pixbuf = pixbuf.scale_simple(new_size, new_size * h / w, GdkPixbuf.InterpType.HYPER)
|
||||||
# Si la largeur de l'image est plus petite que la hauteur on fait pivoter
|
# Si la largeur de l'image est plus petite que la hauteur on fait pivoter
|
||||||
if(pixbuf.get_width() < pixbuf.get_height()):
|
if(pixbuf.get_width() < pixbuf.get_height()):
|
||||||
pixbuf = pixbuf.rotate_simple(270)
|
pixbuf = pixbuf.rotate_simple(270)
|
||||||
# Si la hauteur est dépasse la moitié de la fenêtre principale, on re-dimensionne
|
# Si la hauteur est dépasse la moitié de la fenêtre principale, on re-dimensionne
|
||||||
if(pixbuf.get_height() > self.window.get_size()[1]/2):
|
if(pixbuf.get_height() > self.window.get_size()[1] / 2):
|
||||||
w, h = pixbuf.get_width(), pixbuf.get_height()
|
w, h = pixbuf.get_width(), pixbuf.get_height()
|
||||||
pixbuf = pixbuf.scale_simple( (w * self.window.get_size()[1]/2)/h, self.window.get_size()[1]/2 , GdkPixbuf.InterpType.HYPER)
|
pixbuf = pixbuf.scale_simple((w * self.window.get_size()[1] / 2) / h, self.window.get_size()[1] / 2, GdkPixbuf.InterpType.HYPER)
|
||||||
self.image_preview.set_from_pixbuf(pixbuf)
|
self.image_preview.set_from_pixbuf(pixbuf)
|
||||||
|
|
||||||
# Dès qu'une ligne est séléctionnée sur la treeview on enregistre les valeurs
|
# Dès qu'une ligne est séléctionnée sur la treeview on enregistre les valeurs
|
||||||
|
|
@ -238,7 +240,7 @@ class MesCigares:
|
||||||
(model, iter) = selection.get_selected()
|
(model, iter) = selection.get_selected()
|
||||||
if iter is not None:
|
if iter is not None:
|
||||||
lib = model.get_value(iter, 0)
|
lib = model.get_value(iter, 0)
|
||||||
qtee = model.get_value(iter,5)
|
qtee = model.get_value(iter, 5)
|
||||||
return(lib, qtee)
|
return(lib, qtee)
|
||||||
|
|
||||||
# Changer de base de données
|
# Changer de base de données
|
||||||
|
|
@ -262,7 +264,7 @@ class MesCigares:
|
||||||
db.close()
|
db.close()
|
||||||
db = sqlite3.connect(self.filechooser_bdd.get_filename())
|
db = sqlite3.connect(self.filechooser_bdd.get_filename())
|
||||||
# On met à jour le titre de la fenêtre
|
# On met à jour le titre de la fenêtre
|
||||||
self.window.set_title("MesCigares - base : {0}".format(ntpath.basename(self.filechooser_bdd.get_filename().replace('.db',''))))
|
self.window.set_title("MesCigares - base : {0}".format(ntpath.basename(self.filechooser_bdd.get_filename().replace('.db', ''))))
|
||||||
self.loadtreeview()
|
self.loadtreeview()
|
||||||
self.filechooser_bdd.hide()
|
self.filechooser_bdd.hide()
|
||||||
|
|
||||||
|
|
@ -377,23 +379,22 @@ class MesCigares:
|
||||||
self.scaleq12m.set_value(1)
|
self.scaleq12m.set_value(1)
|
||||||
self.scaleq13m.set_value(1)
|
self.scaleq13m.set_value(1)
|
||||||
|
|
||||||
|
|
||||||
# Calcul de la note globale pour modification d'une note de dégustation
|
# Calcul de la note globale pour modification d'une note de dégustation
|
||||||
def on_scaleqm_change_value(self, scale, enum, new_value):
|
def on_scaleqm_change_value(self, scale, enum, new_value):
|
||||||
# On récupère les notes
|
# On récupère les notes
|
||||||
q1=int(self.scaleq1m.get_value())
|
q1 = int(self.scaleq1m.get_value())
|
||||||
q2=int(self.scaleq2m.get_value())
|
q2 = int(self.scaleq2m.get_value())
|
||||||
q3=int(self.scaleq3m.get_value())
|
q3 = int(self.scaleq3m.get_value())
|
||||||
q4=int(self.scaleq4m.get_value())
|
q4 = int(self.scaleq4m.get_value())
|
||||||
q5=int(self.scaleq5m.get_value())
|
q5 = int(self.scaleq5m.get_value())
|
||||||
q6=int(self.scaleq6m.get_value())
|
q6 = int(self.scaleq6m.get_value())
|
||||||
q7=int(self.scaleq7m.get_value())
|
q7 = int(self.scaleq7m.get_value())
|
||||||
q8=int(self.scaleq8m.get_value())
|
q8 = int(self.scaleq8m.get_value())
|
||||||
q9=int(self.scaleq9m.get_value())
|
q9 = int(self.scaleq9m.get_value())
|
||||||
q10=int(self.scaleq10m.get_value())
|
q10 = int(self.scaleq10m.get_value())
|
||||||
q11=int(self.scaleq11m.get_value())
|
q11 = int(self.scaleq11m.get_value())
|
||||||
q12=int(self.scaleq12m.get_value())
|
q12 = int(self.scaleq12m.get_value())
|
||||||
q13=int(self.scaleq13m.get_value())
|
q13 = int(self.scaleq13m.get_value())
|
||||||
|
|
||||||
note = q1 + q2 + q3 + q4 + q5 + q6 + q7 + q8 + q9 + q10 + q11 + q12 + q13
|
note = q1 + q2 + q3 + q4 + q5 + q6 + q7 + q8 + q9 + q10 + q11 + q12 + q13
|
||||||
# On affiche la note / 100 temporaire
|
# On affiche la note / 100 temporaire
|
||||||
|
|
@ -407,21 +408,21 @@ class MesCigares:
|
||||||
start = textbuffer.get_start_iter()
|
start = textbuffer.get_start_iter()
|
||||||
end = textbuffer.get_end_iter()
|
end = textbuffer.get_end_iter()
|
||||||
# On récupère le commentaire et on échape les quote pour l'insert SQL
|
# On récupère le commentaire et on échape les quote pour l'insert SQL
|
||||||
commentaire = textbuffer.get_text(start, end, include_hidden_chars=False).replace("'","''")
|
commentaire = textbuffer.get_text(start, end, include_hidden_chars=False).replace("'", "''")
|
||||||
# On récupère les notes
|
# On récupère les notes
|
||||||
q1=int(self.scaleq1m.get_value())
|
q1 = int(self.scaleq1m.get_value())
|
||||||
q2=int(self.scaleq2m.get_value())
|
q2 = int(self.scaleq2m.get_value())
|
||||||
q3=int(self.scaleq3m.get_value())
|
q3 = int(self.scaleq3m.get_value())
|
||||||
q4=int(self.scaleq4m.get_value())
|
q4 = int(self.scaleq4m.get_value())
|
||||||
q5=int(self.scaleq5m.get_value())
|
q5 = int(self.scaleq5m.get_value())
|
||||||
q6=int(self.scaleq6m.get_value())
|
q6 = int(self.scaleq6m.get_value())
|
||||||
q7=int(self.scaleq7m.get_value())
|
q7 = int(self.scaleq7m.get_value())
|
||||||
q8=int(self.scaleq8m.get_value())
|
q8 = int(self.scaleq8m.get_value())
|
||||||
q9=int(self.scaleq9m.get_value())
|
q9 = int(self.scaleq9m.get_value())
|
||||||
q10=int(self.scaleq10m.get_value())
|
q10 = int(self.scaleq10m.get_value())
|
||||||
q11=int(self.scaleq11m.get_value())
|
q11 = int(self.scaleq11m.get_value())
|
||||||
q12=int(self.scaleq12m.get_value())
|
q12 = int(self.scaleq12m.get_value())
|
||||||
q13=int(self.scaleq13m.get_value())
|
q13 = int(self.scaleq13m.get_value())
|
||||||
|
|
||||||
note = q1 + q2 + q3 + q4 + q5 + q6 + q7 + q8 + q9 + q10 + q11 + q12 + q13
|
note = q1 + q2 + q3 + q4 + q5 + q6 + q7 + q8 + q9 + q10 + q11 + q12 + q13
|
||||||
# Le commentaire et l'id
|
# Le commentaire et l'id
|
||||||
|
|
@ -430,7 +431,7 @@ class MesCigares:
|
||||||
|
|
||||||
# On met à jour la base de données
|
# On met à jour la base de données
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
sql = "update degustation set commentaires = '{0}', q1 = '{1}', q2 = '{2}', q3 = '{3}', q4 = '{4}', q5 = '{5}', q7 = '{7}', q8 = '{8}', q9 = '{9}', q10 = '{10}', q11 = '{11}', q12 = '{12}', q13 = '{13}', note = '{14}' where id_cigare = '{15}' and id = '{16}'".format(commentaire, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, note , id_cigare, idcomm)
|
sql = "update degustation set commentaires = '{0}', q1 = '{1}', q2 = '{2}', q3 = '{3}', q4 = '{4}', q5 = '{5}', q7 = '{7}', q8 = '{8}', q9 = '{9}', q10 = '{10}', q11 = '{11}', q12 = '{12}', q13 = '{13}', note = '{14}' where id_cigare = '{15}' and id = '{16}'".format(commentaire, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, note, id_cigare, idcomm)
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
db.commit()
|
db.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
@ -458,7 +459,7 @@ class MesCigares:
|
||||||
# On regarde s'il y a déjà une photo pour le cigare séléctionné
|
# On regarde s'il y a déjà une photo pour le cigare séléctionné
|
||||||
nb = cursor.execute("select count(*) from photos where id_cigare = '{0}'".format(self.treeview_selection[5])).fetchone()[0]
|
nb = cursor.execute("select count(*) from photos where id_cigare = '{0}'".format(self.treeview_selection[5])).fetchone()[0]
|
||||||
# si nb = 0 on insère sinon on update la table photos
|
# si nb = 0 on insère sinon on update la table photos
|
||||||
if ( nb == 0):
|
if (nb == 0):
|
||||||
cursor.execute("insert into photos (id_cigare, photo) values('{0}','{1}')".format(self.treeview_selection[5], path))
|
cursor.execute("insert into photos (id_cigare, photo) values('{0}','{1}')".format(self.treeview_selection[5], path))
|
||||||
else:
|
else:
|
||||||
cursor.execute("update photos set photo = '{0}' where id_cigare='{1}'".format(path, self.treeview_selection[5]))
|
cursor.execute("update photos set photo = '{0}' where id_cigare='{1}'".format(path, self.treeview_selection[5]))
|
||||||
|
|
@ -474,12 +475,11 @@ class MesCigares:
|
||||||
if pthinfo is not None:
|
if pthinfo is not None:
|
||||||
path, col, cellx, celly = pthinfo
|
path, col, cellx, celly = pthinfo
|
||||||
self.tree.grab_focus()
|
self.tree.grab_focus()
|
||||||
self.tree.set_cursor( path, col, 0)
|
self.tree.set_cursor(path, col, 0)
|
||||||
# On affiche le popup
|
# On affiche le popup
|
||||||
self.popup.show_all();
|
self.popup.show_all()
|
||||||
self.popup.popup(None, None, None, None, event.button, event.time)
|
self.popup.popup(None, None, None, None, event.button, event.time)
|
||||||
|
|
||||||
|
|
||||||
def text_edited(self, widget, path, text):
|
def text_edited(self, widget, path, text):
|
||||||
self.liststore[path][1] = text
|
self.liststore[path][1] = text
|
||||||
|
|
||||||
|
|
@ -489,27 +489,27 @@ class MesCigares:
|
||||||
if col == 4:
|
if col == 4:
|
||||||
try:
|
try:
|
||||||
self.table.set_value(iter, col, int(new_text))
|
self.table.set_value(iter, col, int(new_text))
|
||||||
self.update_db("id", new_text,tuple(self.treeview_selection)[5])
|
self.update_db("id", new_text, tuple(self.treeview_selection)[5])
|
||||||
except ValueError: # Si la quantité saisie n'est pas un entier
|
except ValueError: # Si la quantité saisie n'est pas un entier
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.table.set_value(iter, col, new_text)
|
self.table.set_value(iter, col, new_text)
|
||||||
self.update_db("nom", new_text,tuple(self.treeview_selection)[5])
|
self.update_db("nom", new_text, tuple(self.treeview_selection)[5])
|
||||||
|
|
||||||
# Mise à jour de la BDD si changement dans un cellule
|
# Mise à jour de la BDD si changement dans un cellule
|
||||||
def update_db(self, operation, new_text, indice):
|
def update_db(self, operation, new_text, indice):
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
# update cigares.designation
|
# update cigares.designation
|
||||||
if (operation == 'nom'):
|
if (operation == 'nom'):
|
||||||
sql = "update cigares set designation = '{0}' where id = '{1}'".format(new_text.replace("'","''"),str(indice))
|
sql = "update cigares set designation = '{0}' where id = '{1}'".format(new_text.replace("'", "''"), str(indice))
|
||||||
#print(sql)
|
# print(sql)
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
# update quantité dans table stock
|
# update quantité dans table stock
|
||||||
if (operation == 'id'):
|
if (operation == 'id'):
|
||||||
sql = "update stocks set quantite = '{0}' where id_cigare='{1}'".format(new_text, str(indice))
|
sql = "update stocks set quantite = '{0}' where id_cigare='{1}'".format(new_text, str(indice))
|
||||||
#print(sql)
|
# print(sql)
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
@ -525,7 +525,6 @@ class MesCigares:
|
||||||
if len(self.tablemodules) != 0:
|
if len(self.tablemodules) != 0:
|
||||||
self.tablemodules.clear()
|
self.tablemodules.clear()
|
||||||
|
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute('Select id, libelle, provenance from marques order by lower(libelle)')
|
cursor.execute('Select id, libelle, provenance from marques order by lower(libelle)')
|
||||||
rs = cursor.fetchall()
|
rs = cursor.fetchall()
|
||||||
|
|
@ -546,7 +545,7 @@ class MesCigares:
|
||||||
self.dialog_add_cigare.hide()
|
self.dialog_add_cigare.hide()
|
||||||
|
|
||||||
# Changement dans la liste déroulante des marques
|
# Changement dans la liste déroulante des marques
|
||||||
def on_cbmarques_changed(self,widget):
|
def on_cbmarques_changed(self, widget):
|
||||||
index = self.cbmarques.get_active()
|
index = self.cbmarques.get_active()
|
||||||
try:
|
try:
|
||||||
provenance = self.tablemarques[index][2].title()
|
provenance = self.tablemarques[index][2].title()
|
||||||
|
|
@ -554,9 +553,8 @@ class MesCigares:
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self.lbl_marque.set_text("")
|
self.lbl_marque.set_text("")
|
||||||
|
|
||||||
|
|
||||||
# Changement dans la liste déroulante des modules
|
# Changement dans la liste déroulante des modules
|
||||||
def on_cbmodules_changed(self,widget):
|
def on_cbmodules_changed(self, widget):
|
||||||
try:
|
try:
|
||||||
index = self.cbmodules.get_active()
|
index = self.cbmodules.get_active()
|
||||||
longueur = self.tablemodules[index][2]
|
longueur = self.tablemodules[index][2]
|
||||||
|
|
@ -567,7 +565,7 @@ class MesCigares:
|
||||||
self.lbl_module.set_text("")
|
self.lbl_module.set_text("")
|
||||||
|
|
||||||
# Validation de l'ajout d'un nouveau cigare
|
# Validation de l'ajout d'un nouveau cigare
|
||||||
def on_btadd_clicked(self,widget):
|
def on_btadd_clicked(self, widget):
|
||||||
index = self.cbmarques.get_active()
|
index = self.cbmarques.get_active()
|
||||||
model = self.cbmarques.get_model()
|
model = self.cbmarques.get_model()
|
||||||
itemmarque = model[index]
|
itemmarque = model[index]
|
||||||
|
|
@ -584,15 +582,14 @@ class MesCigares:
|
||||||
# table stocks : id_cigare = max id + 1
|
# table stocks : id_cigare = max id + 1
|
||||||
#print (str(self.entry_nom_cigare.get_text()))
|
#print (str(self.entry_nom_cigare.get_text()))
|
||||||
|
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute('Select max(id) from cigares')
|
cursor.execute('Select max(id) from cigares')
|
||||||
try:
|
try:
|
||||||
maxid = cursor.fetchone()[0] + 1
|
maxid = cursor.fetchone()[0] + 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
maxid = 1
|
maxid = 1
|
||||||
cursor.execute("insert into stocks (id_cigare, quantite) values ('{0}','{1}')".format(int(maxid),0))
|
cursor.execute("insert into stocks (id_cigare, quantite) values ('{0}','{1}')".format(int(maxid), 0))
|
||||||
cursor.execute("insert into cigares (designation, marque, module) values ('{0}','{1}', '{2}')".format(str(self.entry_nom_cigare.get_text()), int(itemmarque[0]),int(itemmodel[0])))
|
cursor.execute("insert into cigares (designation, marque, module) values ('{0}','{1}', '{2}')".format(str(self.entry_nom_cigare.get_text()), int(itemmarque[0]), int(itemmodel[0])))
|
||||||
db.commit()
|
db.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
|
@ -612,7 +609,6 @@ class MesCigares:
|
||||||
if len(self.tablechoixcig) != 0:
|
if len(self.tablechoixcig) != 0:
|
||||||
self.tablechoixcig.clear()
|
self.tablechoixcig.clear()
|
||||||
|
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute('Select c.id, c.designation from cigares c order by c.designation asc')
|
cursor.execute('Select c.id, c.designation from cigares c order by c.designation asc')
|
||||||
rs = cursor.fetchall()
|
rs = cursor.fetchall()
|
||||||
|
|
@ -656,7 +652,7 @@ class MesCigares:
|
||||||
return
|
return
|
||||||
if(self.notebook_achats.get_current_page() == 0): # Choix à l'unité
|
if(self.notebook_achats.get_current_page() == 0): # Choix à l'unité
|
||||||
qte_achat = int(self.scale_qte_achats.get_value())
|
qte_achat = int(self.scale_qte_achats.get_value())
|
||||||
prix_achat = self.entry_prix_achats.get_text().replace(",",".")
|
prix_achat = self.entry_prix_achats.get_text().replace(",", ".")
|
||||||
prix_achat = '%.2f' % float(prix_achat)
|
prix_achat = '%.2f' % float(prix_achat)
|
||||||
code_boite = ""
|
code_boite = ""
|
||||||
else: # = 1 choix par boites
|
else: # = 1 choix par boites
|
||||||
|
|
@ -670,10 +666,10 @@ class MesCigares:
|
||||||
|
|
||||||
# On formate la date (ajout d'un 0 si besoin)
|
# On formate la date (ajout d'un 0 si besoin)
|
||||||
j = str(self.calendar_date_achats.get_date()[2])
|
j = str(self.calendar_date_achats.get_date()[2])
|
||||||
if(len(str(self.calendar_date_achats.get_date()[1] +1)) == 1):
|
if(len(str(self.calendar_date_achats.get_date()[1] + 1)) == 1):
|
||||||
m = "0" + str(self.calendar_date_achats.get_date()[1] +1)
|
m = "0" + str(self.calendar_date_achats.get_date()[1] + 1)
|
||||||
else:
|
else:
|
||||||
m = str(self.calendar_date_achats.get_date()[1] +1)
|
m = str(self.calendar_date_achats.get_date()[1] + 1)
|
||||||
a = self.calendar_date_achats.get_date()[0]
|
a = self.calendar_date_achats.get_date()[0]
|
||||||
|
|
||||||
date_achat = "{0}/{1}/{2}".format(j, m, a)
|
date_achat = "{0}/{1}/{2}".format(j, m, a)
|
||||||
|
|
@ -754,7 +750,6 @@ class MesCigares:
|
||||||
model = self.cbchoixcigqte.get_model()
|
model = self.cbchoixcigqte.get_model()
|
||||||
idc = model[item]
|
idc = model[item]
|
||||||
|
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("Update stocks set quantite = '{0}' where id_cigare = '{1}'".format(int(self.scaleqte.get_value()), idc[0]))
|
cursor.execute("Update stocks set quantite = '{0}' where id_cigare = '{1}'".format(int(self.scaleqte.get_value()), idc[0]))
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
@ -767,7 +762,7 @@ class MesCigares:
|
||||||
self.loadtreeview()
|
self.loadtreeview()
|
||||||
|
|
||||||
# Affichage de la fenêtre de dégustation
|
# Affichage de la fenêtre de dégustation
|
||||||
def on_gtk_degustation_activate(self,menuitem, data=None):
|
def on_gtk_degustation_activate(self, menuitem, data=None):
|
||||||
if len(self.tablechoixcigare) != 0:
|
if len(self.tablechoixcigare) != 0:
|
||||||
self.tablechoixcigare.clear()
|
self.tablechoixcigare.clear()
|
||||||
|
|
||||||
|
|
@ -787,10 +782,10 @@ class MesCigares:
|
||||||
|
|
||||||
# On formate la date (ajout d'un 0 si besoin)
|
# On formate la date (ajout d'un 0 si besoin)
|
||||||
j = str(self.DegustationDate.get_date()[2])
|
j = str(self.DegustationDate.get_date()[2])
|
||||||
if(len(str(self.DegustationDate.get_date()[1] +1)) == 1):
|
if(len(str(self.DegustationDate.get_date()[1] + 1)) == 1):
|
||||||
m = "0" + str(self.DegustationDate.get_date()[1] +1)
|
m = "0" + str(self.DegustationDate.get_date()[1] + 1)
|
||||||
else:
|
else:
|
||||||
m = str(self.DegustationDate.get_date()[1] +1)
|
m = str(self.DegustationDate.get_date()[1] + 1)
|
||||||
a = self.DegustationDate.get_date()[0]
|
a = self.DegustationDate.get_date()[0]
|
||||||
|
|
||||||
# Formatage de la date du calendar au format %d/%m/%Y
|
# Formatage de la date du calendar au format %d/%m/%Y
|
||||||
|
|
@ -800,16 +795,15 @@ class MesCigares:
|
||||||
start = textbuffer.get_start_iter()
|
start = textbuffer.get_start_iter()
|
||||||
end = textbuffer.get_end_iter()
|
end = textbuffer.get_end_iter()
|
||||||
# On récupère le commentaire et on échape les quote pour l'insert SQL
|
# On récupère le commentaire et on échape les quote pour l'insert SQL
|
||||||
textlines = textbuffer.get_text(start, end, include_hidden_chars=False).replace("'","''")
|
textlines = textbuffer.get_text(start, end, include_hidden_chars=False).replace("'", "''")
|
||||||
|
|
||||||
index = self.cbchoixcigare.get_active()
|
index = self.cbchoixcigare.get_active()
|
||||||
itemchoixcig = self.tablechoixcigare[index]
|
itemchoixcig = self.tablechoixcigare[index]
|
||||||
|
|
||||||
note = int(self.scaleq1.get_value()) + int(self.scaleq2.get_value())+int(self.scaleq3.get_value())+int(self.scaleq4.get_value())+int(self.scaleq5.get_value())+int(self.scaleq6.get_value())+int(self.scaleq7.get_value())+int(self.scaleq8.get_value())+int(self.scaleq9.get_value())+int(self.scaleq10.get_value())+int(self.scaleq11.get_value())+int(self.scaleq12.get_value())+int(self.scaleq13.get_value())
|
note = int(self.scaleq1.get_value()) + int(self.scaleq2.get_value()) + int(self.scaleq3.get_value()) + int(self.scaleq4.get_value()) + int(self.scaleq5.get_value()) + int(self.scaleq6.get_value()) + int(self.scaleq7.get_value()) + int(self.scaleq8.get_value()) + int(self.scaleq9.get_value()) + int(self.scaleq10.get_value()) + int(self.scaleq11.get_value()) + int(self.scaleq12.get_value()) + int(self.scaleq13.get_value())
|
||||||
|
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("insert into degustation (id_cigare,date,commentaires,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,note) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}')".format(itemchoixcig[0],DateDegustation ,textlines,int(self.scaleq1.get_value()),int(self.scaleq2.get_value()),int(self.scaleq3.get_value()),int(self.scaleq4.get_value()),int(self.scaleq5.get_value()),int(self.scaleq6.get_value()),int(self.scaleq7.get_value()),int(self.scaleq8.get_value()),int(self.scaleq9.get_value()),int(self.scaleq10.get_value()),int(self.scaleq11.get_value()),int(self.scaleq12.get_value()),int(self.scaleq13.get_value()),note))
|
cursor.execute("insert into degustation (id_cigare,date,commentaires,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,note) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}')".format(itemchoixcig[0], DateDegustation, textlines, int(self.scaleq1.get_value()), int(self.scaleq2.get_value()), int(self.scaleq3.get_value()), int(self.scaleq4.get_value()), int(self.scaleq5.get_value()), int(self.scaleq6.get_value()), int(self.scaleq7.get_value()), int(self.scaleq8.get_value()), int(self.scaleq9.get_value()), int(self.scaleq10.get_value()), int(self.scaleq11.get_value()), int(self.scaleq12.get_value()), int(self.scaleq13.get_value()), note))
|
||||||
# - 1 sur le stock
|
# - 1 sur le stock
|
||||||
cursor.execute("update stocks set quantite = quantite - 1 where id = {0}".format(itemchoixcig[0]))
|
cursor.execute("update stocks set quantite = quantite - 1 where id = {0}".format(itemchoixcig[0]))
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
@ -849,7 +843,7 @@ class MesCigares:
|
||||||
# Affichage de l'assistant d'aide pour la documentation
|
# Affichage de l'assistant d'aide pour la documentation
|
||||||
def on_gtk_how_to_activate(self, widget):
|
def on_gtk_how_to_activate(self, widget):
|
||||||
self.doc.show()
|
self.doc.show()
|
||||||
#self.doc.hide()
|
# self.doc.hide()
|
||||||
|
|
||||||
def on_lbl_intro_activate_link(self, widget):
|
def on_lbl_intro_activate_link(self, widget):
|
||||||
self.doc.set_forward_page_func(page_func=None, data=None)
|
self.doc.set_forward_page_func(page_func=None, data=None)
|
||||||
|
|
@ -870,7 +864,7 @@ class MesCigares:
|
||||||
start = textbuffer.get_start_iter()
|
start = textbuffer.get_start_iter()
|
||||||
end = textbuffer.get_end_iter()
|
end = textbuffer.get_end_iter()
|
||||||
# On récupère le commentaire et on échape les quote pour l'insert SQL
|
# On récupère le commentaire et on échape les quote pour l'insert SQL
|
||||||
textlines = textbuffer.get_text(start, end, include_hidden_chars=False).replace("'","''")
|
textlines = textbuffer.get_text(start, end, include_hidden_chars=False).replace("'", "''")
|
||||||
|
|
||||||
# On ajoute en base de données
|
# On ajoute en base de données
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
|
@ -891,12 +885,11 @@ class MesCigares:
|
||||||
if pthinfo is not None:
|
if pthinfo is not None:
|
||||||
path, col, cellx, celly = pthinfo
|
path, col, cellx, celly = pthinfo
|
||||||
self.treeview_wishes.grab_focus()
|
self.treeview_wishes.grab_focus()
|
||||||
self.treeview_wishes.set_cursor( path, col, 0)
|
self.treeview_wishes.set_cursor(path, col, 0)
|
||||||
# On affiche le popup
|
# On affiche le popup
|
||||||
self.popup_test.show_all();
|
self.popup_test.show_all()
|
||||||
self.popup_test.popup(None, None, None, None, event.button, event.time)
|
self.popup_test.popup(None, None, None, None, event.button, event.time)
|
||||||
|
|
||||||
|
|
||||||
# Ouvrir l'url dans le navigateur au clic droit sur une ligne de la treeview des cigares à tester
|
# Ouvrir l'url dans le navigateur au clic droit sur une ligne de la treeview des cigares à tester
|
||||||
def on_gtk_copier_test_activate(self, widget):
|
def on_gtk_copier_test_activate(self, widget):
|
||||||
try:
|
try:
|
||||||
|
|
@ -911,12 +904,12 @@ class MesCigares:
|
||||||
if iter is not None:
|
if iter is not None:
|
||||||
url = model.get_value(iter, 3)
|
url = model.get_value(iter, 3)
|
||||||
if not urlparse(url).scheme:
|
if not urlparse(url).scheme:
|
||||||
url = "http://"+url
|
url = "http://" + url
|
||||||
# On copie dans le presse papier
|
# On copie dans le presse papier
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
|
|
||||||
# Pour supprimer au clic droit
|
# Pour supprimer au clic droit
|
||||||
def on_gtk_supprimer_activate(self,widget):
|
def on_gtk_supprimer_activate(self, widget):
|
||||||
id_supp = self.treeview_selection[5]
|
id_supp = self.treeview_selection[5]
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
sql = "delete from cigares where id = {0}".format(id_supp)
|
sql = "delete from cigares where id = {0}".format(id_supp)
|
||||||
|
|
@ -937,7 +930,7 @@ class MesCigares:
|
||||||
self.loadtreeview()
|
self.loadtreeview()
|
||||||
|
|
||||||
# Pour supprimer un cigare à tester au clic droit
|
# Pour supprimer un cigare à tester au clic droit
|
||||||
def on_gtk_supprimer_test_activate(self,widget):
|
def on_gtk_supprimer_test_activate(self, widget):
|
||||||
selection = self.treeview_wishes.get_selection()
|
selection = self.treeview_wishes.get_selection()
|
||||||
(model, iter) = selection.get_selected()
|
(model, iter) = selection.get_selected()
|
||||||
if iter is not None:
|
if iter is not None:
|
||||||
|
|
@ -970,6 +963,7 @@ class MesCigares:
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
# Filtrer au changement sur entry_search
|
# Filtrer au changement sur entry_search
|
||||||
|
|
||||||
def on_entry_search_changed(self, data=None):
|
def on_entry_search_changed(self, data=None):
|
||||||
self.tree_filter.refilter()
|
self.tree_filter.refilter()
|
||||||
|
|
||||||
|
|
@ -1034,7 +1028,6 @@ class MesCigares:
|
||||||
self.filechooser_image = self.builder.get_object("filechooser_image")
|
self.filechooser_image = self.builder.get_object("filechooser_image")
|
||||||
self.filechooser_bdd = self.builder.get_object("filechooser_bdd")
|
self.filechooser_bdd = self.builder.get_object("filechooser_bdd")
|
||||||
|
|
||||||
|
|
||||||
# Fenêtre d'ajout d'une marque
|
# Fenêtre d'ajout d'une marque
|
||||||
self.entry_marque = self.builder.get_object("entry_marque")
|
self.entry_marque = self.builder.get_object("entry_marque")
|
||||||
self.entry_provenance = self.builder.get_object("entry_provenance")
|
self.entry_provenance = self.builder.get_object("entry_provenance")
|
||||||
|
|
@ -1116,7 +1109,7 @@ class MesCigares:
|
||||||
self.editable_cell_qte = gtk.CellRendererText()
|
self.editable_cell_qte = gtk.CellRendererText()
|
||||||
self.invisible_cell = gtk.CellRendererText()
|
self.invisible_cell = gtk.CellRendererText()
|
||||||
|
|
||||||
self.editable_cell_nom.connect('edited', self.cell_edited_callback,0)
|
self.editable_cell_nom.connect('edited', self.cell_edited_callback, 0)
|
||||||
self.editable_cell_nom.set_property('editable', True)
|
self.editable_cell_nom.set_property('editable', True)
|
||||||
|
|
||||||
self.col_nom = gtk.TreeViewColumn('Nom', self.editable_cell_nom, text=0, background=11)
|
self.col_nom = gtk.TreeViewColumn('Nom', self.editable_cell_nom, text=0, background=11)
|
||||||
|
|
@ -1133,22 +1126,22 @@ class MesCigares:
|
||||||
self.col_marque.set_sort_column_id(1)
|
self.col_marque.set_sort_column_id(1)
|
||||||
self.tree.append_column(self.col_marque)
|
self.tree.append_column(self.col_marque)
|
||||||
|
|
||||||
self.col_module= gtk.TreeViewColumn('Module', self.no_editable_cell, text=2, background=11)
|
self.col_module = gtk.TreeViewColumn('Module', self.no_editable_cell, text=2, background=11)
|
||||||
self.col_module.set_sort_column_id(2)
|
self.col_module.set_sort_column_id(2)
|
||||||
self.tree.append_column(self.col_module)
|
self.tree.append_column(self.col_module)
|
||||||
|
|
||||||
self.col_provenance= gtk.TreeViewColumn('Terroir', self.no_editable_cell, text=3, background=11)
|
self.col_provenance = gtk.TreeViewColumn('Terroir', self.no_editable_cell, text=3, background=11)
|
||||||
self.col_provenance.set_sort_column_id(3)
|
self.col_provenance.set_sort_column_id(3)
|
||||||
self.tree.append_column(self.col_provenance)
|
self.tree.append_column(self.col_provenance)
|
||||||
|
|
||||||
self.editable_cell_qte.connect('edited', self.cell_edited_callback,4)
|
self.editable_cell_qte.connect('edited', self.cell_edited_callback, 4)
|
||||||
self.editable_cell_qte.set_property('editable', True)
|
self.editable_cell_qte.set_property('editable', True)
|
||||||
self.col_qte = gtk.TreeViewColumn('Quantité', self.editable_cell_qte, text=4, background=11)
|
self.col_qte = gtk.TreeViewColumn('Quantité', self.editable_cell_qte, text=4, background=11)
|
||||||
self.col_qte.set_sort_column_id(4)
|
self.col_qte.set_sort_column_id(4)
|
||||||
self.tree.append_column(self.col_qte)
|
self.tree.append_column(self.col_qte)
|
||||||
|
|
||||||
# colonne invisible pour l'id_cigare
|
# colonne invisible pour l'id_cigare
|
||||||
self.invisible_cell.set_property('visible',False)
|
self.invisible_cell.set_property('visible', False)
|
||||||
self.col_id = gtk.TreeViewColumn('id', self.invisible_cell, text=5, background=11)
|
self.col_id = gtk.TreeViewColumn('id', self.invisible_cell, text=5, background=11)
|
||||||
self.col_id.set_sort_column_id(5)
|
self.col_id.set_sort_column_id(5)
|
||||||
|
|
||||||
|
|
@ -1196,6 +1189,8 @@ class MesCigares:
|
||||||
self.loadtreeview()
|
self.loadtreeview()
|
||||||
|
|
||||||
# Vérifier qu'il s'agit d'un nombre
|
# Vérifier qu'il s'agit d'un nombre
|
||||||
|
|
||||||
|
|
||||||
def is_number(s):
|
def is_number(s):
|
||||||
try:
|
try:
|
||||||
float(s)
|
float(s)
|
||||||
|
|
@ -1203,6 +1198,7 @@ def is_number(s):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def createdb(new_bdd):
|
def createdb(new_bdd):
|
||||||
db = sqlite3.connect(new_bdd)
|
db = sqlite3.connect(new_bdd)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
|
@ -1459,6 +1455,7 @@ def createdb(new_bdd):
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
def checkconfig():
|
def checkconfig():
|
||||||
"""Récupérer la configuration ou la créer"""
|
"""Récupérer la configuration ou la créer"""
|
||||||
# Fichier de configuration
|
# Fichier de configuration
|
||||||
|
|
@ -1467,8 +1464,8 @@ def checkconfig():
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
try:
|
try:
|
||||||
config.read(__CONFIGFILE__)
|
config.read(__CONFIGFILE__)
|
||||||
if config.has_option('MesCigares','bdd'):
|
if config.has_option('MesCigares', 'bdd'):
|
||||||
bdd = config.get('MesCigares','bdd')
|
bdd = config.get('MesCigares', 'bdd')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -1476,14 +1473,14 @@ def checkconfig():
|
||||||
createdb(bdd)
|
createdb(bdd)
|
||||||
|
|
||||||
# Si aucune conf
|
# Si aucune conf
|
||||||
if not(config.has_option('MesCigares','bdd')):
|
if not(config.has_option('MesCigares', 'bdd')):
|
||||||
bdd = __CONFDIR__ + "/bdd/main.db"
|
bdd = __CONFDIR__ + "/bdd/main.db"
|
||||||
# écrire le fichier de conf avec les informations par defaut
|
# écrire le fichier de conf avec les informations par defaut
|
||||||
try:
|
try:
|
||||||
cfgfile = open(__CONFIGFILE__,'w')
|
cfgfile = open(__CONFIGFILE__, 'w')
|
||||||
if not(config.has_section('MesCigares')):
|
if not(config.has_section('MesCigares')):
|
||||||
config.add_section('MesCigares')
|
config.add_section('MesCigares')
|
||||||
config.set('MesCigares','bdd',bdd)
|
config.set('MesCigares', 'bdd', bdd)
|
||||||
config.write(cfgfile)
|
config.write(cfgfile)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
@ -1492,14 +1489,15 @@ def checkconfig():
|
||||||
createdb(bdd)
|
createdb(bdd)
|
||||||
return(bdd)
|
return(bdd)
|
||||||
|
|
||||||
|
|
||||||
def setconfig(new_bdd):
|
def setconfig(new_bdd):
|
||||||
"""Mettre à jour la configuration"""
|
"""Mettre à jour la configuration"""
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
try:
|
try:
|
||||||
cfgfile = open(__CONFIGFILE__,'w')
|
cfgfile = open(__CONFIGFILE__, 'w')
|
||||||
if not(config.has_section('MesCigares')):
|
if not(config.has_section('MesCigares')):
|
||||||
config.add_section('MesCigares')
|
config.add_section('MesCigares')
|
||||||
config.set('MesCigares','bdd',new_bdd)
|
config.set('MesCigares', 'bdd', new_bdd)
|
||||||
config.write(cfgfile)
|
config.write(cfgfile)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
@ -1510,5 +1508,5 @@ if __name__ == "__main__":
|
||||||
dbconf = checkconfig()
|
dbconf = checkconfig()
|
||||||
db = sqlite3.connect(dbconf)
|
db = sqlite3.connect(dbconf)
|
||||||
main = MesCigares()
|
main = MesCigares()
|
||||||
main.window.set_title("MesCigares - base : {0}".format(ntpath.basename(dbconf)).replace('.db',''))
|
main.window.set_title("MesCigares - base : {0}".format(ntpath.basename(dbconf)).replace('.db', ''))
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
[MesCigares]
|
[MesCigares]
|
||||||
bdd = /home/jlaunay/git/Cigares/app_gestion/MesCigares/bdd/jerome.db
|
bdd = /home/jlaunay/git/Cigares/app_gestion/bdd/jerome.db
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue