-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfiguration_langues.py
More file actions
165 lines (144 loc) · 5.36 KB
/
configuration_langues.py
File metadata and controls
165 lines (144 loc) · 5.36 KB
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
# -*- coding:utf-8 -*-
#
# Copyright © 2020 cGIfl300
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the “Software”),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import gettext
from tkinter import *
from peewee import *
from db_model import *
fr = gettext.translation(
"base",
localedir=repertoire_script + "locales",
languages=[langue_appli],
fallback=False,
)
fr.install()
_ = fr.gettext
ngettext = fr.ngettext
class Configuration_Langues(Toplevel):
"""Interface graphique configuration des langues.
Ce module permet de configurer les langues de pyBible.
ENG = Anglais; FRA = Français... en fonction des Bibles présentes dans la base de donnée.
"""
def __init__(self, debug=False):
Toplevel.__init__(self)
self.debug = debug
def interface(self):
"""Interface de la fenêtre"""
self.title(_("pyBible - Editeur de langues"))
self.geometry("300x400")
self.panel0 = Canvas(self, bg=couleur_fond)
self.panel1 = Canvas(self, bg=couleur_fond)
self.liste_langue()
self.WDG_Langues = []
self.SCROLL_LST = Scrollbar(self, orient=VERTICAL)
self.LSTLangues = Listbox(
self.panel0,
selectmode=SINGLE,
bg=couleur_fond_saisie,
fg=couleur_texte_saisie,
yscrollcommand=self.SCROLL_LST.set,
)
self.SCROLL_LST.config(command=self.LSTLangues.yview)
self.LBL_Langue = Label(
self.panel1,
bg=couleur_fond,
fg=couleur_texte,
text=_("Veuillez sélectionner une langue"),
)
self.ENT_Description = Entry(
self.panel1, bg=couleur_fond_saisie, fg=couleur_texte_saisie
)
self.BTN_Valider = Button(
self.panel1,
bg=couleur_fond_saisie,
fg=couleur_texte_saisie,
text=_("Modifier"),
command=self.do_ModifierLangue,
)
"""
Mise en place des callbacks
"""
self.LSTLangues.bind("<<ListboxSelect>>", self.do_ListeSelect)
self.do_feed_list()
""" Implantation des composants.
"""
self.panel1.pack(fill=BOTH, side=BOTTOM, expand=True)
self.SCROLL_LST.pack(side=RIGHT, fill=Y)
self.panel0.pack(fill=BOTH, expand=True)
self.LSTLangues.pack(fill=BOTH, expand=True)
self.LBL_Langue.pack(fill=X, expand=True)
self.ENT_Description.pack(fill=X, expand=True)
self.BTN_Valider.pack(fill=X, expand=True)
def do_feed_list(self):
VAR_row = 0
for ligne in self.langue:
self.LSTLangues.insert(VAR_row, ligne[0])
VAR_row += 1
def liste_langue(self):
"""Retourne la liste des langues présentes dans la base de données.
self.langue[0][0] = FRE; self.langue[0][1] = Français
self.langue[1][0] = ENG; self.langue[1][1] = Anglais
...
"""
self.langue = []
for l in Langues.select():
if self.debug:
print(f"{l.langue} : {l.description}")
self.langue.append([l.langue, l.description])
def do_ListeSelect(self, event):
# Losqu'une langue est sélectionnée dans la liste
Code_Langue = self.LSTLangues.selection_get()
for ligne in self.langue:
if ligne[0] == Code_Langue:
Description_Langue = ligne[1]
pass
self.LBL_Langue.config(
text=_("Le code\n{}\nest attribué à la langue\n{}").format(
Code_Langue, Description_Langue
)
)
self.ENT_Description.delete(0, END)
self.ENT_Description.insert(0, Description_Langue)
def do_ModifierLangue(self):
"""
Modification de la description de langue
"""
Code_Langue = self.LSTLangues.selection_get()
Description_Langue = self.ENT_Description.get()
q = Langues.update({Langues.description: Description_Langue}).where(
Langues.langue == Code_Langue
)
q.execute()
self.LBL_Langue.config(
text=_("Le code\n{}\nest attribué à la langue\n{}").format(
Code_Langue, Description_Langue
)
)
self.liste_langue()
def run(self):
self.interface()
if __name__ == "__main__":
w = Tk()
w.after(30000, w.destroy)
w.wm_state("icon")
App = Configuration_Langues(debug=True)
App.run()
w.mainloop()