0

As title, i need to set window size with frame. i know with geometry. in the code, frame try to resize along widget size. i want it constant. so widget inside frame not involve with frame size.

for ex, if i remove button widget in code. window size will follow frame size.

root = tkinter.Tk()

s = ttk.Style()
s.configure('Login.TFrame', background='red')

login = ttk.Frame(root, style='Login.TFrame')
login.config(width=640, height=360)

// remove button widget makes window follow frame config size.
ttk.Button(login, text="Login").pack()        

login.pack(expand=True, fill=tkinter.BOTH)

root.mainloop()
yui amanda
  • 17
  • 2
  • Try `login.pack_propagate(False)` – TheLizzard Sep 15 '21 at 16:08
  • @TheLizzard where u get all frame's method? it looks so easy. but i cant find completely documentation that list each widget method. – yui amanda Sep 15 '21 at 16:10
  • 1
    Well `tkinter` isn't well documented anywhere but look at [this](http://web.archive.org/web/20201112021403/https://effbot.org/tkinterbook/widget.htm#Tkinter.Widget.pack_propagate-method) – TheLizzard Sep 15 '21 at 16:12
  • Tk is documented, but you have to translate languages from Tcl to Python for use with Tkinter. In this case, https://www.tcl.tk/man/tcl/TkCmd/pack.html#M24 – patthoyts Sep 15 '21 at 16:41
  • You can get help on all methods of a frame with `help(tk.Frame)` (or the appropriate variation for how you are importing tkinter) – Bryan Oakley Sep 15 '21 at 16:50

0 Answers0