Python Forum
[Tkinter] Frame size only works if frame is empty(Solved)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Frame size only works if frame is empty(Solved)
#1
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
Reply
#2
try adding:
frame.pack_propagate(False)
after calling pack
Reply
#3
Thank you but that did not work.

Tuck
Reply
#4
The other thing you can do, when packing,
is add fill=Both, expand=True
like:
frame.pack(fill=Both, expand=True)
Reply
#5
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,
Reply
#6
then use tkinter.BOTH
don't place in quotes
Reply
#7
I just put quotes there to show what I changed.
Reply
#8
did you try tkinter.BOTH ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Horizontal extension of widgets + frame size adapted to content Fab117 3 344 Feb-22-2024, 06:54 PM
Last Post: deanhystad
  [Tkinter] TKinter Remove Button Frame Nu2Python 8 821 Jan-16-2024, 06:44 PM
Last Post: rob101
  Problem passing argument to functionin inTkinter frame ericwm7248 3 952 Sep-11-2023, 03:11 PM
Last Post: deanhystad
  [Tkinter] Help running a loop inside a tkinter frame Konstantin23 3 1,451 Aug-10-2023, 11:41 AM
Last Post: Konstantin23
  tkinter mapview in a frame janeik 2 1,246 Jun-22-2023, 02:53 PM
Last Post: deanhystad
  [Tkinter] Image in Frame in Tabbed Widget Columbo 4 2,083 Sep-28-2022, 08:04 PM
Last Post: deanhystad
  [Tkinter] Frame with treeview virencm 5 6,843 Feb-01-2022, 04:58 PM
Last Post: deanhystad
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 4,013 Sep-30-2021, 05:57 PM
Last Post: menator01
  [Tkinter] How to create scrollable frame mandiatutti 7 4,340 Aug-07-2021, 03:34 PM
Last Post: deanhystad
  [Tkinter] using different frame for some widgets rwahdan 1 2,349 Jul-13-2021, 08:32 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020