Skip to content

Not working correctly with Pyinstaller #53

@Is-0

Description

@Is-0

I was just trying out tkdnd and found out that this application runs perfectly in normal python but when I make an exe using pyinstaller, it gives this error.

Traceback (most recent call last):
  File "TkinterDnD2\TkinterDnD.py", line 39, in _require
_tkinter.TclError: can't find package tkdnd

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "testGUI.py", line 15, in <module>
  File "TkinterDnD2\TkinterDnD.py", line 271, in __init__
  File "TkinterDnD2\TkinterDnD.py", line 41, in _require
RuntimeError: Unable to load tkdnd library.
[18820] Failed to execute script testGUI

Here's the code

import tkinter as tk
from TkinterDnD2 import DND_FILES, TkinterDnD

def drop_inside_list_box(event):
    listb.insert("end", event.data)

def drop_inside_textbox(event):
    tbox.delete("1.0", "end")
    if event.data.endswith(".txt"):
        with open(event.data, "r") as file:
            for line in file:
                line = line.strip()
                tbox.insert("end", f"{line}\n")

root = TkinterDnD.Tk()
root.geometry("800x600")

listb = tk.Listbox(root, selectmode=tk.SINGLE, background='#ffed06')
listb.pack(fill="x")
listb.drop_target_register(DND_FILES)
listb.dnd_bind("<<Drop>>", drop_inside_list_box)

tbox = tk.Text(root)
tbox.pack()
tbox.drop_target_register(DND_FILES)
tbox.dnd_bind("<<Drop>>", drop_inside_textbox)

root.mainloop()

It works if I remove this

tbox = tk.Text(root)
tbox.pack()
tbox.drop_target_register(DND_FILES)
tbox.dnd_bind("<<Drop>>", drop_inside_textbox)

If I remove that then drop_inside_textbox() is of no use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions