Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- root.geometry("1280x820")
- x = 0
- y = 0
- def move(color):
- global x, y
- l1['bg'] = color
- if color == "green":
- x -= 15
- y += 0
- if color == "blue":
- x += 15
- y += 0
- if color == "red":
- x += 0
- y -= 15
- if color == "yellow":
- x += 0
- y += 15
- l1.place(x=x, y=y)
- b1 = Button(bg='green', width=10, height=3, text='<-', font='Verdana 15', command=lambda: move(b1['bg']))
- b2 = Button(bg='blue', width=10, height=3, text='->', font='Verdana 15', command=lambda: move(b2['bg']))
- b3 = Button(bg='red', width=10, height=3, text='Вверх', font='Verdana 15', command=lambda: move(b3['bg']))
- b4 = Button(bg='yellow', width=10, height=3, text='Вниз', font='Verdana 15', command=lambda: move(b4['bg']))
- b1.place(x=5, y=5)
- b2.place(x=150, y=5)
- b3.place(x=5, y=100)
- b4.place(x=150, y=100)
- l1 = Label(bg='black', width=10, height=3, text='МЕТКА', font='Verdana 15')
- x = 450
- y = 500
- l1.place(x=x, y=y)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement