Skip to content

Commit 627679d

Browse files
committed
palce-random-postion
1 parent bc3b8fc commit 627679d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import tkinter as tk
2+
import random
3+
4+
def move():
5+
f.place_forget()
6+
new_x = random.randint(0, 100)
7+
new_y = random.randint(0, 150)
8+
f.place(x=new_x, y=new_y)
9+
10+
root = tk.Tk()
11+
12+
f = tk.Frame(root)
13+
f.place(x=0, y=0)
14+
15+
tk.Label(f, text='HELLO!').pack()
16+
tk.Button(f, text='Move it', command=move).pack()
17+
18+
root.mainloop()

0 commit comments

Comments
 (0)