0

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

TheBigEye
  • 3
  • 1
  • 1
    Please try to provide a complete [mcve], and preferably one that doesn't rely on images. We do _not_ need the complete code, we just need enough to reproduce the problem. – Bryan Oakley Jun 02 '21 at 23:46
  • you maybe have to much frames put in your app? in tk it's always the best option to have less frames. or you will see thoose effects. so maybe this aren't frames, but you have too much of anything, that is makes your app slowly – bangKok Jun 03 '21 at 14:08

0 Answers0