I'm trying to make a windows simulator with windows and menus (or so I think I did), lately I use a drag and drop system to move labels (most of my widgets are, I avoid using canvases because they are somewhat difficult :| ), so I pretend that I move windows, now, the problem is that for some strange reason, the label that I drag flickers, or does not move correctly with the mouse, here is an example
I have tried to put an update_idletasks()
to the drag and drop function .. but that hardly solves my problem .. because before it was blinking and the window was not showing correctly .. now it shows correctly when dragging but it blinks
The window is a label with an image that I move, it is located in another label, which is the wallpaper, I tried to change it to a canvas ... but apparently it is still the same problem
Here is the code for this system and the one for the window:
#desktop background code
Wallpaper = "BlissHill"
Background_image = tk.PhotoImage(file="Assets/Wallpapers/" + Wallpaper + ".png")
Background_label = tk.Label(Ventana, image=Background_image)
Background_label.place(x=-1, y=-1, relwidth=1, relheight=1)
# Drag and drop function
def make_draggable(widget):
widget.bind("<Button-1>", on_drag_start)
widget.bind("<B1-Motion>", on_drag_motion)
def on_drag_start(event):
widget = event.widget
widget.update_idletasks()
widget._drag_start_x = event.x
widget._drag_start_y = event.y
def on_drag_motion(event):
widget = event.widget
x = widget.winfo_x() - widget._drag_start_x + event.x
y = widget.winfo_y() - widget._drag_start_y + event.y
widget.update_idletasks()
widget.place(x=x, y=y)
# File manager (template)
FileManager_Texture = tk.PhotoImage(file="Assets/FileManager.png")
FileManagerMenu = Label(
Background_label,
width=687,
height=374,
bg="black",
image=FileManager_Texture,
borderwidth="0",
)
FileManagerMenu.place(x=1512, y=1512) # initial position before pressing the button
make_draggable(FileManagerMenu)
the complete code is too much to put here