Python 3 Tkinter Move Multiple Widgets on Canvas Window Such as Button,TextBox on Button Click GUI Desktop App Full Project For Beginners

 

 

 

main.py

 

 

import tkinter as tk
import random

# --- funtions ---

def move():
    # hide frame
    f.place_forget()

    # random positiom
    new_x = random.randint(0, 100)
    new_y = random.randint(0, 150)

    # show in new place
    f.place(x=new_x, y=new_y)

# --- main ---

root = tk.Tk()

f = tk.Frame(root)
f.place(x=0, y=0)

tk.Label(f, text='HELLO!').pack()
tk.Button(f, text='Move it', command=move).pack()

root.mainloop()

Leave a Reply