-
Notifications
You must be signed in to change notification settings - Fork 0
/
printapp.py
95 lines (66 loc) · 2.85 KB
/
printapp.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
from tkinter import *
# import autopy
import pyautogui as pg
import sys
#variables
current_x, current_y = 0,0
color = 'black'
scalewidth= 1 # 1.255
scaleheight= 1 # 1.271
widthSc, heightSc = pg.size() # autopy.screen.size()
widthSc= scalewidth * widthSc
#functions
def addLine(pX, pY , cX, cY ):
canvas.create_line((pX * scalewidth, pY * scaleheight, cX *scalewidth, cY * scaleheight),fill = color ,width=5) #"white")
def show_color(new_color):
global color
color = new_color
def new_canvas():
canvas.delete('all')
#print(color)
display_pallete()
def quitd():
window.withdraw()
#tkinter window
window = Tk()
window.title('Paint')
window.state('zoomed')
window.rowconfigure(0, weight=1)
window.columnconfigure(0, weight=1)
canvas= Canvas(window,background='white')
canvas.master.overrideredirect(True)
canvas.grid(row=0,column=0,sticky='nsew')
#2 buttons
btn= Button(canvas, text="New Canvas", bg="#353535" ,fg="#fefefe" , command=new_canvas)
btn.place(x=widthSc-150, y=555)
btn2= Button(canvas, text="Quit Draw", bg="#353535" ,fg="#fefefe" , command=quitd)
btn2.place(x=widthSc-150, y=610)
#colors
def display_pallete():
new_id = canvas.create_rectangle((widthSc-65,70, widthSc - 30,105),fill='black')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('black'))
new_id = canvas.create_rectangle((widthSc-65,120, widthSc - 30,155),fill='gray')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('gray'))
new_id = canvas.create_rectangle((widthSc-65,170, widthSc - 30,205),fill='#fefefe')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('#fefefe'))
new_id = canvas.create_rectangle((widthSc-65,220, widthSc - 30,255),fill='red')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('red'))
new_id = canvas.create_rectangle((widthSc-65,270, widthSc - 30,305),fill='orange')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('orange'))
new_id = canvas.create_rectangle((widthSc-65,320, widthSc - 30,355),fill='yellow')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('yellow'))
new_id = canvas.create_rectangle((widthSc-65,370, widthSc - 30,405),fill='green')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('green'))
new_id = canvas.create_rectangle((widthSc-65,420, widthSc - 30,455),fill='blue')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('blue'))
new_id = canvas.create_rectangle((widthSc-65,470, widthSc - 30,505),fill='purple')
canvas.tag_bind(new_id, '<Button-1>', lambda x: show_color('purple'))
display_pallete()
#top of screen transparent
canvas.master.wm_attributes("-topmost", True)
#canvas.master.wm_attributes("-disabled", True)
canvas.master.wm_attributes("-transparentcolor", "white")
#window.withdraw()
#window.deiconify()
#window.state('zoomed')
#window.mainloop()