Question

I wanted to ask if it is possible to draw a child window inside a parent window so that it will only be able to move inside the parent window and won't be able to move out of the parent window bounds.

Was it helpful?

Solution

If you mean having actual windows with title bar, menu, status bar etc. inside the parent window then the answer is: No, Tcl/Tk and by extension Tkinter does not support this with its standard widgets.

There have been efforts in the past to implement widgets which emulate MDI as you can see on the TCL wiki, but most of them are over a decade old. You will probably have to implement it yourself or choose a different GUI toolkit if you really need to implement this kind of UI design.

If you do it yourself, you can use the Frame widget as the subwindow, and use place to put it in the containing window. Or, you can create it as an object on a canvas. You'll have to write all of the code to give the inner window borders and a title bar, and to manage moving it around, iconifying it, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top