Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TkDnD didn't work #72

Open
redjacketKR opened this issue Aug 14, 2024 · 0 comments
Open

TkDnD didn't work #72

redjacketKR opened this issue Aug 14, 2024 · 0 comments

Comments

@redjacketKR
Copy link

tkinterdnd2 or TkDnD doesn't work with this CTkListbox

I've tried to convert this last piece to customtkinter but no use because of no support of dnd

    self.listbox = tk.Listbox(list_container, selectmode=tk.EXTENDED)

def make_listbox_drop_target(self):
    if hasattr(self, 'listbox'):
        self.listbox.drop_target_register(DND_FILES)
        self.listbox.dnd_bind('<<Drop>>', self.on_drop)


def create_listbox_frame(self, parent):
    label = ctk.CTkLabel(parent, text="CSV files:")
    label.pack(pady=(0, 5))

    list_container = ctk.CTkFrame(parent)
    list_container.pack(fill="both", expand=True)

    self.listbox = CTkListbox(list_container, multiple_selection=True)
    self.listbox.pack(side="left", fill="both", expand=True)

    y_scrollbar = ctk.CTkScrollbar(list_container, orientation="vertical", command=self.listbox.yview)
    y_scrollbar.pack(side="right", fill="y")

    x_scrollbar = ctk.CTkScrollbar(parent, orientation="horizontal", command=self.listbox.xview)
    x_scrollbar.pack(side="bottom", fill="x")

    self.listbox.configure(yscrollcommand=y_scrollbar.set, xscrollcommand=x_scrollbar.set)

    self.listbox.drop_target_register(DND_FILES)
    self.listbox.dnd_bind('<<Drop>>', self.on_drop)
    self.listbox.bind('<Delete>', self.delete_selected_items)

    button_frame = ctk.CTkFrame(parent)
    button_frame.pack(fill="x", pady=5)

And the layout changes made the buttons disapear...
Hope they are 1 to 1 replaceable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant