put a Button into a frame in python tkinter -
i trying template tkinter application. cant put buttons frames.
is frame right control use template? or there different.
from tkinter import * root = tk() frame = frame(root, height="200", width="200", bg="green").pack() b = button(frame, text="hell world").pack(padx="10", pady="10") z = label(root, text="outside").pack() root.mainloop()
this code.
the code runs, button beneath green frame. want have button inside of frame.
is possible?
frame = frame(root, height="200", width="200", bg="green").pack()
after line executes, frame
equal none
because that's pack()
returns. need assign widget , pack on separate lines if want keep reference it.
frame = frame(root, height="200", width="200", bg="green") frame.pack()
same b
, z
, never use them don't matter much.
Comments
Post a Comment