Python Forum

Full Version: Frame size only works if frame is empty(Solved)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to have a set frame size so I can place my widgets where I like them but the frame only seems to give me my dimensions when I comment out the widgets.
Just a heads up I am teaching myself all of this for work.

from tkinter import *
import openpyxl
from PIL import ImageTk, Image

wb = openpyxl.load_workbook('test.xlsx')
ws = wb['Customer']
ws1 = wb['Invoice']
d = ws['D8'].value
rnginv = ws1['AA4'].value

root = Tk()

frame = Frame(width=1350, height=900)
frame.pack()

photo = ImageTk.PhotoImage(Image.open('DelusionalDesignslogo2.png'))
logo = Label(frame, image=photo)
logo.pack()
titleA = Label(frame, text=d)
titleA.pack()
labelrinv = Label(frame, text=rnginv)
labelrinv.pack()



root.wm_title('Delusion Designs CNC Invoice Program v1.0')
root.mainloop()
Thanks for any help I get.

Tuck
try adding:
frame.pack_propagate(False)
after calling pack
Thank you but that did not work.

Tuck
The other thing you can do, when packing,
is add fill=Both, expand=True
like:
frame.pack(fill=Both, expand=True)
I get this error.

Traceback (most recent call last):
File "C:/Users/Delusional Customer/PycharmProjects/DelusionalDesignsCNC/Invoice.py", line 14, in <module>
frame.pack(fill=Both, expand=True)
NameError: name 'Both' is not defined

Changed to "BOTH" and I am back at the original problem.
Window still only resizes if empty,
then use tkinter.BOTH
don't place in quotes
I just put quotes there to show what I changed.
did you try tkinter.BOTH ?