0
0 комментариев

[apcode language=»python»]

from tkinter import *
from tkinter import colorchooser
global color 
color = "black" 
global r 
r = 5
  def create_brush(event): 
 x = event.x  
 y = event.y 
 x1 = int(x) + r
 y1 = int(y) + r 
 global brush 
 brush = canvas.create_oval(x,y,x1,y1,tag = "brush",fill = color,width = 0,outline = color)
   def start_paint(): 
 global canvas
 canvas = Canvas(window_main,width = 1440,height = 900) 
 canvas.pack() 
 canvas.bind("<B1-Motion>",create_brush)
 def get_color_event(event): 
 if hasattr(event.widget, 'find_closest'):
  tags = event.widget.find_closest(event.x, event.y)
  for tag in tags:
   canvas.itemconfig(tag, fill=color,width = 0,outline= color)
 def get_color(): 
 color = colorchooser.askcolor()[1]
 canvas.bind("<B1-Motion>",get_color_event)
  def new_list(): 
 canvas.delete(ALL)
 def weight_line(): 
  r = 200
  canvas.bind("<B1-Motion>",create_brush)
  def main(): 
 global window_main
 window_main = Tk()
 window_main.attributes('-fullscreen',True) 
 start_paint()
 button_quit = Button(window_main, width=12, height=2, text='Выход', bg='red', fg='black', command = lambda: window_main.destroy()) 
 button_quit.place(x=0, y=0) 
 button_weight = Button(window_main, width=12, height=2, text='Толщина Кисти', bg='red', fg='black', command = weight_line) 
 button_weight.place(x=94, y=0) 
 button_color = Button(window_main, width=12,height=2, text='Цвет', bg='red', fg='black', command = get_color)
 button_color.place(x= 188, y=0) 
 button_newlist = Button(window_main, width=12,height=2, text='Новый лист', bg='red', fg='black', command = new_list)
 button_newlist.place(x= 282, y=0) 
 window_main.mainloop() 
 main()

[/apcode]

Решенный вопрос
Добавить комментарий