-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoodle.py
991 lines (860 loc) · 48.1 KB
/
doodle.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
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
import autopy
from pynput.mouse import Button as button
from pynput.mouse import Controller
import numpy as np
import HandTrackingMod as htm
from tkinter import *
import tkinter as tk
import tkinter.font
from tkinter import messagebox, filedialog, PhotoImage
from tkinter.ttk import Scale
import PIL
from PIL import ImageTk, Image, ImageGrab
from tkinter import colorchooser
import time
import cv2
from idlelib.tooltip import Hovertip
root = Tk()
root.geometry("1150x750")
root.title("DOODLE")
root.wm_iconbitmap('Utils/Pictures/Icon/doodle.ico')
root.config(cursor="@Mario.cur")
lmain = Label(root)
wCam, hCam = 300, 250
framexR = 50 # Frame Reduction
frameyR = 75
smoothening = 10
mouse = Controller()
detector = htm.HandDetector(maxHands=1)
wScr, hScr = autopy.screen.size()
wCanvas = wScr*0.75
class Paint:
# Initialisation
x_start, y_start = 0, 0
x_final, y_final = 0, 0
line_x0, line_y0, line_x1, line_y1 = 0, 0, 0, 0
rect_x0, rect_y0, rect_x1, rect_y1 = 0, 0, 0, 0
oval_x0, oval_y0, oval_x1, oval_y1 = 0, 0, 0, 0
pent_x0, pent_y0 = 0, 0
hex_x0, hex_y0 = 0, 0
parallelogram_x0, parallelogram_y0 = 0, 0
tri_x0, tri_y0 = 0, 0
rect_id = 0
oval_id = 0
line_id = 0
pentagon_id = 0
triangle_id = 0
hexagon_id = 0
parallelogram_id = 0
file_to_open: PhotoImage
menu_img_container = []
about_img = []
selection_id = 0
temp = []
cut_copy_img = []
counter = -1
img_label_all = []
heading, txt, entry, top, tips_label = None, None, None, None, None
des_label_all = []
width, height = 300, 275
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
root.bind('<Escape>', lambda e: root.quit())
lmain.pack(side="left")
lmain.place(x=1000, y=0)
mode = "Cursor mode"
FPS = 0
pTime = 0
img = None
plocX, plocY = 0, 0
clocX, clocY = 0, 0
text = "Hello"
font_family = "Helvetica"
font_size = 12
font_weight = "normal"
font_slant = "roman"
font_underline = 0
font_overstrike = 0
# To create menu bar
def menu_bar(self):
menu = Menu(root)
menu_img = ["open.png", "save.png", "exit.png", "undo.png", "cut.png", "copy.png", "paste.png", "text.png",
"about.png", "new.png", "cursor.png", "gesture.png", "help.png", "font_family.png", "font_size.png", "bold.png", "italic.png", "underline.png", "strikeout.png"]
for i in range(19):
self.menu_img_container.append(i)
self.menu_img_container[i] = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Menu_bar/" + menu_img[i]).resize((30, 30), Image.Resampling.LANCZOS))
# FILE MENU
file_menu = Menu(menu, tearoff=0)
file_menu.add_command(label=" New", command=self.new, image=self.menu_img_container[9], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
file_menu.add_command(label="Open", command=self.open_file, image=self.menu_img_container[0], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
file_menu.add_command(label="Save", command=self.save_file, accelerator="Ctrl+S",
image=self.menu_img_container[1], compound=LEFT, background="white", foreground="blue",
font=("Arial", 10, "bold"), activebackground="blue", activeforeground="white")
file_menu.add_separator()
file_menu.add_command(label="Quit", command=self.quit, image=self.menu_img_container[2], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
menu.add_cascade(label="🗂 File", menu=file_menu)
# EDIT MENU
edit_menu = Menu(menu, tearoff=0)
edit_menu.add_command(label="Undo", command=self.undo, accelerator="Ctrl+Z", image=self.menu_img_container[3],
compound=LEFT, background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
edit_menu.add_separator()
edit_menu.add_command(label="Cut", command=self.cut, accelerator="Ctrl+C", image=self.menu_img_container[4],
compound=LEFT, background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
edit_menu.add_command(label="Copy", command=self.copy, accelerator="Ctrl+X", image=self.menu_img_container[5],
compound=LEFT, background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
edit_menu.add_command(label="Paste", command=self.paste, accelerator="Ctrl+V", image=self.menu_img_container[6],
compound=LEFT, background="white", foreground="blue",
font=("Arial", 10, "bold"), activebackground="blue", activeforeground="white")
menu.add_cascade(label="✒ Edit", menu=edit_menu)
# TEXT MENU
text_menu = Menu(menu, tearoff=0)
text_menu.add_command(label="Text", command=self.add_text, image=self.menu_img_container[7], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
#text_menu = Menu(root, tearoff=0)
font_menu = Menu(root, tearoff=0)
font_menu.add_command(label="Arial Black", command=lambda value="Arial Black": self.set_font_family(value))
font_menu.add_command(label="Courier New", command=lambda value="Courier New": self.set_font_family(value))
font_menu.add_command(label="DejaVu Sans", command=lambda value="DejaVu Sans": self.set_font_family(value))
font_menu.add_command(label="Edwardian Script ITC", command=lambda value="Edwardian Script ITC": self.set_font_family(value))
font_menu.add_command(label="Garamond", command=lambda value="Garamond": self.set_font_family(value))
font_menu.add_command(label="Georgia", command=lambda value="Georgia": self.set_font_family(value))
font_menu.add_command(label="Papyrus", command=lambda value="Papyrus": self.set_font_family(value))
font_menu.add_command(label="Rockwell", command=lambda value="Rockwell": self.set_font_family(value))
font_menu.add_command(label="Small Fonts", command=lambda value="Small Fonts": self.set_font_family(value))
font_menu.add_command(label="Wide Latin", command=lambda value="Wide Latin": self.set_font_family(value))
text_menu.add_cascade(label="Font Family", menu=font_menu, image=self.menu_img_container[13], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
#text_menu.add_command(label="Change Text", command=self.set_text)
text_menu.add_command(label="Font Size", command=self.set_font_size, image=self.menu_img_container[14], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
text_menu.add_command(label="Bold", command=self.set_font_weight, image=self.menu_img_container[15], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
text_menu.add_command(label="Italic", command=self.set_font_slant, image=self.menu_img_container[16], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
text_menu.add_command(label="Underline", command=self.set_font_underline, image=self.menu_img_container[17], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
text_menu.add_command(label="Strike Out", command=self.set_font_overstrike, image=self.menu_img_container[18], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
menu.add_cascade(label="🖊 Text", menu=text_menu)
# HELP MENU
help_menu = Menu(menu, tearoff=0)
help_menu.add_command(label="About", command=self.about, image=self.menu_img_container[8], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
help_menu.add_command(label="Tips", command=self.tips, image=self.menu_img_container[12], compound=LEFT,
background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
menu.add_cascade(label="❓ Help", menu=help_menu)
# MODE MENU
mode_menu = Menu(menu, tearoff=0)
mode_menu.add_command(label="Cursor", command=self.cursor_mode, image=self.menu_img_container[10],
compound=LEFT, background="white", foreground="blue", font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
mode_menu.add_command(label="Gestures", command=self.gesture_mode
, image=self.menu_img_container[11], compound=LEFT, background="white", foreground="blue",
font=("Arial", 10, "bold"),
activebackground="blue", activeforeground="white")
menu.add_cascade(label="🖐 Mode", menu=mode_menu)
root.config(menu=menu)
# TO USE SHORTCUTS
root.bind("<Control-z>", self.undo)
root.bind("<Control-s>", self.save_file)
root.bind("<Control-x>", self.cut)
root.bind("<Control-c>", self.copy)
root.bind("<Control-v>", self.paste)
def __init__(self):
self.color_fills = "white"
self.pen_color = "black"
self.eraser_color = "white"
self.colour = "black"
self.stack = []
self.item = None
self.menu_bar()
# # CREATING COLOR PALLETE
self.color_fill = LabelFrame(root, bd=5, relief=RIDGE, bg="white")
self.color_fill.place(x=0, y=0, width=70, height=190)
Hovertip(self.color_fill, 'Outline color')
colors = ["#000000", "#964B00", "#FF0000", "#008000", "#0000FF", "#800080", "#FFA500", "#FFFFFF",
"#ffff00", "#FF69B4", "#00FF00", "#00fffb", "#b19cd9", "#FFD580"]
i = j = 0
for color in colors:
Button(self.color_fill, bg=color, bd=2, relief=RIDGE, width=3,
command=lambda col=color: self.select_color(col)).grid(row=i, column=j)
i = i + 1
if i == 7:
i = 0
j += 1
# CREATING LABEL FOR STATUS BAR AND FPS COUNT
self.status_bar = Label(bd=5, relief=RIDGE, font='Times 15 bold', bg='white', fg='black', anchor=W)
self.status_bar.pack(side=BOTTOM, fill=X)
self.fps = Label(bd=5, relief=RIDGE, font='Times 15 bold', bg='white', fg='black')
self.fps.place(x=1000, y=250)
# CREATING BUTTONS:
self.zoom_in_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/zoom in.png").resize((25, 20), Image.Resampling.LANCZOS))
self.zoom_in = Button(image=self.zoom_in_img, fg="red", bg="white", font=("Arial", 10, "bold"), relief=RAISED,
bd=3, command=lambda: self.zoom_control(1))
self.zoom_in.place(x=0, y=575)
Hovertip(self.zoom_in, 'Zoom in')
self.zoom_out_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/zoom out.png").resize((25, 20), Image.Resampling.LANCZOS))
self.zoom_out = Button(image=self.zoom_out_img, fg="red", bg="white", font=("Arial", 10, "bold"), relief=RAISED,
bd=3, command=lambda: self.zoom_control(0))
self.zoom_out.place(x=37, y=575)
Hovertip(self.zoom_out, 'Zoom out')
self.eraser_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/eraser.png").resize((28, 20), Image.Resampling.LANCZOS))
self.eraser_btn = Button(root, image=self.eraser_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.eraser)
self.eraser_btn.place(x=0, y=197)
Hovertip(self.eraser_btn, ' Eraser')
self.pencil_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/pencil.png.").resize((24, 20), Image.Resampling.LANCZOS))
self.pencil_btn = Button(root, image=self.pencil_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.pencil)
self.pencil_btn.place(x=37, y=515)
Hovertip(self.pencil_btn, 'Pencil')
self.line_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/line.png").resize((24, 20), Image.Resampling.LANCZOS))
self.line_but = Button(root, image=self.line_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.draw_line)
self.line_but.place(x=0, y=515)
Hovertip(self.line_but, 'Line')
self.colorbox_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/bucket.png").resize((25, 20), Image.Resampling.LANCZOS))
self.colorbox_btn = Button(root, image=self.colorbox_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.color_bucket)
self.colorbox_btn.place(x=37, y=197)
Hovertip(self.colorbox_btn, 'Fill color')
self.clear = Button(root, text="Clear", bd=4, bg="white", fg="blue", width=8, relief=RIDGE,
command= self.clear_canvas)
self.clear.place(x=0, y=227)
self.canvas = Button(root, text="Canvas", bd=4, bg="white", fg="blue", width=8, relief=RIDGE,
command=self.canvas_bg)
self.canvas.place(x=0, y=257)
Hovertip(self.canvas, 'Change the canvas background')
self.pen_size = LabelFrame(root, bd=5, bg="white", relief=RIDGE)
self.pen_size.place(x=0, y=290, height=130, width=70)
Hovertip(self.pen_size, 'Changes Pencil and Eraser Size')
self.pen_size1 = Scale(self.pen_size, orient=VERTICAL, from_=70, to=0, length=120)
self.pen_size1.set(1)
self.pen_size1.grid(row=0, column=1, padx=17)
self.rectangle_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Shapes/rectangle.png").resize((24, 20), Image.Resampling.LANCZOS))
self.rec = Button(root, image=self.rectangle_img, fg="red", bg="white",
font=("Arial", 10, "bold"), relief=RAISED, bd=3, command=self.draw_rectangle)
self.rec.place(x=0, y=425)
Hovertip(self.rec, 'Rectangle')
self.circle_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Shapes/circle.png").resize((24, 20), Image.Resampling.LANCZOS))
self.circle_btn = Button(root, image=self.circle_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.draw_oval)
self.circle_btn.place(x=0, y=455)
Hovertip(self.circle_btn, 'Circle')
self.triangle_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Shapes/triangle.png").resize((24, 20), Image.Resampling.LANCZOS))
self.triangle_btn = Button(root, image=self.triangle_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.draw_triangle)
self.triangle_btn.place(x=37, y=425)
Hovertip(self.triangle_btn, 'Triangle')
self.pentagon_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Shapes/pentagon.png").resize((24, 20), Image.Resampling.LANCZOS))
self.pentagon_btn = Button(root, image=self.pentagon_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.draw_pentagon)
self.pentagon_btn.place(x=37, y=455)
Hovertip(self.pentagon_btn, 'Pentagon')
self.hexagon_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Shapes/hexagon.png").resize((24, 20), Image.Resampling.LANCZOS))
self.hexagon_btn = Button(root, image=self.hexagon_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.draw_hexagon)
self.hexagon_btn.place(x=0, y=485)
Hovertip(self.hexagon_btn, 'Hexagon')
self.parallelogram_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Shapes/parallelogram.png").resize((24, 20), Image.Resampling.LANCZOS))
self.parallelogram_btn = Button(root, image=self.parallelogram_img, fg="red", bg="white",
font=("Arial", 10, "bold"), relief=RAISED, bd=3,
command=self.draw_parallelogram)
self.parallelogram_btn.place(x=37, y=485)
Hovertip(self.parallelogram_btn, 'Parallelogram')
self.selection_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/selection_box.png").resize((24, 20), Image.Resampling.LANCZOS))
self.selection_btn = Button(root, image=self.selection_img, fg="red", bg="white", font=("Arial", 10, "bold"),
relief=RAISED, bd=3, command=self.select_region)
self.selection_btn.place(x=0, y=545)
Hovertip(self.selection_btn, 'Select region')
self.screen_shot_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Tools/screen_shot.png").resize((24, 20), Image.Resampling.LANCZOS))
self.screen_shot_btn = Button(root, image=self.screen_shot_img, fg="red", bg="white",
font=("Arial", 10, "bold"), relief=RAISED, bd=3, command=self.snipping)
self.screen_shot_btn.place(x=37, y=545)
Hovertip(self.screen_shot_btn, 'Snipping tool')
# MAKE CANVAS
self.canvas = Canvas(root, bd=6, bg="white", relief=GROOVE, height=600, width=1000)
self.canvas.place(x=80, y=0,)
self.xsb = Scrollbar(root, orient="horizontal", command=self.canvas.xview)
self.ysb = Scrollbar(root, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=self.ysb.set, xscrollcommand=self.xsb.set)
self.canvas.configure(scrollregion=(0, 0, 1000, 1000))
self.xsb.pack(side=BOTTOM, fill=X)
self.ysb.pack(side=RIGHT, fill=Y)
# MOUSE DRAG
self.canvas.bind("<B1-Motion>", self.paint_app)
self.canvas.bind("<ButtonRelease-1>", self.reset)
self.canvas.bind("<Motion>", self.coordinates)
self.canvas.bind("<MouseWheel>", self.zoom_canvas)
def paint_app(self, event):
if self.x_start and self.y_start:
self.stack.append(
self.canvas.create_line(self.x_start, self.y_start, event.x, event.y, width=self.pen_size1.get(),
fill=self.pen_color, capstyle=ROUND, smooth=True))
self.x_start = event.x
self.y_start = event.y
def reset(self, _):
self.x_start = None
self.y_start = None
self.stack.append('#')
# DRAWING TOOLS
def pencil(self):
self.canvas.config(cursor="@Mario.cur")
self.canvas.unbind("<Button-1>")
self.canvas.unbind("<ButtonRelease-1>")
self.canvas.unbind("<B1-Motion>")
self.pen_color = self.colour
self.canvas.bind("<B1-Motion>", self.paint_app)
self.canvas.bind("<ButtonRelease-1>", self.reset)
def select_color(self, col):
self.pen_color = col
self.colour = col
def eraser(self):
#self.canvas.config(cursor="@eraser.cur")
self.pen_color = self.eraser_color
self.canvas.bind("<B1-Motion>", self.paint_app)
self.canvas.bind("<ButtonRelease-1>", self.reset)
def color_bucket(self):
color_box = messagebox.askokcancel("FILL COLOR", "This is applicable only for the available shapes."
" Select the color from the chooser with which color you want inside the shape"
" and then draw the shape you wish")
if color_box is True:
self.color_fills = colorchooser.askcolor(color=self.color_fills)[1]
def canvas_bg(self):
color = colorchooser.askcolor()
self.canvas.configure(background=color[1])
self.eraser_color = color[1]
self.pen_color = self.eraser_color
def clear_canvas(self):
clear_c = messagebox.askyesno("Clear canvas confirmation", "Do you really want to Clear the canvas? "
"If you clear before saving,your changes will be lost")
if clear_c is True:
self.canvas.delete("all")
# STATUS BAR INDICATING MOUSE POSITION AND MODE
def coordinates(self, event):
self.status_bar['text'] = f'{event.x},{event.y}px {self.mode}'
# TO CREATE SHAPES
def draw_rectangle(self):
self.canvas.config(cursor="@Mario.cur")
self.pen_color = self.colour
self.canvas.bind("<Button-1>", self.start_rect)
self.canvas.bind("<ButtonRelease-1>", self.stop_rect)
self.canvas.bind("<B1-Motion>", self.moving_rect)
def start_rect(self, event):
# Convert x0,y0 coordinates to canvas coordinates
self.rect_x0 = self.canvas.canvasx(event.x)
self.rect_y0 = self.canvas.canvasy(event.y)
# Creates rectangle
self.rect_id = self.canvas.create_rectangle(
self.rect_x0, self.rect_y0, self.rect_x0, self.rect_y0, outline=self.pen_color, fill=self.color_fills, width=self.pen_size1.get())
def moving_rect(self, event):
self.rect_x1 = self.canvas.canvasx(event.x)
self.rect_y1 = self.canvas.canvasy(event.y)
# Modify rectangle x1, y1 coordinates
self.canvas.coords(self.rect_id, self.rect_x0, self.rect_y0, self.rect_x1, self.rect_y1)
def stop_rect(self, event):
self.rect_x1 = self.canvas.canvasx(event.x)
self.rect_y1 = self.canvas.canvasy(event.y)
self.canvas.coords(self.rect_id, self.rect_x0, self.rect_y0, self.rect_x1, self.rect_y1)
self.stack.append(self.rect_id)
self.stack.append('$')
def draw_oval(self):
self.canvas.config(cursor="@Mario.cur")
self.pen_color = self.colour
self.canvas.bind("<Button-1>", self.start_oval)
self.canvas.bind("<ButtonRelease-1>", self.stop_oval)
self.canvas.bind("<B1-Motion>", self.moving_oval)
def start_oval(self, event):
self.oval_x0 = self.canvas.canvasx(event.x)
self.oval_y0 = self.canvas.canvasy(event.y)
self.oval_id = self.canvas.create_oval(
self.oval_x0, self.oval_y0, self.oval_x0, self.oval_y0, outline=self.pen_color, fill=self.color_fills, width=self.pen_size1.get())
def moving_oval(self, event):
self.oval_x1 = self.canvas.canvasx(event.x)
self.oval_y1 = self.canvas.canvasy(event.y)
self.canvas.coords(self.oval_id, self.oval_x0, self.oval_y0, self.oval_x1, self.oval_y1)
def stop_oval(self, event):
self.oval_x1 = self.canvas.canvasx(event.x)
self.oval_y1 = self.canvas.canvasy(event.y)
self.canvas.coords(self.oval_id, self.oval_x0, self.oval_y0, self.oval_x1, self.oval_y1)
self.stack.append(self.oval_id)
self.stack.append('$')
def draw_line(self):
self.canvas.config(cursor="@Mario.cur")
self.pen_color = self.colour
self.canvas.bind("<Button-1>", self.start_line)
self.canvas.bind("<ButtonRelease-1>", self.stop_line)
self.canvas.bind("<B1-Motion>", self.moving_line)
def start_line(self, event):
self.line_x0 = self.canvas.canvasx(event.x)
self.line_y0 = self.canvas.canvasy(event.y)
self.line_id = self.canvas.create_line(
self.line_x0, self.line_y0, self.line_x0, self.line_y0, fill=self.pen_color, width=self.pen_size1.get(),
smooth=True, capstyle=ROUND)
def moving_line(self, event):
self.line_x1 = self.canvas.canvasx(event.x)
self.line_y1 = self.canvas.canvasy(event.y)
self.canvas.coords(self.line_id, self.line_x0, self.line_y0, self.line_x1, self.line_y1)
def stop_line(self, event):
self.line_x1 = self.canvas.canvasx(event.x)
self.line_y1 = self.canvas.canvasy(event.y)
self.canvas.coords(self.line_id, self.line_x0, self.line_y0, self.line_x1, self.line_y1)
self.stack.append(self.line_id)
self.stack.append('$')
def draw_triangle(self):
self.canvas.config(cursor="@Mario.cur")
self.pen_color = self.colour
self.canvas.bind("<Button-1>", self.start_triangle)
self.canvas.bind("<ButtonRelease-1>", self.stop_triangle)
self.canvas.bind("<B1-Motion>", self.moving_triangle)
def start_triangle(self, event):
self.tri_x0 = self.canvas.canvasx(event.x)
self.tri_y0 = self.canvas.canvasy(event.y)
self.triangle_id = self.canvas.create_polygon(self.tri_x0, self.tri_y0, self.tri_x0 - (event.x - self.tri_x0),
event.y, event.x, event.y, outline=self.pen_color,
width=self.pen_size1.get(),
fill=self.color_fills
)
def moving_triangle(self, event):
self.canvas.coords(self.triangle_id, self.tri_x0, self.tri_y0, self.tri_x0 - (event.x - self.tri_x0), event.y,
event.x, event.y)
def stop_triangle(self, event):
self.canvas.coords(self.triangle_id, self.tri_x0, self.tri_y0, self.tri_x0 - (event.x - self.tri_x0), event.y,
event.x, event.y)
self.stack.append(self.triangle_id)
self.stack.append('$')
def draw_pentagon(self):
self.canvas.config(cursor="@Mario.cur")
self.pen_color = self.colour
self.canvas.bind("<Button-1>", self.start_pentagon)
self.canvas.bind("<ButtonRelease-1>", self.stop_pentagon)
self.canvas.bind("<B1-Motion>", self.moving_pentagon)
def start_pentagon(self, event):
self.pent_x0 = self.canvas.canvasx(event.x)
self.pent_y0 = self.canvas.canvasy(event.y)
self.pentagon_id = self.canvas.create_polygon(self.pent_x0, self.pent_y0, int(self.pent_x0), event.y, event.x,
event.y, int(event.x), self.pent_y0,
(self.pent_x0 + event.x) / 2, self.pent_y0 - 20,
outline=self.pen_color, width=self.pen_size1.get(), fill=self.color_fills)
def moving_pentagon(self, event):
self.canvas.coords(self.pentagon_id, self.pent_x0, self.pent_y0, int(self.pent_x0), event.y, event.x, event.y,
int(event.x), self.pent_y0, (self.pent_x0 + event.x) / 2, self.pent_y0 - 20)
def stop_pentagon(self, event):
self.canvas.coords(self.pentagon_id, self.pent_x0, self.pent_y0, int(self.pent_x0), event.y, event.x, event.y,
int(event.x), self.pent_y0, (self.pent_x0 + event.x) / 2, self.pent_y0 - 20)
self.stack.append(self.pentagon_id)
self.stack.append('$')
def draw_hexagon(self):
self.canvas.config(cursor="@Mario.cur")
self.pen_color = self.colour
self.canvas.bind("<Button-1>", self.start_hexagon)
self.canvas.bind("<ButtonRelease-1>", self.stop_hexagon)
self.canvas.bind("<B1-Motion>", self.moving_hexagon)
def start_hexagon(self, event):
self.hex_x0 = self.canvas.canvasx(event.x)
self.hex_y0 = self.canvas.canvasy(event.y)
self.hexagon_id = self.canvas.create_polygon(self.hex_x0, self.hex_y0, int(self.hex_x0), event.y,
(int(self.hex_x0) + int(event.x)) / 2, int(event.y) + 50, event.x,
event.y, int(event.x),
self.hex_y0, (self.hex_x0 + event.x) / 2, self.hex_y0 - 50,
outline=self.pen_color, width=self.pen_size1.get(), fill=self.color_fills)
def moving_hexagon(self, event):
self.canvas.coords(self.hexagon_id, self.hex_x0, self.hex_y0, int(self.hex_x0), event.y,
(int(self.hex_x0) + int(event.x)) / 2, int(event.y) + 50, event.x, event.y, int(event.x),
self.hex_y0,
(self.hex_x0 + event.x) / 2, self.hex_y0 - 50)
def stop_hexagon(self, event):
self.canvas.coords(self.hexagon_id, self.hex_x0, self.hex_y0, int(self.hex_x0), event.y,
(int(self.hex_x0) + int(event.x)) / 2, int(event.y) + 50, event.x, event.y, int(event.x),
self.hex_y0,
(self.hex_x0 + event.x) / 2, self.hex_y0 - 50)
self.stack.append(self.hexagon_id)
self.stack.append('$')
def draw_parallelogram(self):
self.canvas.config(cursor="@Mario.cur")
self.pen_color = self.colour
self.canvas.bind("<Button-1>", self.start_parallelogram)
self.canvas.bind("<ButtonRelease-1>", self.stop_parallelogram)
self.canvas.bind("<B1-Motion>", self.moving_parallelogram)
def start_parallelogram(self, event):
self.parallelogram_x0 = self.canvas.canvasx(event.x)
self.parallelogram_y0 = self.canvas.canvasy(event.y)
self.parallelogram_id = self.canvas.create_polygon(self.parallelogram_x0, self.parallelogram_y0,
int(self.parallelogram_x0) + 30, event.y, event.x, event.y,
int(event.x) - 30,
self.parallelogram_y0, outline=self.pen_color,
width=self.pen_size1.get(), fill=self.color_fills)
def moving_parallelogram(self, event):
self.canvas.coords(self.parallelogram_id, self.parallelogram_x0, self.parallelogram_y0,
int(self.parallelogram_x0) + 30, event.y, event.x, event.y, int(event.x) - 30,
self.parallelogram_y0)
def stop_parallelogram(self, event):
self.canvas.coords(self.parallelogram_id, self.parallelogram_x0, self.parallelogram_y0,
int(self.parallelogram_x0) + 30, event.y, event.x, event.y, int(event.x) - 30,
self.parallelogram_y0)
self.stack.append(self.parallelogram_id)
self.stack.append('$')
# ZOOM USING BUTTONS
def zoom_control(self, e): # For Zoom in and Zoom out
try:
if e.delta > 0:
self.canvas.scale("all", e.x, e.y, 1.1, 1.1)
elif e.delta < 0:
self.canvas.scale("all", e.x, e.y, 0.9, 0.9)
except :
if e == 1:
self.canvas.scale("all", 550, 350, 1.1, 1.1)
else:
self.canvas.scale("all", 550, 350, 0.9, 0.9)
# ZOOM USING SCROLLING
def zoom_canvas(self, _):
if _.delta > 0:
self.canvas.scale("all", _.x, _.y, 1.1, 1.1)
elif _.delta < 0:
self.canvas.scale("all", _.x, _.y, 0.9, 0.9)
self.canvas.configure(scrollregion=self.canvas.bbox("all"))
# SELECTING REGION FOR CUT, COPY, PASTE
def select_region(self):
self.canvas.config(cursor="@Mario.cur")
try:
self.draw_selection()
if self.rect_id:
self.rect_id = self.canvas.create_rectangle(self.rect_x0, self.rect_y0, self.rect_x0, self.rect_y0,
dash=(4, 2), outline="black")
def select_region_final(_):
self.temp.append(self.rect_id)
self.canvas.bind('<ButtonRelease-1>', select_region_final)
self.canvas.bind('<Button-3>', self.delete)
except BaseException:
print("Select region error")
def delete(self, _):
self.canvas.delete(self.rect_id)
def start_selection(self, event):
# Convert mouse screen x0,y0 coordinates to canvas coordinates
self.rect_x0 = self.canvas.canvasx(event.x)
self.rect_y0 = self.canvas.canvasy(event.y)
# Create rectangle
if not self.rect_id:
self.rect_id = self.canvas.create_rectangle(self.rect_x0, self.rect_y0, self.rect_x0, self.rect_y0,
dash=(4, 2), outline="black")
def moving_selection(self, event):
self.rect_x1 = self.canvas.canvasx(event.x)
self.rect_y1 = self.canvas.canvasy(event.y)
x, y = self.canvas.winfo_width(), self.canvas.winfo_height()
if event.x > 0.9 * x:
self.canvas.xview_scroll(1, 'units')
elif event.x < 0.1 * x:
self.canvas.xview_scroll(-1, 'units')
if event.y > 0.9 * y:
self.canvas.yview_scroll(1, 'units')
elif event.y < 0.1 * y:
self.canvas.yview_scroll(-1, 'units')
# expand rectangle as you drag the mouse
self.canvas.coords(self.rect_id, self.rect_x0, self.rect_y0, self.rect_x1, self.rect_y1)
def delete_selected_region(self, _): # To delete selected region
self.canvas.itemconfig(self.rect_id, fill=self.eraser_color, width=0.00001, outline=self.eraser_color)
self.reset_rectangle()
def draw_selection(self):
self.canvas.bind("<Button-1>", self.start_selection)
self.canvas.bind("<ButtonRelease-1>", self.stop_rect)
self.canvas.bind("<B1-Motion>", self.moving_selection)
self.canvas.bind(self.place)
self.canvas.bind('<Delete>', self.delete_selected_region)
self.canvas.bind("<ButtonRelease-1>", self.reset)
# FOR SNIPPING
def snipping(self):
try:
self.canvas.delete(self.temp.pop())
time.sleep(0.0000001)
root.update()
x1 = root.winfo_rootx() + self.canvas.winfo_x()
y1 = root.winfo_rooty() + self.canvas.winfo_y()
file = filedialog.asksaveasfilename(initialdir="Screen_shots", title="Screen shot save",
filetypes=[("PNG File", "*.png")])
if file:
ImageGrab.grab().crop(
(x1 + self.rect_x0, y1 + self.rect_y0, x1 + self.rect_x1, y1 + self.rect_y1)).save(file + ".png")
self.reset_rectangle()
except BaseException:
messagebox.showerror("Selection Error",
"First select a region by clicking the selection tool', then take screen shot")
def reset_rectangle(self):
self.rect_x0 = 0
self.rect_y0 = 0
self.rect_y1 = 0
self.rect_x1 = 0
self.temp = []
# METHODS FOR FILE MENU
def new(self):
self.save_file()
take = messagebox.askyesno("New Window Conformation", "Do you really want to open new Window?")
root.title("Doodle" + "-----" + "New Window")
if take is True:
self.canvas.delete("all")
def open_file(self):
try:
filename = filedialog.askopenfilename(initialdir="/",
filetypes=(("jpeg files", "*.jpg"), ("png files", "*.png")))
image = Image.open(filename)
image.save("Temp.png", "png")
self.file_to_open = PhotoImage(file="Temp.png")
self.canvas.delete("all")
self.canvas.create_image(3, 3, image=self.file_to_open, anchor=NW)
except AttributeError:
pass
def save_file(self, _=None):
file = filedialog.asksaveasfilename(initialdir="/", filetypes=(
("jpeg files", "*.jpg"), ("png files", "*.png")))
if file:
x = root.winfo_rootx() + self.canvas.winfo_x()
y = root.winfo_rooty() + self.canvas.winfo_y()
x1 = x + self.canvas.winfo_width()
y1 = y + self.canvas.winfo_height()
ImageGrab.grab().crop((x, y, x1, y1)).save(file + '.png')
ImageGrab.grab().crop((x, y, x1, y1)).save(file + '.jpg')
@staticmethod
def quit():
take = messagebox.askyesno("Quit Confirmation", "Do you really want to quit?")
if take is True:
root.quit()
# METHODS RELATED TO EDIT MENU
def undo(self, _=None):
try:
self.item = self.stack.pop()
if self.item == '$': # For undoing figures like rectangle, oval, circle, square, straight lines.
self.item = self.stack.pop()
self.canvas.delete(self.item)
elif self.item == '#':
self.item = self.stack.pop()
while self.item != '#' and self.item != '$':
self.canvas.delete(self.item)
if len(self.stack) == 0:
break
self.item = self.stack.pop()
if self.item == '#' or self.item == '$':
self.stack.append(self.item)
except IndexError:
pass
def cut(self, _=None): # Cut the selected region
self.copy(1)
self.delete_selected_region(False)
self.canvas.unbind("<B1-Motion>")
def copy(self, _=None): # Copy the selected region
try:
self.canvas.itemconfig(self.temp[len(self.temp) - 1], outline=self.eraser_color)
time.sleep(0.0001)
self.canvas.update()
x1 = root.winfo_rootx() + self.canvas.winfo_x()
y1 = root.winfo_rooty() + self.canvas.winfo_y()
ImageGrab.grab().crop((x1 + self.rect_x0, y1 + self.rect_y0, x1 + self.rect_x1, y1 + self.rect_y1)).save(
"cutting.png")
self.counter += 1
self.reset_rectangle()
except BaseException:
messagebox.showwarning("Error","Please select the region first")
def paste(self, _=None): # Paste the region keep in clipboard
if (self.counter >= 0):
messagebox.showinfo('Paste', ''' 📣 Please set the mouse pointer then click the left button 📣''')
self.cut_copy_img.append(ImageTk.PhotoImage(Image.open("cutting.png")))
self.canvas.bind('<Button-1>', self.place)
self.canvas.bind("<Motion>", self.coordinates)
self.canvas.bind('<Button-3>', self.cancel)
else:
messagebox.showwarning("Error","Cut or Copy the region to Paste ")
def place(self, event):
take = self.canvas.create_image(event.x, event.y, image=self.cut_copy_img[self.counter])
self.stack.append(take)
self.stack.append('$')
# METHODS RELATED TO TEXT MENU
def add_text(self):
self.top = tk.Toplevel()
self.top.geometry('310x70')
text_label = Label(self.top, text="Enter the text", font=("Times", 10, "bold"))
text_label.grid(row=0, column=0)
self.entry = Entry(self.top, width=50, relief=SUNKEN, font=("Times", 10, "bold"))
self.entry.grid(row=1, column=0)
enter_but = Button(self.top, text="OK", command=self.insert)
enter_but.grid(row=2, column=0)
def insert(self):
self.txt = self.entry.get()
if len(self.txt) > 0:
self.top.destroy()
messagebox.showinfo('Add text', "📣 Please set the mouse pointer from where you want to start the text left"
" click on the mouse to insert then right click to cancel 📣")
self.canvas.bind('<Button-1>', self.insert_txt)
self.canvas.bind('<Button-3>', self.cancel)
def insert_txt(self, event):
text_font = tk.font.Font(family=self.font_family, size=self.font_size,
weight=self.font_weight, slant=self.font_slant, underline=self.font_underline,
overstrike=self.font_overstrike)
take = self.canvas.create_text(event.x, event.y, text=self.txt, font= text_font, fill = self.colour)
#event.widget.create_text(self.x1_line_pt, self.y1_line_pt, fill=self.fill_color, font=text_font, text=self.text)
self.stack.append(take)
self.stack.append('$')
def cancel(self, _):
self.canvas.unbind('<Button-1>')
self.canvas.unbind('<Button-3>')
def text_button_press(self, value):
self.text = value()
def set_font_size(self):
top = Toplevel()
label = Label(top, text="Enter text size: ")
label.pack()
entry = Entry(top)
entry.pack()
button=Button(top, text="Set Text Size",command=lambda value=entry.get:
self.font_size_button_press(value))
button.pack()
def font_size_button_press(self, value):
self.font_size = value()
def set_font_weight(self):
if self.font_weight == "normal":
self.font_weight = "bold"
else:
self.font_weight = "normal"
def set_font_slant(self):
if self.font_slant == "roman":
self.font_slant = "italic"
else:
self.font_slant = "roman"
def set_font_underline(self):
if self.font_underline == 0:
self.font_underline = 1
else:
self.font_underline = 0
def set_font_overstrike(self):
if self.font_overstrike == 0:
self.font_overstrike = 1
else:
self.font_overstrike = 0
def set_font_family(self, value):
self.font_family = value
# METHODS RELATED TO HELP MENU
@staticmethod
def about():
messagebox.showinfo("ABOUT", "A paint applications where you can draw with varying brush size,"
" draw various shapes, erase, take a screen and many other cool features with either in"
" Cursor mode or Gesture mode using hand movements. Developed by Lokeswar P"
" and Logapriya G - students of MIT, Chennai")
def tips(self):
self.top = tk.Toplevel()
self.top.title("ABOUT")
self.top.geometry("1350x750")
self.top.wm_iconbitmap('Utils/Pictures/Icon/doodle.ico')
self.img_label_all = []
self.about_img.clear()
self.about_img = ImageTk.PhotoImage(
Image.open("Utils/Pictures/Menu_bar/about_gesture.png").resize((1350, 700), Image.ANTIALIAS))
self.img_label_all = Label(self.top, image=self.about_img, relief=RAISED, bd=3)
self.img_label_all.place(x=0, y=0)
# METHODS RELATED TO MODE
def show_frame(self):
if self.mode == "Gesture mode":
_, self.img = self.cap.read()
# 1. Find hand Landmarks
self.img = detector.findHands(self.img)
lmlist, bbox = detector.findPosition(self.img)
# 2. Get the tip of the index and middle fingers
if len(lmlist) != 0:
x1, y1 = lmlist[8][1:]
x2, y2 = lmlist[12][1:]
#3. Check which fingers are up
fingers = detector.fingersUp()
print(fingers)
cv2.rectangle(self.img, (framexR, frameyR), (wCam - framexR, hCam - frameyR), (255, 0, 255), 2)
# 4. Only Index Finger : Moving Mode
if fingers[1] == 1 and fingers[2] == 0 and fingers[3] == 0 and fingers[4] == 0 and fingers[0] == 0:
# 5. Convert Coordinates
x3 = np.interp(x1, (framexR, wCam - framexR), (0, wCanvas))
x3 = np.interp(x1, (framexR, wCam - framexR), (0, wCanvas))
y3 = np.interp(y1, (frameyR, hCam - frameyR), (0, hScr))
# 6. Smoothen Values
self.clocX = self.plocX + (x3 - self.plocX) / smoothening
self.clocY = self.plocY + (y3 - self.plocY) / smoothening
# 7. Move Mouse
autopy.mouse.move(wCanvas - self.clocX, self.clocY)
cv2.circle(self.img, (x1, y1), 5, (255, 0, 255), cv2.FILLED)
self.plocX, self.plocY = self.clocX, self.clocY
# 8. Both Index and middle fingers are up : Clicking Mode
if fingers[1] == 1 and fingers[2] == 1:
# 9. Find distance between fingers
length, self.img, lineInfo = detector.findDistance(8, 12, self.img)
#print(length)
# 10. Click mouse if distance short
if length < 20:
cv2.circle(self.img, (lineInfo[4], lineInfo[5]), 5, (0, 255, 0), cv2.FILLED)
mouse.press(button.left)
elif length > 40:
mouse.release(button.left)
if fingers[1] == 1 and fingers[2] == 1 and fingers[3] == 1 and fingers[4] == 1 and fingers[0] == 1:
mouse.release(button.left)
cTime = time.time()
self.FPS = 1 / (cTime - self.pTime)
self.pTime = cTime
fps_disp = "FPS: " + str(self.FPS)[:5]
self.fps['text'] = f'{fps_disp}'
if _:
cv2image = cv2.cvtColor(self.img, cv2.COLOR_BGR2RGB)
img1 = PIL.Image.fromarray(cv2image)
imgtk = ImageTk.PhotoImage(image=img1)
lmain.imgtk = imgtk
lmain.configure(image=imgtk)
lmain.after(1, self.show_frame)
self.canvas.config(width=900, height=620)
else:
return
def close(self):
if self.mode == "Cursor mode":
self.cap.release()
lmain.config(image="")
self.canvas.config(width=1000, height=600)
else:
return
def gesture_mode(self):
self.mode = "Gesture mode"
width, height = 350, 350
self.cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
lmain.pack(side="left")
lmain.place(x=1000, y=0)
self.show_frame()
def cursor_mode(self):
self.mode = "Cursor mode"
self.close()
paint = Paint()
root.mainloop()