-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrawdrawer.py
More file actions
69 lines (50 loc) · 2.29 KB
/
rawdrawer.py
File metadata and controls
69 lines (50 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import tkinter
class Scribble:
def on_pressed(self, event):
self.sx = event.x
self.sy = event.y
self.canvas.create_oval(self.sx, self.sy, event.x, event.y,
outline = self.color.get(),
width = self.width.get())
def on_dragged(self, event):
self.canvas.create_line(self.sx, self.sy, event.x, event.y,
fill = self.color.get(),
width = self.width.get())
self.sx = event.x
self.sy = event.y
"""
def click1(self,event):
self.canvas.create_oval(self.sx-20,self.sy-20,self.sx+20,self.sy+20,
fill = self.color.get(),
width = self.width.get())
def click2(self,event):
self.canvas.create_oval(self.sx-40,self.sy-30,self.sx+40,self.sy+30,
fill = self.color.get(),
width = self.width.get())
"""
def create_window(self):
window = tkinter.Tk()
window.title("お絵かきソフト")
self.canvas = tkinter.Canvas(window, bg = "black",
width = 600, height = 400)
self.canvas.pack()
quit_button = tkinter.Button(window, text = "終了",
command = window.quit)
quit_button.pack(side = tkinter.RIGHT)
self.canvas.bind("<ButtonPress-1>", self.on_pressed)
self.canvas.bind("<B1-Motion>", self.on_dragged)
COLORS = ["red", "white", "blue", "pink", "green","black"]
self.color = tkinter.StringVar()
self.color.set(COLORS[1])
b = tkinter.OptionMenu(window, self.color, *COLORS)
b.pack(side = tkinter.LEFT)
self.width = tkinter.Scale(window, from_ = 1, to = 10,
orient = tkinter.HORIZONTAL)
self.width.set(5)
self.width.pack(side = tkinter.LEFT)
return window;
def __init__(self):
self.window = self.create_window();
def run(self):
self.window.mainloop()
Scribble().run()