Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. root = Tk()
  4. root.geometry("1280x820")
  5.  
  6. x = 0
  7. y = 0
  8.  
  9.  
  10. def move(color):
  11.     global x, y
  12.     l1['bg'] = color
  13.     if color == "green":
  14.         x -= 15
  15.         y += 0
  16.     if color == "blue":
  17.         x += 15
  18.         y += 0
  19.     if color == "red":
  20.         x += 0
  21.         y -= 15
  22.     if color == "yellow":
  23.         x += 0
  24.         y += 15
  25.     l1.place(x=x, y=y)
  26.  
  27.  
  28. b1 = Button(bg='green', width=10, height=3, text='<-', font='Verdana 15', command=lambda: move(b1['bg']))
  29. b2 = Button(bg='blue', width=10, height=3, text='->', font='Verdana 15', command=lambda: move(b2['bg']))
  30. b3 = Button(bg='red', width=10, height=3, text='Вверх', font='Verdana 15', command=lambda: move(b3['bg']))
  31. b4 = Button(bg='yellow', width=10, height=3, text='Вниз', font='Verdana 15', command=lambda: move(b4['bg']))
  32. b1.place(x=5, y=5)
  33. b2.place(x=150, y=5)
  34. b3.place(x=5, y=100)
  35. b4.place(x=150, y=100)
  36. l1 = Label(bg='black', width=10, height=3, text='МЕТКА', font='Verdana 15')
  37. x = 450
  38. y = 500
  39. l1.place(x=x, y=y)
  40. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement