File packages/gui/category_chooser.py changed (mode: 100644) (index c5be3b4..3a7d7dc) |
... |
... |
from tkinter import messagebox as tmb |
7 |
7 |
from packages import color as clr |
from packages import color as clr |
8 |
8 |
from packages import item_upload |
from packages import item_upload |
9 |
9 |
|
|
|
10 |
|
|
10 |
11 |
class MarkingDropdown(tkinter.Frame): |
class MarkingDropdown(tkinter.Frame): |
11 |
12 |
def __init__(self, master, *args, **kwargs): |
def __init__(self, master, *args, **kwargs): |
12 |
13 |
tkinter.Frame.__init__(self, master, *args, **kwargs) |
tkinter.Frame.__init__(self, master, *args, **kwargs) |
|
... |
... |
class MarkingDropdown(tkinter.Frame): |
22 |
23 |
self.resultvar = tkinter.StringVar(self) |
self.resultvar = tkinter.StringVar(self) |
23 |
24 |
|
|
24 |
25 |
self.options = { |
self.options = { |
25 |
|
'Neu':'14', |
|
26 |
|
'Alt':'9', |
|
27 |
|
'Item im Upload Prozess':'28' |
|
|
26 |
|
'Neu': '14', |
|
27 |
|
'Alt': '9', |
|
28 |
|
'Item im Upload Prozess': '28' |
28 |
29 |
} |
} |
29 |
30 |
|
|
30 |
31 |
self.optionvar.set('marking') |
self.optionvar.set('marking') |
31 |
32 |
|
|
32 |
|
self.dropdown_menu = tkinter.OptionMenu(self, self.optionvar, *[ *self.options ]) |
|
|
33 |
|
self.dropdown_menu = tkinter.OptionMenu(self, self.optionvar, |
|
34 |
|
*[*self.options]) |
33 |
35 |
self.dropdown_menu.grid(row=1, column=0, sticky="EW", padx=50) |
self.dropdown_menu.grid(row=1, column=0, sticky="EW", padx=50) |
34 |
36 |
|
|
35 |
37 |
self.optionvar.trace('w', self.change_dropdown) |
self.optionvar.trace('w', self.change_dropdown) |
36 |
38 |
|
|
37 |
39 |
def change_dropdown(self, *args): |
def change_dropdown(self, *args): |
38 |
|
if(self.optionvar.get() and not( self.optionvar.get() == 'marking' )): |
|
39 |
|
self.resultvar = self.options[ self.optionvar.get() ] |
|
|
40 |
|
if(self.optionvar.get() and not(self.optionvar.get() == 'marking')): |
|
41 |
|
self.resultvar = self.options[self.optionvar.get()] |
|
42 |
|
|
40 |
43 |
|
|
41 |
44 |
class LabelBox(tkinter.Frame): |
class LabelBox(tkinter.Frame): |
42 |
45 |
def __init__(self, master, similar_names): |
def __init__(self, master, similar_names): |
|
... |
... |
class LabelBox(tkinter.Frame): |
52 |
55 |
for num, name in enumerate(self.similar_names): |
for num, name in enumerate(self.similar_names): |
53 |
56 |
rownum = num |
rownum = num |
54 |
57 |
columnnum = 1 |
columnnum = 1 |
55 |
|
if(num>15): |
|
|
58 |
|
if(num > 15): |
56 |
59 |
rownum = num - 16 |
rownum = num - 16 |
57 |
60 |
columnnum = 2 |
columnnum = 2 |
58 |
|
if(num>30): |
|
|
61 |
|
if(num > 30): |
59 |
62 |
rownum = num - 31 |
rownum = num - 31 |
60 |
63 |
columnnum = 3 |
columnnum = 3 |
61 |
|
if(num>45): |
|
|
64 |
|
if(num > 45): |
62 |
65 |
rownum = num - 46 |
rownum = num - 46 |
63 |
66 |
columnnum = 4 |
columnnum = 4 |
64 |
67 |
|
|
65 |
|
self.element.append( tkinter.Text(self, height=1, width=25) ) |
|
|
68 |
|
self.element.append(tkinter.Text(self, height=1, width=25)) |
66 |
69 |
self.element[num].insert(1.0, name) |
self.element[num].insert(1.0, name) |
67 |
|
self.element[num].configure(bg=self.master.master.cget('bg'), relief='flat') |
|
|
70 |
|
self.element[num].configure(bg=self.master.master.cget('bg'), |
|
71 |
|
relief='flat') |
68 |
72 |
self.element[num].configure(state='disabled') |
self.element[num].configure(state='disabled') |
69 |
73 |
self.element[num].grid(row=rownum, column=columnnum, sticky='W') |
self.element[num].grid(row=rownum, column=columnnum, sticky='W') |
70 |
74 |
|
|
|
75 |
|
|
71 |
76 |
class DropdownBox(tkinter.Frame): |
class DropdownBox(tkinter.Frame): |
72 |
77 |
def __init__(self, master): |
def __init__(self, master): |
73 |
78 |
tkinter.Frame.__init__(self, master) |
tkinter.Frame.__init__(self, master) |
|
... |
... |
class DropdownBox(tkinter.Frame): |
79 |
84 |
def initialize(self): |
def initialize(self): |
80 |
85 |
self.grid() |
self.grid() |
81 |
86 |
|
|
82 |
|
self.dropdown = tkinter.OptionMenu(self, self.variable, *self.optionslist) |
|
|
87 |
|
self.dropdown = tkinter.OptionMenu(self, self.variable, |
|
88 |
|
*self.optionslist) |
83 |
89 |
self.dropdown.grid(row=1, column=1, sticky='EW') |
self.dropdown.grid(row=1, column=1, sticky='EW') |
84 |
90 |
|
|
85 |
91 |
|
|
|
... |
... |
class InfoBox(tkinter.Frame): |
99 |
105 |
self.optionvar.set("missing Colors") |
self.optionvar.set("missing Colors") |
100 |
106 |
|
|
101 |
107 |
# Dropdown Box with all the missing colors |
# Dropdown Box with all the missing colors |
102 |
|
self.dropdownbox = DropdownBox(self); |
|
|
108 |
|
self.dropdownbox = DropdownBox(self) |
103 |
109 |
self.dropdownbox.grid(row=1, column=1, columnspan=2, sticky="EW") |
self.dropdownbox.grid(row=1, column=1, columnspan=2, sticky="EW") |
104 |
110 |
|
|
105 |
111 |
self.optionvar.trace('w', self.change_dropdown) |
self.optionvar.trace('w', self.change_dropdown) |
|
... |
... |
class ButtonBox(tkinter.Frame): |
127 |
133 |
def initialize(self): |
def initialize(self): |
128 |
134 |
self.grid() |
self.grid() |
129 |
135 |
|
|
130 |
|
self.continue_button = tkinter.Button(self, text="Continue", command=lambda: self.master.destroy_warningbox()) |
|
|
136 |
|
self.continue_button = tkinter.Button(self, text="Continue", |
|
137 |
|
command=lambda: |
|
138 |
|
self.master.destroy_warningbox()) |
131 |
139 |
self.continue_button.grid(row=1, column=1, sticky='EW', padx=20) |
self.continue_button.grid(row=1, column=1, sticky='EW', padx=20) |
132 |
140 |
|
|
133 |
|
self.create_button = tkinter.Button(self, text="Create a Syncfile", command=lambda: self.master.create_syncfile()) |
|
|
141 |
|
self.create_button = tkinter.Button(self, text="Create a Syncfile", |
|
142 |
|
command=lambda: |
|
143 |
|
self.master.create_syncfile()) |
134 |
144 |
self.create_button.grid(row=1, column=2, sticky='EW', padx=20) |
self.create_button.grid(row=1, column=2, sticky='EW', padx=20) |
135 |
145 |
|
|
136 |
|
self.stop_button = tkinter.Button(self, text='Stop', command=lambda: self.master.destroy_root()) |
|
|
146 |
|
self.stop_button = tkinter.Button(self, text='Stop', |
|
147 |
|
command=lambda: |
|
148 |
|
self.master.destroy_root()) |
137 |
149 |
self.stop_button.grid(row=1, column=3, sticky='EW', padx=20) |
self.stop_button.grid(row=1, column=3, sticky='EW', padx=20) |
138 |
150 |
|
|
|
151 |
|
|
139 |
152 |
class WarningBox(tkinter.Frame): |
class WarningBox(tkinter.Frame): |
140 |
153 |
def __init__(self, master, colorlist, *args, **kwargs): |
def __init__(self, master, colorlist, *args, **kwargs): |
141 |
154 |
tkinter.Frame.__init__(self, master, *args, **kwargs) |
tkinter.Frame.__init__(self, master, *args, **kwargs) |
|
... |
... |
class WarningBox(tkinter.Frame): |
156 |
169 |
self.colorlist_length = len(self.colorlist) |
self.colorlist_length = len(self.colorlist) |
157 |
170 |
self.colorlist_string = self.create_colorstring(self.colorlist) |
self.colorlist_string = self.create_colorstring(self.colorlist) |
158 |
171 |
else: |
else: |
159 |
|
print("ERROR @ WarningBox: colorlist has the wrong type (needs to be a list)\n{0}".format(type(colorlist))) |
|
160 |
|
|
|
161 |
|
self.boxdesc = tkinter.Label(self, text="The flatfile contains colors that are not found in Plentymarkets.") |
|
162 |
|
self.boxdesc.grid(row=1,column=1,columnspan=4, sticky='NESW', pady=20, padx=20) |
|
163 |
|
|
|
164 |
|
self.warningmessage = tkinter.Label(self, text="Number of missing colors: " + str( self.colorlist_length ) + "\nColors: " + self.colorlist_string) |
|
165 |
|
self.warningmessage.grid(row=2,column=1,columnspan=4, sticky='NESW') |
|
|
172 |
|
print("ERROR @ WarningBox: colorlist needs to be a list\n{0}" |
|
173 |
|
.format(type(self.colorlist))) |
|
174 |
|
|
|
175 |
|
self.boxdesc = \ |
|
176 |
|
tkinter.Label(self, |
|
177 |
|
text="Flatfile colors not found in Plentymarkets.") |
|
178 |
|
self.boxdesc.grid(row=1, column=1, columnspan=4, |
|
179 |
|
sticky='NESW', pady=20, padx=20) |
|
180 |
|
|
|
181 |
|
self.warningmessage = tkinter.Label(self, |
|
182 |
|
text="Number of missing colors: " + |
|
183 |
|
str(self.colorlist_length) + |
|
184 |
|
"\nColors: " + |
|
185 |
|
self.colorlist_string) |
|
186 |
|
self.warningmessage.grid(row=2, column=1, |
|
187 |
|
columnspan=4, sticky='NESW') |
166 |
188 |
|
|
167 |
189 |
self.buttonbox = ButtonBox(master=self) |
self.buttonbox = ButtonBox(master=self) |
168 |
|
self.buttonbox.grid(row=3,column=1,columnspan=3, sticky='NESW', pady=20, padx=20) |
|
|
190 |
|
self.buttonbox.grid(row=3, column=1, columnspan=3, |
|
191 |
|
sticky='NESW', pady=20, padx=20) |
169 |
192 |
|
|
170 |
|
self.infobox = InfoBox(master=self, options=self.colorlist, colordict=self.colordict) |
|
171 |
|
self.infobox.grid(row=4, column=1, columnspan=3, sticky='NESW', pady=20, padx=20) |
|
|
193 |
|
self.infobox = InfoBox(master=self, options=self.colorlist, |
|
194 |
|
colordict=self.colordict) |
|
195 |
|
self.infobox.grid(row=4, column=1, columnspan=3, |
|
196 |
|
sticky='NESW', pady=20, padx=20) |
172 |
197 |
|
|
173 |
198 |
def create_syncfile(self): |
def create_syncfile(self): |
174 |
199 |
clr.create_attributesync(self.colordict, self.master.master.upath) |
clr.create_attributesync(self.colordict, self.master.master.upath) |
|
... |
... |
class WarningBox(tkinter.Frame): |
183 |
208 |
def create_colorstring(self, colorlist): |
def create_colorstring(self, colorlist): |
184 |
209 |
colorstring = '' |
colorstring = '' |
185 |
210 |
|
|
186 |
|
if(len(colorlist)>3): |
|
187 |
|
colorstring = ' , '.join(colorlist[0:3]) + '...' |
|
|
211 |
|
if(len(colorlist) > 3): |
|
212 |
|
colorstring = ' , '.join(colorlist[0:3]) + '...' |
188 |
213 |
else: |
else: |
189 |
|
colorstring = ' , '.join(colorlist) |
|
|
214 |
|
colorstring = ' , '.join(colorlist) |
190 |
215 |
|
|
191 |
216 |
return colorstring |
return colorstring |
192 |
217 |
|
|
|
218 |
|
|
193 |
219 |
class DropdownChooser(tkinter.Frame): |
class DropdownChooser(tkinter.Frame): |
194 |
220 |
def __init__(self, master, *args, **kwargs): |
def __init__(self, master, *args, **kwargs): |
195 |
221 |
tkinter.Frame.__init__(self, master, *args, **kwargs) |
tkinter.Frame.__init__(self, master, *args, **kwargs) |
|
... |
... |
class DropdownChooser(tkinter.Frame): |
205 |
231 |
self.activityvar = tkinter.StringVar(self) |
self.activityvar = tkinter.StringVar(self) |
206 |
232 |
self.resultvar = tkinter.StringVar(self) |
self.resultvar = tkinter.StringVar(self) |
207 |
233 |
|
|
208 |
|
self.options = {'Men.Aladinhose':'34', |
|
209 |
|
'Men.Sommerhose':'36', |
|
210 |
|
'Men.Stoffhose':'35', |
|
211 |
|
'Men.Shorts':'37', |
|
212 |
|
'Men.Fischerhose':'85', |
|
213 |
|
'Men.Hemden': '38', |
|
214 |
|
'Men.Tshirt' :'39', |
|
215 |
|
'Men.Hoodie' : '40', |
|
216 |
|
'Men.Jacken' :'41', |
|
217 |
|
'Women.Kleid' :'62', |
|
218 |
|
'Women.Tunika' :'63', |
|
219 |
|
'Women.Sarong-K' :'64', |
|
220 |
|
'Women.Skirt' :'87', |
|
221 |
|
'Women.Aladinhose' :'53', |
|
222 |
|
'Women.Stoffhose' :'70', |
|
223 |
|
'Women.Sommerhose' :'71', |
|
224 |
|
'Women.Hosenrock' :'72', |
|
225 |
|
'Women.Legging' :'73', |
|
226 |
|
'Women.Fischerhose' :'96', |
|
227 |
|
'Women.Top' :'65', |
|
228 |
|
'Women.Tshirt/Hemden' :'66', |
|
229 |
|
'Women.Hoodie' :'68', |
|
230 |
|
'Women.Sarong-O' :'69', |
|
231 |
|
'Women.Jacken' :'84', |
|
232 |
|
'Unisex.Bags' : '108' |
|
|
234 |
|
self.options = {'Men.Aladinhose': '34', |
|
235 |
|
'Men.Sommerhose': '36', |
|
236 |
|
'Men.Stoffhose': '35', |
|
237 |
|
'Men.Shorts': '37', |
|
238 |
|
'Men.Fischerhose': '85', |
|
239 |
|
'Men.Hemden': '38', |
|
240 |
|
'Men.Tshirt': '39', |
|
241 |
|
'Men.Hoodie': '40', |
|
242 |
|
'Men.Jacken': '41', |
|
243 |
|
'Women.Kleid': '62', |
|
244 |
|
'Women.Tunika': '63', |
|
245 |
|
'Women.Sarong-K': '64', |
|
246 |
|
'Women.Skirt': '87', |
|
247 |
|
'Women.Aladinhose': '53', |
|
248 |
|
'Women.Stoffhose': '70', |
|
249 |
|
'Women.Sommerhose': '71', |
|
250 |
|
'Women.Hosenrock': '72', |
|
251 |
|
'Women.Legging': '73', |
|
252 |
|
'Women.Fischerhose': '96', |
|
253 |
|
'Women.Top': '65', |
|
254 |
|
'Women.Tshirt/Hemden': '66', |
|
255 |
|
'Women.Hoodie': '68', |
|
256 |
|
'Women.Sarong-O': '69', |
|
257 |
|
'Women.Jacken': '84', |
|
258 |
|
'Unisex.Bags': '108' |
233 |
259 |
} |
} |
234 |
260 |
|
|
235 |
261 |
self.activities = { |
self.activities = { |
|
... |
... |
class DropdownChooser(tkinter.Frame): |
249 |
275 |
self.menu_header_major = tkinter.Label(self, text='Major category') |
self.menu_header_major = tkinter.Label(self, text='Major category') |
250 |
276 |
self.menu_header_major.grid(row=0, column=0, sticky='NESW') |
self.menu_header_major.grid(row=0, column=0, sticky='NESW') |
251 |
277 |
|
|
252 |
|
self.menu_header_activity = tkinter.Label(self, text='Activity category') |
|
|
278 |
|
self.menu_header_activity = tkinter.Label(self, |
|
279 |
|
text='Activity category') |
253 |
280 |
self.menu_header_activity.grid(row=0, column=1, sticky='NESW') |
self.menu_header_activity.grid(row=0, column=1, sticky='NESW') |
254 |
281 |
|
|
255 |
|
self.dropdown_menu = tkinter.OptionMenu(self, self.optionvar, *[ *self.options ]) |
|
|
282 |
|
self.dropdown_menu = tkinter.OptionMenu(self, self.optionvar, |
|
283 |
|
*[*self.options]) |
256 |
284 |
self.dropdown_menu.grid(row=1, column=0, sticky="EW", padx=50) |
self.dropdown_menu.grid(row=1, column=0, sticky="EW", padx=50) |
257 |
285 |
|
|
258 |
|
self.activity_menu = tkinter.OptionMenu(self, self.activityvar, *[ *self.activities ]) |
|
|
286 |
|
self.activity_menu = tkinter.OptionMenu(self, self.activityvar, |
|
287 |
|
*[*self.activities]) |
259 |
288 |
self.activity_menu.grid(row=1, column=1, sticky="EW", padx=50) |
self.activity_menu.grid(row=1, column=1, sticky="EW", padx=50) |
260 |
289 |
|
|
261 |
290 |
self.optionvar.trace('w', self.change_dropdown) |
self.optionvar.trace('w', self.change_dropdown) |
|
... |
... |
class DropdownChooser(tkinter.Frame): |
263 |
292 |
self.resultvar.trace('w', self.add_desc) |
self.resultvar.trace('w', self.add_desc) |
264 |
293 |
|
|
265 |
294 |
# Create a textbox to show the result of the choosing |
# Create a textbox to show the result of the choosing |
266 |
|
self.resultbox = tkinter.Entry(self, textvariable=self.resultvar, width=50, bg="white") |
|
267 |
|
self.resultbox.grid(row=2, column=0, columnspan=2, sticky="EW", padx=50) |
|
|
295 |
|
self.resultbox = tkinter.Entry(self, textvariable=self.resultvar, |
|
296 |
|
width=50, bg="white") |
|
297 |
|
self.resultbox.grid(row=2, column=0, columnspan=2, |
|
298 |
|
sticky="EW", padx=50) |
268 |
299 |
|
|
269 |
|
# Create a label with an info about the standard category which hides if the entry is empty |
|
270 |
|
self.category_info = tkinter.Label(self, text="The first category in the list will be used as standard category!") |
|
|
300 |
|
# Create a label with an info about the standard category |
|
301 |
|
# which hides if the entry is empty |
|
302 |
|
self.category_info =\ |
|
303 |
|
tkinter.Label(self, |
|
304 |
|
text="first entry used as standard category!") |
271 |
305 |
|
|
272 |
306 |
def change_dropdown(self, *args): |
def change_dropdown(self, *args): |
273 |
|
if( not( self.resultbox.get() ) ): |
|
274 |
|
if(not( self.activityvar.get() == 'activities' )): |
|
|
307 |
|
if(not(self.resultbox.get())): |
|
308 |
|
if(not(self.activityvar.get() == 'activities')): |
275 |
309 |
print(self.activityvar.get()) |
print(self.activityvar.get()) |
276 |
310 |
tmb.showerror("No Major category!", |
tmb.showerror("No Major category!", |
277 |
311 |
"Please enter first a major category, so that the first gets set as standard category. After that add a activity category!") |
"Please enter first a major category, so that the first gets set as standard category. After that add a activity category!") |
278 |
312 |
self.activityvar.set('activities') |
self.activityvar.set('activities') |
279 |
313 |
|
|
280 |
|
self. resultbox.insert(tkinter.INSERT, self.options[ self.optionvar.get() ] ) |
|
|
314 |
|
self. resultbox.insert(tkinter.INSERT, |
|
315 |
|
self.options[self.optionvar.get()]) |
281 |
316 |
else: |
else: |
282 |
|
if(self.optionvar.get() and not( re.search( self.options[ self.optionvar.get() ] ,self.resultbox.get()) ) ): |
|
283 |
|
self.resultbox.insert(tkinter.INSERT, ', ' + self.options[ self.optionvar.get() ] ) |
|
284 |
|
if(self.activityvar.get() and not( self.activityvar.get() == 'activities' )): |
|
285 |
|
if(not( re.search( self.activities[ self.activityvar.get() ] ,self.resultbox.get()) ) ): |
|
286 |
|
self.resultbox.insert(tkinter.INSERT, ', ' + self.activities[ self.activityvar.get() ] ) |
|
|
317 |
|
if(self.optionvar.get() and |
|
318 |
|
not(re.search(self.options[self.optionvar.get()], |
|
319 |
|
self.resultbox.get()))): |
|
320 |
|
self.resultbox.insert(tkinter.INSERT, ', ' + |
|
321 |
|
self.options[self.optionvar.get()]) |
|
322 |
|
if(self.activityvar.get() and |
|
323 |
|
not(self.activityvar.get() == 'activities')): |
|
324 |
|
if(not(re.search(self.activities[self.activityvar.get()], |
|
325 |
|
self.resultbox.get()))): |
|
326 |
|
self.resultbox.insert(tkinter.INSERT, ', ' + |
|
327 |
|
self.activities[self.activityvar. |
|
328 |
|
get()]) |
287 |
329 |
|
|
288 |
330 |
def add_desc(self, *args): |
def add_desc(self, *args): |
289 |
|
if(len(self.resultvar.get())>1): |
|
|
331 |
|
if(len(self.resultvar.get()) > 1): |
290 |
332 |
self.category_info.grid(row=3, columnspan=2, sticky="EW") |
self.category_info.grid(row=3, columnspan=2, sticky="EW") |
291 |
333 |
else: |
else: |
292 |
334 |
self.category_info.grid_remove() |
self.category_info.grid_remove() |
293 |
335 |
|
|
294 |
336 |
|
|
295 |
|
|
|
296 |
337 |
class DescBox(tkinter.Frame): |
class DescBox(tkinter.Frame): |
297 |
338 |
def __init__(self, master, desctext): |
def __init__(self, master, desctext): |
298 |
339 |
tkinter.Frame.__init__(self, master) |
tkinter.Frame.__init__(self, master) |
|
... |
... |
class DescBox(tkinter.Frame): |
304 |
345 |
self.grid() |
self.grid() |
305 |
346 |
|
|
306 |
347 |
self.desc_label = tkinter.Label(self, text=self.desctext) |
self.desc_label = tkinter.Label(self, text=self.desctext) |
307 |
|
self.desc_label.grid(rowspan=2,column=1, sticky="EW") |
|
|
348 |
|
self.desc_label.grid(rowspan=2, column=1, sticky="EW") |
308 |
349 |
|
|
309 |
350 |
|
|
310 |
351 |
class CategoryChooser(tkinter.Tk): |
class CategoryChooser(tkinter.Tk): |
|
... |
... |
class CategoryChooser(tkinter.Tk): |
315 |
356 |
self.flatfile = flatfile |
self.flatfile = flatfile |
316 |
357 |
self.atrpath = atrpath |
self.atrpath = atrpath |
317 |
358 |
self.atrdate = atrdate |
self.atrdate = atrdate |
318 |
|
self.newpath = {'upload-path':'', 'attribute-path':''} |
|
319 |
|
self.data = {'name':'', 'categories':'', 'marking':''} |
|
|
359 |
|
self.newpath = {'upload-path': '', 'attribute-path': ''} |
|
360 |
|
self.data = {'name': '', 'categories': '', 'marking': ''} |
320 |
361 |
self.protocol("WM_WINDOW_DELETE", self.close_app) |
self.protocol("WM_WINDOW_DELETE", self.close_app) |
321 |
362 |
self.missingcolors = {} |
self.missingcolors = {} |
322 |
363 |
# Window position properties |
# Window position properties |
|
... |
... |
class CategoryChooser(tkinter.Tk): |
330 |
371 |
self.positiondown = int(self.screen_h/3 - self.window_h) |
self.positiondown = int(self.screen_h/3 - self.window_h) |
331 |
372 |
# For single screen |
# For single screen |
332 |
373 |
else: |
else: |
333 |
|
self.positionright = int(self.winfo_screenwidth()/2 - self.window_w) |
|
334 |
|
self.positiondown = int(self.winfo_screenheight()/3 - self.window_h) |
|
|
374 |
|
self.positionright = int(self.winfo_screenwidth()/2 - |
|
375 |
|
self.window_w) |
|
376 |
|
self.positiondown = int(self.winfo_screenheight()/3 - |
|
377 |
|
self.window_h) |
335 |
378 |
# geometry of the window and build the elements of the gui |
# geometry of the window and build the elements of the gui |
336 |
379 |
self.geometry("+{}+{}".format(self.positionright, self.positiondown)) |
self.geometry("+{}+{}".format(self.positionright, self.positiondown)) |
337 |
380 |
self.initialize() |
self.initialize() |
|
... |
... |
class CategoryChooser(tkinter.Tk): |
342 |
385 |
if(self.atrpath['path']): |
if(self.atrpath['path']): |
343 |
386 |
self.check_colors(self.flatfile, self.atrpath) |
self.check_colors(self.flatfile, self.atrpath) |
344 |
387 |
|
|
345 |
|
self.pathdesc = DescBox(master=self, desctext="The current Upload path is: \n" + self.upath) |
|
|
388 |
|
self.pathdesc = DescBox(master=self, |
|
389 |
|
desctext="The current Upload path is: \n" + |
|
390 |
|
self.upath) |
346 |
391 |
self.pathdesc.grid(row=0, columnspan=3, pady=10, padx=10) |
self.pathdesc.grid(row=0, columnspan=3, pady=10, padx=10) |
347 |
392 |
|
|
348 |
|
self.attributedesc = DescBox(master=self, desctext="The current attribute file:\n" + self.atrpath['path'] + '\nUpload-date:\t' + self.atrdate) |
|
|
393 |
|
self.attributedesc = DescBox(master=self, |
|
394 |
|
desctext="The current attribute file:\n" + |
|
395 |
|
self.atrpath['path'] + |
|
396 |
|
'\nUpload-date:\t' + self.atrdate) |
349 |
397 |
self.attributedesc.grid(row=1, columnspan=3, pady=10, padx=10) |
self.attributedesc.grid(row=1, columnspan=3, pady=10, padx=10) |
350 |
398 |
|
|
351 |
|
self.changepathbutton = tkinter.Button(self, text="Choose a new path", command=lambda: self.get_new_path("Choose a new upload folder", 'upload')) |
|
|
399 |
|
self.changepathbutton =\ |
|
400 |
|
tkinter.Button(self, text="Choose a new path", |
|
401 |
|
command=lambda: |
|
402 |
|
self.get_new_path("Choose a new upload folder", |
|
403 |
|
'upload')) |
352 |
404 |
self.changepathbutton.grid(row=2, column=1, pady=10, padx=10) |
self.changepathbutton.grid(row=2, column=1, pady=10, padx=10) |
353 |
405 |
|
|
354 |
|
self.changeatrbutton = tkinter.Button(self, text="Choose the attribute file", command=lambda: self.get_new_path("Choose a new attribute file", 'atr')) |
|
|
406 |
|
self.changeatrbutton =\ |
|
407 |
|
tkinter.Button(self, text="Choose the attribute file", |
|
408 |
|
command=lambda: |
|
409 |
|
self.get_new_path("Choose a new attribute file", |
|
410 |
|
'atr')) |
355 |
411 |
self.changeatrbutton.grid(row=2, column=2, pady=10, padx=10) |
self.changeatrbutton.grid(row=2, column=2, pady=10, padx=10) |
356 |
412 |
|
|
357 |
|
self.dropdesc = DescBox(master=self, desctext="Choose the categories for the product.") |
|
|
413 |
|
self.dropdesc =\ |
|
414 |
|
DescBox(master=self, |
|
415 |
|
desctext="Choose the categories for the product.") |
358 |
416 |
self.dropdesc.grid(row=3, columnspan=3, pady=10, padx=10) |
self.dropdesc.grid(row=3, columnspan=3, pady=10, padx=10) |
359 |
417 |
|
|
360 |
418 |
self.dropdown = DropdownChooser(master=self) |
self.dropdown = DropdownChooser(master=self) |
361 |
419 |
self.dropdown.grid(row=4, column=1, columnspan=2) |
self.dropdown.grid(row=4, column=1, columnspan=2) |
362 |
420 |
|
|
363 |
|
self.namedesc = DescBox(master=self, desctext="Choose a name for the product") |
|
|
421 |
|
self.namedesc = DescBox(master=self, |
|
422 |
|
desctext="Choose a name for the product") |
364 |
423 |
self.namedesc.grid(row=5, columnspan=3, pady=10, padx=10) |
self.namedesc.grid(row=5, columnspan=3, pady=10, padx=10) |
365 |
424 |
|
|
366 |
425 |
self.namechooser = tkinter.Entry(self, width=50, bg="white") |
self.namechooser = tkinter.Entry(self, width=50, bg="white") |
367 |
426 |
self.namechooser.grid(row=6, columnspan=3, pady=10, padx=10) |
self.namechooser.grid(row=6, columnspan=3, pady=10, padx=10) |
368 |
427 |
|
|
369 |
|
self.markingdesc = DescBox(master=self, desctext="Choose a marking for the product") |
|
|
428 |
|
self.markingdesc = DescBox(master=self, |
|
429 |
|
desctext="Choose a marking for the product") |
370 |
430 |
self.markingdesc.grid(row=7, columnspan=3, pady=10, padx=10) |
self.markingdesc.grid(row=7, columnspan=3, pady=10, padx=10) |
371 |
431 |
|
|
372 |
432 |
self.markingchooser = MarkingDropdown(master=self) |
self.markingchooser = MarkingDropdown(master=self) |
373 |
433 |
self.markingchooser.grid(row=8, columnspan=3, pady=10, padx=10) |
self.markingchooser.grid(row=8, columnspan=3, pady=10, padx=10) |
374 |
434 |
|
|
375 |
|
self.accept = tkinter.Button(self, text="Accept", |
|
376 |
|
command=lambda: self.get_input(self.dropdown.resultbox.get(), |
|
377 |
|
self.namechooser.get(), |
|
378 |
|
self.markingchooser.resultvar)) |
|
|
435 |
|
self.accept =\ |
|
436 |
|
tkinter.Button(self, text="Accept", |
|
437 |
|
command=lambda: |
|
438 |
|
self.get_input(self.dropdown.resultbox.get(), |
|
439 |
|
self.namechooser.get(), |
|
440 |
|
self.markingchooser.resultvar)) |
379 |
441 |
self.accept.grid(row=9, column=3, pady=10, padx=10) |
self.accept.grid(row=9, column=3, pady=10, padx=10) |
380 |
442 |
|
|
381 |
443 |
def get_input(self, categories, name, marking): |
def get_input(self, categories, name, marking): |
|
... |
... |
class CategoryChooser(tkinter.Tk): |
388 |
450 |
def get_new_path(self, title, option): |
def get_new_path(self, title, option): |
389 |
451 |
if(option == 'upload'): |
if(option == 'upload'): |
390 |
452 |
print("Get the new path of the upload folder.") |
print("Get the new path of the upload folder.") |
391 |
|
self.newpath['upload-path'] = tkinter.filedialog.askdirectory(title=title) |
|
|
453 |
|
self.newpath['upload-path'] =\ |
|
454 |
|
tkinter.filedialog.askdirectory(title=title) |
392 |
455 |
elif(option == 'atr'): |
elif(option == 'atr'): |
393 |
456 |
print("Get a new attribute file.") |
print("Get a new attribute file.") |
394 |
|
self.newpath['attribute-path'] = tkinter.filedialog.askopenfilename(title=title) |
|
|
457 |
|
self.newpath['attribute-path'] =\ |
|
458 |
|
tkinter.filedialog.askopenfilename(title=title) |
395 |
459 |
self.atrdate = datetime.datetime.now().strftime("%d.%m.%Y-%H:%M") |
self.atrdate = datetime.datetime.now().strftime("%d.%m.%Y-%H:%M") |
396 |
460 |
self.check_colors(self.flatfile, self.newpath['attribute-path']) |
self.check_colors(self.flatfile, self.newpath['attribute-path']) |
397 |
461 |
|
|
|
... |
... |
class CategoryChooser(tkinter.Tk): |
408 |
472 |
self.toplevelWarning = tkinter.Toplevel(self) |
self.toplevelWarning = tkinter.Toplevel(self) |
409 |
473 |
self.toplevelWarning.title("Warning missing Colors") |
self.toplevelWarning.title("Warning missing Colors") |
410 |
474 |
self.toplevelWarning.lift(self) |
self.toplevelWarning.lift(self) |
411 |
|
self.toplevelWarning.geometry("+{}+{}".format(self.positionright, self.positiondown)) |
|
|
475 |
|
self.toplevelWarning.geometry("+{}+{}" |
|
476 |
|
.format(self.positionright, |
|
477 |
|
self.positiondown)) |
412 |
478 |
self.warningbox = WarningBox(self.toplevelWarning, colorlist) |
self.warningbox = WarningBox(self.toplevelWarning, colorlist) |
413 |
479 |
except Exception as err: |
except Exception as err: |
414 |
|
print("Error @ checkcolor: {0} - line no.: {1}".format(err, sys.exc_info()[2].tb_lineno)) |
|
|
480 |
|
print("Error @ checkcolor: {0} - line no.: {1}" |
|
481 |
|
.format(err, sys.exc_info()[2].tb_lineno)) |
415 |
482 |
|
|
416 |
483 |
def close_app(self): |
def close_app(self): |
417 |
484 |
if(self.data['name'] and self.data['categories']): |
if(self.data['name'] and self.data['categories']): |
418 |
485 |
self.withdraw() |
self.withdraw() |
419 |
486 |
else: |
else: |
420 |
|
tmb.showerror("NO INPUT", "Please enter a name and at least one category!") |
|
|
487 |
|
tmb.showerror("NO INPUT", |
|
488 |
|
"Please enter a name and at least one category!") |