0

I'm trying to put a small frame in a larger frame but when I run this code it only gives me the smaller frame with the bigger mainframe nowhere in sight. I'm just beginning to learn how to make stuff in python so I could be completely wrong in my approach but I can't see what I'm doing wrong here. Any help would be really appreciated.

from tkinter import *

master = Tk()

main_frame = Frame(master,
                   width = '900',
                   height = '500',
                   bg = '#9bdcd5')


login_frame = Frame(main_frame,
                     width = '500',
                     height = '300',
                     bg = '#FFFFFF')

main_frame.pack()
login_frame.pack()

if __name__ == '__main__':
    mainloop()
quamrana
  • 37,849
  • 12
  • 53
  • 71
Cadda
  • 3
  • 1

1 Answers1

-1

I'm not entirely sure what happens with pack(), but I'm sure it must be wrong for the smaller frame. Try place() instead:

main_frame.pack()
login_frame.place(x=100,y=50)

if __name__ == '__main__':
    mainloop()
quamrana
  • 37,849
  • 12
  • 53
  • 71
  • Oh wow, it was that simple huh. It worked just like that, Thanks a lot dude! – Cadda Oct 25 '20 at 18:01
  • @Cadda This is not the reason why it didn't work. A frame would stay at whatever size it happens to be at the time until a new slave window is added, which it will fit itself to the size of the new slave. This behavior can be overwritten by `frame.propagate(0)`. See [this](https://stackoverflow.com/a/44338653/9284423) answer for more details. – Henry Yik Oct 25 '20 at 18:07