pythonuser-interfacetkinter

Creating a Toplevel window using tkinterDnD2


I'm using tkinterDnD2 for my python GUI. I'm quite familiar with tkinter and, if I want to create a Toplevel window with another windoe, root as a parent, then I'd use the code

import tkinter as tk

toplevel = tk.Toplevel(root)

However, if I try using tkinterDnD2 for the same task

from tkinterdnd2 import *

toplevel = TkinterDnD.Toplevel(root)

I get the error

    toplevel = TkinterDnD.Toplevel(root)
               ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'tkinterdnd2.TkinterDnD' has no attribute 'Toplevel'

The documentation doesn't help that much on this regard and I was hoping that perhaps someone here knew how to create a toplevel window using tkinterDnD2 (or if it was possible). I'm trying to create a window (different from my main window), that has drag and drop capabilities.


Solution

  • @jasonharper 's comment solves it: if the main window is a tkinterdnd, then any tk.Toplevel window, with said main window as parent, will also have DnD capabilities.