-2

I am trying to make a Tkinter app, and I need to nest a Tk object inside another. Is there any way to do it? This is my current code:

from tkinter import *
root = Tk()
def new():
   r =Tk()
   Label(r, text="new window").pack()
Message(root, text="Lorem ipsum dolorsunt in culpa qui officia orum.", width=50).pack()
Button(root, text="new window", command=new, padx=30).pack()
root.mainloop()
nerdguy
  • 174
  • 1
  • 16
  • Read [Why are multiple instances of Tk discouraged?](https://stackoverflow.com/questions/48045401/why-are-multiple-instances-of-tk-discouraged) – stovfl Feb 26 '20 at 14:57
  • It looks like you did little to no research. There are countless post on how to get a 2nd window in Tkinter. `Toplevel()` is the method you are looking for. That said your question is not formatted properly. – Mike - SMT Feb 26 '20 at 16:37
  • @Mike-SMT: they don't just want a second window, I think they want a second window _inside_ a window. – Bryan Oakley Feb 26 '20 at 18:55
  • @BryanOakley so just a frame? Or something they can drag around? – Mike - SMT Feb 26 '20 at 18:56
  • @Mike-SMT: I'm assuming they want to drag it around. – Bryan Oakley Feb 26 '20 at 19:01

1 Answers1

1

You cannot do what you want. You cannot embed an instance of Tk inside another instance of Tk.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685