[Add] commit initial reprise du code

This commit is contained in:
Jérôme Launay 2015-12-11 13:11:48 +01:00
commit 405c164263
33 changed files with 10146 additions and 0 deletions

103
.gitignore vendored Normal file
View File

@ -0,0 +1,103 @@
#### joe made this: http://goel.io/joe
#####=== Python ===#####
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#####=== Vim ===#####
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
#####=== Emacs ===#####
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
# pas de zip
*.zip

1070
MesCigares/MesCigares.py Executable file

File diff suppressed because it is too large Load Diff

BIN
MesCigares/bdd/JEROME.db Normal file

Binary file not shown.

BIN
MesCigares/bdd/JEROME_KO.db Normal file

Binary file not shown.

BIN
MesCigares/bdd/main.db Normal file

Binary file not shown.

View File

@ -0,0 +1,3 @@
[MesCigares]
bdd = /home/jlaunay/Documents/Cigares/MesCigares/bdd/JEROME.db

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

2550
MesCigares/ui/ui.glade Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
[MesCigares]
bdd = /home/jlaunay/Documents/Cigares/app_gestion/MesCigares/bdd/jerome.db

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,329 @@
<?xml version="1.0" encoding="UTF-8"?>
<glade-interface>
<!-- interface-requires gtk+ 2.24 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem5">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="quit" swapped="no"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">4</property>
<property name="n_columns">4</property>
<child>
<widget class="GtkButton" id="input1">
<property name="label" translatable="yes">1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0.49000000953674316</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input2">
<property name="label" translatable="yes">2</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input3">
<property name="label" translatable="yes">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input4">
<property name="label" translatable="yes">4</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input5">
<property name="label" translatable="yes">5</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input6">
<property name="label" translatable="yes">6</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input7">
<property name="label" translatable="yes">7</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="input8">
<property name="label" translatable="yes">8</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input9">
<property name="label" translatable="yes">9</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="input0">
<property name="label" translatable="yes">0</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="enterValue" swapped="no"/>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="action_clear">
<property name="label" translatable="yes">C</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="clearCalc" swapped="no"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="action_calc">
<property name="label" translatable="yes">=</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="performAction" swapped="no"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="action_add">
<property name="label" translatable="yes">+</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="performAction" swapped="no"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="action_min">
<property name="label" translatable="yes">-</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="performAction" swapped="no"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="action_mul">
<property name="label" translatable="yes">*</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0.50999999046325684</property>
<signal name="clicked" handler="performAction" swapped="no"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="action_div">
<property name="label" translatable="yes">/</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="performAction" swapped="no"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -0,0 +1,79 @@
<?php
class Calc {
protected $glade;
protected $firstParam = null;
protected $operation = null;
function __construct($glade) {
$this->glade = $glade;
}
/* Calculer le résultat de l'opération */
protected function calculate($operation) {
$secondParam = (float) $this->glade->get_widget('entry1')->get_text();
$firstParam = (float) $this->firstParam;
$result = 0;
switch($this->operation) {
case '*':
$result = $firstParam * $secondParam;
break;
case '/':
$result = ($secondParam > 0 ? $firstParam / $secondParam : 0);
break;
case '+':
$result = $firstParam + $secondParam;
break;
case '-':
$result = $firstParam - $secondParam;
break;
}
$this->glade->get_widget('entry1')->set_text($result);
$this->firstParam = $result;
$this->operation = null;
}
/* Effectuer une opération */
public function performAction($obj) {
if ($this->firstParam == null) {
$this->firstParam = $this->glade->get_widget('entry1')->get_text();
$this->glade->get_widget('entry1')->set_text('');
}
if ($this->operation == null) {
$this->operation = str_replace(
array('action_mul', 'action_add', 'action_min', 'action_div'),
array('*', '+', '-', '/'),
$obj->name
);
$this->glade->get_widget('entry1')->set_text('');
} else {
$this->calculate($obj->name);
}
}
/* Ajout du caractère à la valeur courante de la zone d'entrée */
public function enterValue($obj) {
/* Puisque nous avons les noms des boutons Input0 .. input1, vous devez couper le "input" et obtenir la valeur */
/* Je sais que c'est stupide, mais la tâche n'est pas d'écrire des articles pour l'algorithme de calcul) */
$this->glade->get_widget('entry1')->set_text(
$this->glade->get_widget('entry1')->get_text().
str_replace('input', '', $obj->name)
);
}
/* Effacer le champ d'entrée, et la valeur de la première variable, et l'opération étant exécutée */
public function clearCalc($obj) {
$this->firstParam = null;
$this->operation = null;
$this->glade->get_widget('entry1')->set_text('');
}
/* quitter */
public function quit() {
exit;
}
}
/* Загрузить файл интефейса */
$glade = new GladeXML('calc.glade');
/* Указать, что все обработчики событий в классе Calc */
$glade->signal_autoconnect_instance(new Calc($glade));
/* При закрытии окна закрывать приложение */
$glade->get_widget('window1')->connect_simple('destroy', array('Gtk', 'main_quit'));
/* Инициализация GTK приложения */
Gtk::main();

156
app_tarif/pyperclip.py Normal file
View File

@ -0,0 +1,156 @@
# Pyperclip v1.3
# A cross-platform clipboard module for Python. (only handles plain text for now)
# By Al Sweigart al@coffeeghost.net
# Usage:
# import pyperclip
# pyperclip.copy('The text to be copied to the clipboard.')
# spam = pyperclip.paste()
# On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os.
# On Linux, this module makes use of the xclip command, which should come with the os. Otherwise run "sudo apt-get install xclip"
# Copyright (c) 2010, Albert Sweigart
# All rights reserved.
#
# BSD-style license:
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the pyperclip nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY Albert Sweigart "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL Albert Sweigart BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Change Log:
# 1.2 Use the platform module to help determine OS.
# 1.3 Changed ctypes.windll.user32.OpenClipboard(None) to ctypes.windll.user32.OpenClipboard(0), after some people ran into some TypeError
import platform, os
def winGetClipboard():
ctypes.windll.user32.OpenClipboard(0)
pcontents = ctypes.windll.user32.GetClipboardData(1) # 1 is CF_TEXT
data = ctypes.c_char_p(pcontents).value
#ctypes.windll.kernel32.GlobalUnlock(pcontents)
ctypes.windll.user32.CloseClipboard()
return data
def winSetClipboard(text):
GMEM_DDESHARE = 0x2000
ctypes.windll.user32.OpenClipboard(0)
ctypes.windll.user32.EmptyClipboard()
try:
# works on Python 2 (bytes() only takes one argument)
hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text))+1)
except TypeError:
# works on Python 3 (bytes() requires an encoding)
hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text, 'ascii'))+1)
pchData = ctypes.windll.kernel32.GlobalLock(hCd)
try:
# works on Python 2 (bytes() only takes one argument)
ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text))
except TypeError:
# works on Python 3 (bytes() requires an encoding)
ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text, 'ascii'))
ctypes.windll.kernel32.GlobalUnlock(hCd)
ctypes.windll.user32.SetClipboardData(1,hCd)
ctypes.windll.user32.CloseClipboard()
def macSetClipboard(text):
outf = os.popen('pbcopy', 'w')
outf.write(text)
outf.close()
def macGetClipboard():
outf = os.popen('pbpaste', 'r')
content = outf.read()
outf.close()
return content
def gtkGetClipboard():
return gtk.Clipboard().wait_for_text()
def gtkSetClipboard(text):
cb = gtk.Clipboard()
cb.set_text(text)
cb.store()
def qtGetClipboard():
return str(cb.text())
def qtSetClipboard(text):
cb.setText(text)
def xclipSetClipboard(text):
outf = os.popen('xclip -selection c', 'w')
outf.write(text)
outf.close()
def xclipGetClipboard():
outf = os.popen('xclip -selection c -o', 'r')
content = outf.read()
outf.close()
return content
def xselSetClipboard(text):
outf = os.popen('xsel -i', 'w')
outf.write(text)
outf.close()
def xselGetClipboard():
outf = os.popen('xsel -o', 'r')
content = outf.read()
outf.close()
return content
if os.name == 'nt' or platform.system() == 'Windows':
import ctypes
getcb = winGetClipboard
setcb = winSetClipboard
elif os.name == 'mac' or platform.system() == 'Darwin':
getcb = macGetClipboard
setcb = macSetClipboard
elif os.name == 'posix' or platform.system() == 'Linux':
xclipExists = os.system('which xclip') == 0
if xclipExists:
getcb = xclipGetClipboard
setcb = xclipSetClipboard
else:
xselExists = os.system('which xsel') == 0
if xselExists:
getcb = xselGetClipboard
setcb = xselSetClipboard
try:
import gtk
getcb = gtkGetClipboard
setcb = gtkSetClipboard
except:
try:
import PyQt4.QtCore
import PyQt4.QtGui
app = QApplication([])
cb = PyQt4.QtGui.QApplication.clipboard()
getcb = qtGetClipboard
setcb = qtSetClipboard
except:
raise Exception('Pyperclip requires the gtk or PyQt4 module installed, or the xclip command.')
copy = setcb
paste = getcb

BIN
app_tarif/tarifs.db Normal file

Binary file not shown.

151
app_tarif/tarifs.py Executable file
View File

@ -0,0 +1,151 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable-msg=C0103
import sys
import sqlite3
try:
from gi.repository import Gtk as gtk
except:
print('GTK not available')
sys.exit(1)
class TarifCig:
def on_window1_destroy(self, object, data=None):
#print("quitter depuis croix")
gtk.main_quit()
def on_gtk_quit_activate(self, menuitem, data=None):
#print("quitter depuis menu")
gtk.main_quit()
def on_gtk_about_activate(self, menuitem, data=None):
#print("about selectionne")
self.response = self.aboutdialog.run()
self.aboutdialog.hide()
def on_gtk_search_activate(self, menuitem, data=None):
#print("lancement de la recherche")
self.response = self.dialogSearch.run()
self.dialogSearch.hide()
def on_btcancel_clicked(self, object, data=None):
print("clic sur annuler")
def on_btsearch_clicked(self, object, data=None):
#print("recherche: " + self.search.get_text())
self.label1.set_text("Recherche : " + self.search.get_text())
# On commence par vider le liststore (2è recherche)
if len(self.table) != 0:
self.table.clear()
db = sqlite3.connect("tarifs.db")
cursor = db.cursor()
cursor.execute('select * from mars2013 where nom like "%{0}%"'.format( self.search.get_text()))
db.commit()
rs = cursor.fetchall()
ct = 0
for item in rs:
ct += 1
iter = self.table.append()
#self.table.set(iter, 0, item[0], 1, item[1] + " €" if item[1] != '' else '', 2, item[2] + " €" if item[2] != '' else '')
self.table.set(iter, 0, item[0], 1, item[1], 2, item[2])
#print( item)
#self.table.append([item[0], item[1], item[2]])
cursor.close()
# On affiche le nombre de résultats trouvés par la requête
if ct == 0:
self.statusbar.push(self.context_id, "Aucun résultat trouvé")
else:
self.statusbar.push(self.context_id, str(ct) + " résultats trouvés")
def on_treeview1_row_activated(self, widget, position, column):
selection = self.tree.get_selection()
(model, iter) = selection.get_selected()
self.valeur.clear()
self.valeur.append(model.get_value(iter, 0))
self.valeur.append(model.get_value(iter, 1))
self.valeur.append(model.get_value(iter, 2))
def on_treeview1_button_press_event(self, treeview, event):
x = int(event.x)
y = int(event.y)
if event.button == 3: # Clic droit
pthinfo = self.tree.get_path_at_pos(x, y)
if pthinfo is not None:
path, col, cellx, celly = pthinfo
self.tree.grab_focus()
self.tree.set_cursor( path, col, 0)
self.popup.show_all();
self.popup.popup(None, None, None, None, event.button, event.time)
def on_copier_activate(self, menuitem, data=None):
try:
import pyperclip
except:
print('pyperclip not available')
return False
selection = self.tree.get_selection()
(model, iter) = selection.get_selected()
# On copie dans le presse papier
pyperclip.copy(model.get_value(iter, 0) + ';' + model.get_value(iter, 1) + ';' + model.get_value(iter, 2))
def cell_edited_callback(self, cellule, path, new_text,col, model=None):
iter = self.table.get_iter(path)
self.table.set_value(iter, 0, new_text)
self.update_db(tuple(self.valeur),tuple(self.table[path]))
def update_db(self, old_value, new_value):
db = sqlite3.connect("tarifs.db")
cursor = db.cursor()
cursor.execute('update mars2013 set Nom = "{0}", Prix_Unite = "{1}", Prix_Conditionne = "{2}" where Nom = "{3}" and Prix_Unite = "{4}" and Prix_Conditionne = "{5}"'.format(new_value[0],new_value[1],new_value[2],old_value[0],old_value[1],old_value[2]))
db.commit()
cursor.close()
def __init__(self):
self.gladefile = "ui.glade"
self.builder = gtk.Builder()
self.builder.add_from_file(self.gladefile)
self.builder.connect_signals(self)
self.window = self.builder.get_object("window1")
self.aboutdialog = self.builder.get_object("aboutdialog1")
self.dialogSearch = self.builder.get_object("dialogSearch")
self.label1 = self.builder.get_object("label1")
self.search = self.builder.get_object("entry1")
self.statusbar = self.builder.get_object("statusbar1")
self.context_id = self.statusbar.get_context_id("exemple")
self.actions = self.builder.get_object("actiongroup1")
self.popup = self.builder.get_object("popup")
self.table = self.builder.get_object("liststore1")
self.valeur = []
# Constuire l'entête du treeview
self.cell = gtk.CellRendererText()
self.cell2 = gtk.CellRendererText()
self.cell3 = gtk.CellRendererText()
self.cell.connect('edited', self.cell_edited_callback, 1)
self.cell2.connect('edited', self.cell_edited_callback, 2)
self.cell3.connect('edited', self.cell_edited_callback, 3)
self.cell.set_property('editable', True)
self.cell2.set_property('editable', True)
self.cell3.set_property('editable', True)
self.tree = self.builder.get_object("treeview1")
self.column1 = gtk.TreeViewColumn('Nom', self.cell, text=0)
self.column1.set_sort_column_id(0)
self.tree.append_column(self.column1)
self.column2 = gtk.TreeViewColumn('Prix unitaire', self.cell2, text=1)
self.column2.set_sort_column_id(1)
self.tree.append_column(self.column2)
self.column3 = gtk.TreeViewColumn('Prix conditionné', self.cell3, text=2)
self.column3.set_sort_column_id(2)
self.tree.append_column(self.column3)
self.window.show_all()
if __name__ == "__main__":
main = TarifCig()
gtk.main()

330
app_tarif/ui.glade Normal file
View File

@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.6 -->
<object class="GtkActionGroup" id="actiongroup1">
<child>
<object class="GtkAction" id="copier">
<property name="stock_id">gtk-copy</property>
<signal name="activate" handler="on_copier_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkAction" id="quitter">
<property name="stock_id">gtk-quit</property>
<signal name="activate" handler="on_gtk_quit_activate" swapped="no"/>
</object>
</child>
</object>
<object class="GtkAboutDialog" id="aboutdialog1">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<property name="program_name">Tarifs Cigares</property>
<property name="version">O.3</property>
<property name="copyright" translatable="yes">Copyright © Jérôme Launay</property>
<property name="comments" translatable="yes">Tarifs d'Avril 2013</property>
<property name="website">www.projet-libre.org</property>
<property name="website_label" translatable="yes">www.projet-libre.org</property>
<property name="license" translatable="yes">WTFPL</property>
<child internal-child="vbox">
<object class="GtkBox" id="aboutdialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="aboutdialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkDialog" id="dialogSearch">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type">popup</property>
<property name="title" translatable="yes">Recherche d'un cigare</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">normal</property>
<property name="transient_for">window1</property>
<property name="has_resize_grip">False</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="btcancel">
<property name="label" translatable="yes">Annuler</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_btcancel_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btsearch">
<property name="label" translatable="yes">Lancer la recherche</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<accelerator key="Return" signal="clicked"/>
<signal name="clicked" handler="on_btsearch_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Veuillez saisir votre recherche</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-3">btcancel</action-widget>
<action-widget response="0">btsearch</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name column1 -->
<column type="gchararray"/>
<!-- column-name column2 -->
<column type="gchararray"/>
<!-- column-name column3 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkMenu" id="popup">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkMenuItem" id="menuitem">
<property name="use_action_appearance">False</property>
<property name="related_action">copier</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Copier</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem2">
<property name="use_action_appearance">False</property>
<property name="related_action">quitter</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Quitter</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="window_position">center</property>
<property name="default_width">1100</property>
<property name="default_height">650</property>
<signal name="destroy" handler="on_window1_destroy" swapped="no"/>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Cigares</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="gtk_search">
<property name="label">gtk-find</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<accelerator key="s" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<signal name="activate" handler="on_gtk_search_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="gtk_quit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<accelerator key="q" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<signal name="activate" handler="on_gtk_quit_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Aid_e</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="gtk_about">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_gtk_about_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">liststore1</property>
<property name="enable_grid_lines">horizontal</property>
<property name="activate_on_single_click">True</property>
<signal name="button-press-event" handler="on_treeview1_button_press_event" swapped="no"/>
<signal name="row-activated" handler="on_treeview1_row_activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

BIN
photos/Cohiba-Siglo2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
photos/Quintero-Brevas.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

BIN
photos/macanudo_maduro.jpe Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
photos/upmann-majestic.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB