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

[apcode language=»python»]

from tkinter import *
  global start
start = False 
global colour 
colour = "black"
   def colour_funck(colour_change): 
 for tag in range(1,12961):
  canvas.tag_bind(str(tag),'<Button-1>',lambda event: canvas.itemconfig(str(tag),fill=colour_change,width=3))
 def change(my_colour): 
 colour = my_colour
 window_colour.destroy()  
 colour_funck(colour)
 def colour_change(): 
 global window_colour
 window_colour = Tk() 
 button_red  = Button(window_colour,width = 12,height = 2,text = 'Красный',bg = 'red',fg = 'black',command = lambda : change("red")) 
 button_red.place(x = 0,y = 0)
 button_yellow = Button(window_colour,width = 12,height = 2,text = 'Жёлтый',bg = 'red',fg = 'black',command = lambda: change("yellow")) 
 button_yellow.place(x = 94,y = 0)
 button_green = Button(window_colour,width = 12,height = 2,text = 'Зелёный',bg = 'red',fg = 'black',command = lambda: change("green")) 
 button_green.place(x = 188,y = 0)
 button_white = Button(window_colour,width = 12,height = 2,text = 'Белый',bg = 'red',fg = 'black',command = lambda: change("white")) 
 button_white.place(x = 282,y = 0)
 button_black = Button(window_colour,width = 12,height = 2,text = 'Черный',bg = 'red',fg = 'black',command = lambda: change("black")) 
 button_black.place(x = 374,y = 0)
 button_blue = Button(window_colour,width = 12,height = 2,text = 'Голубой',bg = 'red',fg = 'black',command = lambda: change("blue")) 
 button_blue.place(x = 468,y = 0)
 window_colour.mainloop() 
 def rect():
    x = 0
    x1 = 10
    y = 0
    y1 = 10
    tag = '1'
      def binder(x, x1, y, y1, tag,colour):
        canvas.create_rectangle(x,y,x1,y1,tag = tag, fill='white')
        canvas.tag_bind(tag,'<Button-1>',lambda event: canvas.itemconfig(tag,fill=colour,width=3))         
         while x1 != 1450 and y1 != 910:
        binder(x, x1, y, y1, tag, colour)
        x = x + 10
        x1 = x1 + 10
        tag = str(int(tag) + 1)
        if x1 == 1450:
            x = 0
            x1 = 10
            y = y + 10
            y1 = y1 + 10
    def start_game(): 
 window_game = Tk() 
 window_game.attributes("-fullscreen",True)
 global canvas
 canvas = Canvas(window_game,width = 1450,height = 910)
 canvas.pack()
 button_destroy = Button(window_game,width = 12,height = 2,text = 'Выход',bg = 'red',fg = 'black',command = lambda: window_game.destroy())
 button_destroy.place(x = 0,y = 0) 
 button_colour = Button(window_game,width = 12,height = 2,text = 'Цвета',bg = 'red',fg = 'black',command = lambda: colour_change()) 
 button_colour.place(x = 94,y = 0) 
 rect()
  def main():
    global window
    window = Tk()
    window.attributes('-fullscreen',True)
    button_destroy = Button(window,width = 12,height = 2,text = 'Выход',bg = 'red',fg = 'black',command = lambda: window.destroy())
    button_destroy.place(x = 0,y = 0)
    button_start = Button(window,width = 12,height = 2,text = 'Начать',bg = 'red',fg = 'black',command = lambda: start_game())
    button_start.place(x = 500,y = 500)
    window.mainloop()
 main()

[/apcode]

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