-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
680 lines (571 loc) · 22.1 KB
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
from tkinter import *
from tkinter import filedialog, messagebox
from gold import Gold
from diamond import Diamond
from utils.insert_default_value import InsertDefault
from utils.src import Source
from utils.entry_state import EntryStates
'''
Gui class: [all the tkinter entry and buttons]
'''
class Gui():
def __init__(self):
# window
self.window = Tk()
self.window.geometry("1000x620")
self.window.configure(bg = Source().COLOR_WHITE)
self.window.iconbitmap("assets/card.ico")
self.window.title("Card Printing Designer")
# canvas and background
self.background()
# tkinter entry
self.entry()
# tkinter button
self.button()
# inserting default value to the entry
InsertDefault(self).insert_default_value_to_entry()
# default entry state is gold state
gold_state = EntryStates("normal", "disabled", Source().COLOR_DARK)
gold_state.state(self)
# inserting background to the window
def background(self):
self.canvas = Canvas(
self.window,
bg = Source().COLOR_WHITE,
height = 620,
width = 1000,
bd = 0,
highlightthickness = 0,
relief = "ridge")
self.canvas.place(x = 0, y = 0)
self.background_img = PhotoImage(file = f"assets/background.png")
self.background = self.canvas.create_image(
489.5, 308.5,
image=self.background_img)
# inserting entry's to the window
'''
Gold Input
- modify no.
- select image from file
- select qr from file | genarate qr from link
- jewellery name
- adress
- customer name
- date
- product name
- weight
- karate
- AU - gold value
- AG - silver value
- cu - copper value
- oth - other value
Diamond Input
- modify no.
- select image from file
- select qr from file | genarate qr from link
- jewellery name
- adress
- customer name
- date
- product name
- weight
- karate
- colour
- clarity
- cut
- finish
'''
# Entry method
def entry(self):
# ----------------------------------------- modify entry ----------------------------------------------------
self.entry0_img = PhotoImage(file = f"assets/img_textBox0.png")
self.entry0_bg = self.canvas.create_image(
256.0, 38.0,
image = self.entry0_img)
self.entry0 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry0.place(
x = 230.0, y = 23,
width = 52.0,
height = 28)
# ---------------------------------------- product image entry -------------------------------------------------
self.entry1_img = PhotoImage(file = f"assets/img_textBox1.png")
self.entry1_bg = self.canvas.create_image(
110.5, 105.0,
image = self.entry1_img)
self.entry1 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry1.place(
x = 59.0, y = 90,
width = 103.0,
height = 28)
# ------------------------------------------- qr image entry ----------------------------------------------------
self.entry2_img = PhotoImage(file = f"assets/img_textBox2.png")
self.entry2_bg = self.canvas.create_image(
233.5, 105.0,
image = self.entry2_img)
self.entry2 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry2.place(
x = 182.0, y = 90,
width = 103.0,
height = 28)
# ---------------------------------------- jewellery name entry ---------------------------------------------------
self.entry3_img = PhotoImage(file = f"assets/img_textBox3.png")
self.entry3_bg = self.canvas.create_image(
110.5, 172.0,
image = self.entry3_img)
self.entry3 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry3.place(
x = 59.0, y = 157,
width = 103.0,
height = 28)
# ------------------------------------------- adress entry ---------------------------------------------------------
self.entry4_img = PhotoImage(file = f"assets/img_textBox4.png")
self.entry4_bg = self.canvas.create_image(
233.5, 172.0,
image = self.entry4_img)
self.entry4 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry4.place(
x = 182.0, y = 157,
width = 103.0,
height = 28)
# ----------------------------------------- customer name entry ----------------------------------------------------
self.entry5_img = PhotoImage(file = f"assets/img_textBox5.png")
self.entry5_bg = self.canvas.create_image(
172.0, 239.0,
image = self.entry5_img)
self.entry5 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry5.place(
x = 59.0, y = 224,
width = 226.0,
height = 28)
# ---------------------------------------------- date entry ---------------------------------------------------------
self.entry6_img = PhotoImage(file = f"assets/img_textBox6.png")
self.entry6_bg = self.canvas.create_image(
110.5, 306.0,
image = self.entry6_img)
self.entry6 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry6.place(
x = 59.0, y = 291,
width = 103.0,
height = 28)
# ------------------------------------------- product name entry -----------------------------------------------------
self.entry7_img = PhotoImage(file = f"assets/img_textBox7.png")
self.entry7_bg = self.canvas.create_image(
233.5, 306.0,
image = self.entry7_img)
self.entry7 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry7.place(
x = 182.0, y = 291,
width = 103.0,
height = 28)
# ------------------------------------------ product weight entry -----------------------------------------------------
self.entry8_img = PhotoImage(file = f"assets/img_textBox8.png")
self.entry8_bg = self.canvas.create_image(
110.5, 373.0,
image = self.entry8_img)
self.entry8 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry8.place(
x = 59.0, y = 358,
width = 103.0,
height = 28)
# ------------------------------------------ product karate entry ----------------------------------------------------
self.entry9_img = PhotoImage(file = f"assets/img_textBox9.png")
self.entry9_bg = self.canvas.create_image(
233.5, 373.0,
image = self.entry9_img)
self.entry9 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry9.place(
x = 182.0, y = 358,
width = 103.0,
height = 28)
# -------------------------------------------- gold value entry -------------------------------------------------------
self.entry10_img = PhotoImage(file = f"assets/img_textBox10.png")
self.entry10_bg = self.canvas.create_image(
84.5, 471.0,
image = self.entry10_img)
self.entry10 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry10.place(
x = 59.0, y = 456,
width = 51.0,
height = 28)
# ------------------------------------------- silver value entry -------------------------------------------------------
self.entry11_img = PhotoImage(file = f"assets/img_textBox11.png")
self.entry11_bg = self.canvas.create_image(
159.5, 471.0,
image = self.entry11_img)
self.entry11 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry11.place(
x = 134.0, y = 456,
width = 51.0,
height = 28)
# ------------------------------------------- copper value entry -------------------------------------------------------
self.entry12_img = PhotoImage(file = f"assets/img_textBox12.png")
self.entry12_bg = self.canvas.create_image(
234.5, 471.0,
image = self.entry12_img)
self.entry12 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry12.place(
x = 209.0, y = 456,
width = 51.0,
height = 28)
# --------------------------------------------- other value entry -------------------------------------------------------
self.entry13_img = PhotoImage(file = f"assets/img_textBox13.png")
self.entry13_bg = self.canvas.create_image(
309.5, 471.0,
image = self.entry13_img)
self.entry13 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry13.place(
x = 284.0, y = 456,
width = 51.0,
height = 28)
# ------------------------------------------------ color entry -----------------------------------------------------------
self.entry14_img = PhotoImage(file = f"assets/img_textBox14.png")
self.entry14_bg = self.canvas.create_image(
84.5, 540.0,
image = self.entry14_img)
self.entry14 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry14.place(
x = 59.0, y = 525,
width = 51.0,
height = 28)
# ------------------------------------------------ clarity entry ----------------------------------------------------------
self.entry15_img = PhotoImage(file = f"assets/img_textBox15.png")
self.entry15_bg = self.canvas.create_image(
159.5, 540.0,
image = self.entry15_img)
self.entry15 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry15.place(
x = 134.0, y = 525,
width = 51.0,
height = 28)
# ------------------------------------------------- cut entry --------------------------------------------------------------
self.entry16_img = PhotoImage(file = f"assets/img_textBox16.png")
self.entry16_bg = self.canvas.create_image(
234.5, 540.0,
image = self.entry16_img)
self.entry16 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry16.place(
x = 209.0, y = 525,
width = 51.0,
height = 28)
# -------------------------------------------------- finish entry ----------------------------------------------------------
self.entry17_img = PhotoImage(file = f"assets/img_textBox17.png")
self.entry17_bg = self.canvas.create_image(
309.5, 540.0,
image = self.entry17_img)
self.entry17 = Entry(
bd = 0,
bg = Source().COLOR_DARK,
fg = Source().COLOR_WHITE,
insertbackground = Source().COLOR_WHITE,
highlightthickness = 0)
self.entry17.place(
x = 284.0, y = 525,
width = 51.0,
height = 28)
# [2] inserting button to the window
'''
Gold Button
- gold_front
- gold_back
Diamond Button
- diamond_front
- diamond_back
Other Button
- modify
- card_one
- card_two
- card_three
- card_four
- about
'''
# Button method
def button(self):
# ----------------------------------------------------- modify button ----------------------------------------------------------
self.img2 = PhotoImage(file = f"assets/img2.png")
self.b2 = Button(
image = self.img2,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.modify(self),
relief = "flat")
self.b2.place(
x = 294, y = 28,
width = 60,
height = 23)
# -------------------------------------------------- gold tab button ----------------------------------------------------------
self.img0 = PhotoImage(file = f"assets/img0.png")
self.b0 = Button(
image = self.img0,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.gold_card(self),
relief = "flat")
self.b0.place(
x = 51, y = 28,
width = 70,
height = 20)
# -------------------------------------------------- diamond tab button --------------------------------------------------------
self.img1 = PhotoImage(file = f"assets/img1.png")
self.b1 = Button(
image = self.img1,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.diamond_card(self),
relief = "flat")
self.b1.place(
x = 131, y = 28,
width = 70,
height = 20)
# -------------------------------------------------- open item image ----------------------------------------------------------
self.img5 = PhotoImage(file = f"assets/img5.png")
self.b5 = Button(
image = self.img5,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.open_product_image(self),
relief = "flat")
self.b5.place(
x = 58, y = 63,
width = 94,
height = 19)
# ---------------------------------------------------- open qr image ----------------------------------------------------------
self.img6 = PhotoImage(file = f"assets/img6.png")
self.b6 = Button(
image = self.img6,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.open_qr_image(self),
relief = "flat")
self.b6.place(
x = 179, y = 63,
width = 94,
height = 19)
# ------------------------------------------- gold button print ---------------------------------------------------
self.img3 = PhotoImage(file = f"assets/img3.png")
self.b3 = Button(
image = self.img3,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.print_gold_card(self),
relief = "flat")
self.b3.place(
x = 87, y = 568,
width = 100,
height = 29)
# ------------------------------------------ diamond button print ---------------------------------------------------
self.img14 = PhotoImage(file = f"assets/img14.png")
self.b14 = Button(
image = self.img14,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.print_diamond_card(self),
relief = "flat")
self.b14.place(
x = 205, y = 568,
width = 100,
height = 29)
# -------------------------------------------------- Gold ----------------------------------------------------------
self.img7 = PhotoImage(file = f"assets/img7.png")
self.b7 = Button(
image = self.img7,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.gold_card(self),
relief = "flat")
self.b7.place(
x = 606, y = 122,
width = 70,
height = 20)
# -------------------------------------------------- Diamnond ----------------------------------------------------------
self.img8 = PhotoImage(file = f"assets/img8.png")
self.b8 = Button(
image = self.img8,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.diamond_card(self),
relief = "flat")
self.b8.place(
x = 700, y = 122,
width = 70,
height = 20)
# ----------------------------------------------------- card one -------------------------------------------------------------
self.img9 = PhotoImage(file = f"assets/img9.png")
self.b9 = Button(
image = self.img9,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.about(self),
relief = "flat")
self.b9.place(
x = 600, y = 190,
width = 26,
height = 28)
# ----------------------------------------------------- card two -------------------------------------------------------------
self.img10 = PhotoImage(file = f"assets/img10.png")
self.b10 = Button(
image = self.img10,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.about(self),
relief = "flat")
self.b10.place(
x = 650, y = 190,
width = 26,
height = 28)
# ----------------------------------------------------- card three -------------------------------------------------------------
self.img11 = PhotoImage(file = f"assets/img11.png")
self.b11 = Button(
image = self.img11,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.about(self),
relief = "flat")
self.b11.place(
x = 700, y = 190,
width = 26,
height = 28)
# ----------------------------------------------------- card four -------------------------------------------------------------
self.img12 = PhotoImage(file = f"assets/img12.png")
self.b12 = Button(
image = self.img12,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.about(self),
relief = "flat")
self.b12.place(
x = 750, y = 190,
width = 26,
height = 28)
# ---------------------------------------------------- about button ------------------------------------------------------------
self.img13 = PhotoImage(file = f"assets/img13.png")
self.b13 = Button(
image = self.img13,
borderwidth = 0,
highlightthickness = 0,
command = lambda: ButtonCommand.about(self),
relief = "flat")
self.b13.place(
x = 904, y = 34,
width = 54,
height = 19)
'''
ButtonCommand: [all the onClick function of tkinter buttons]
'''
class ButtonCommand(Gui):
def modify(self):
print("modify")
# gold_card:
# only show the entry which is used by gold card
# diamond card entry gets disabled]
def gold_card(self):
gold_state = EntryStates("normal", "disabled", Source().COLOR_DARK)
gold_state.state(self)
# diamond_card:
# only show the entry which is used by diamond card
# gold card entry gets disabled
def diamond_card(self):
gold_state = EntryStates("disabled", "normal", Source().COLOR_DARK)
gold_state.state(self)
# open image from file
# set the path to the entry
def open_product_image(self):
path = filedialog.askopenfilename()
self.entry1.insert(END, path)
print(path)
def open_qr_image(self):
print("open_qr_image")
def print_gold_card(self):
gold = Gold(self)
gold.set_value()
gold.print_card()
def print_diamond_card(self):
diamond = Diamond(self)
diamond.set_value()
diamond.print_card()
def about(self):
messagebox.showinfo("Card Printing Designer","- Created By Rupam Seal\n- Version 1.0.1")