473,789 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pack() and the division of vertical space

I am trying to figure out how to stack two widgets in a frame
vertically so that they both expand horizontally and during vertical
expansion, the top one sticks to the top of the frame and the bottom
one consumes the remaining vertical space. I thought this would do it
but it doesn't. What am I missing?

from Tkinter import *

class AFrame(Frame):
def __init__(self,m aster,**config) :
Frame.__init__( self,master,con fig)
size=50
self.l1= Label(text="abc ",relief="groov e")
self.l1.pack(si de=TOP,expand=Y ES,fill=X,ancho r=N)
self.l2= Label(text="abc ",relief="groov e")
self.l2.pack(si de=TOP,expand=Y ES,fill=BOTH)

af= AFrame(None)
af.pack(side=TO P,expand=YES,fi ll=BOTH)
mainloop()

May 31 '07 #1
2 1485
On Thu, 31 May 2007 19:45:04 +0200, ch************* *****@yahoo.com
<ch************ ******@yahoo.co mwrote:
I am trying to figure out how to stack two widgets in a frame
vertically so that they both expand horizontally and during vertical
expansion, the top one sticks to the top of the frame and the bottom
one consumes the remaining vertical space. I thought this would do it
but it doesn't. What am I missing?
[snip code]

For this kind of stuff, don't use pack; use grid. It will be far easier to
get it working, to read afterwards and to maintain, even if it's slightly
more verbose. IMHO, pack should only be used to create rows or columns of
widgets, without any resizing policy, or to put an entire widget into a
container. If you do anything more complicated than that, you'll find grid
much easier to handle.

HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"
Jun 1 '07 #2
On Jun 1, 3:13 am, "Eric Brunel" <see.signat...@ no.spamwrote:
On Thu, 31 May 2007 19:45:04 +0200, christopherlmar sh...@yahoo.com

<christopherlma rsh...@yahoo.co mwrote:
I am trying to figure out how to stack two widgets in a frame
vertically so that they both expand horizontally and during vertical
expansion, the top one sticks to the top of the frame and the bottom
one consumes the remaining vertical space. I thought this would do it
but it doesn't. What am I missing?

[snip code]

For this kind of stuff, don't use pack; use grid. It will be far easier to
get it working, to read afterwards and to maintain, even if it's slightly
more verbose. IMHO, pack should only be used to create rows or columns of
widgets, without any resizing policy, or to put an entire widget into a
container. If you do anything more complicated than that, you'll find grid
much easier to handle.

HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"
Thanks, I basically came to the same conclusion shortly after writing
my post. I got it working with grid like this:

from Tkinter import *

class AFrame(Frame):
def __init__(self,m aster,**config) :
Frame.__init__( self,master,con fig)
top= self.winfo_topl evel()
top.columnconfi gure(0,weight=1 )
top.rowconfigur e(0,weight=1)
self.grid(row=0 ,column=0,stick y="NEWS")
self.rowconfigu re(0,weight=0)
self.rowconfigu re(1,weight=1)
self.columnconf igure(0,weight= 1)
self.l1= Label(self,text ="abc",relief=" groove")
self.l1.grid(ro w=0,column=0,st icky="NEW")
self.l2= Label(self,text ="abc",relief=" groove")
self.l2.grid(ro w=1,column=0,st icky="NEWS")

af= AFrame(None)
mainloop()

Jun 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12351
by: Applebrown | last post by:
Hello, basically, I'm just learning intermediate CSS and trying to convert my old table webpage completely to CSS. Hoorah, right? Well, it's not quite going as planned. It's an extremely simple layout, and I'm finding myself stuck with small white space in between my images where I planned for the graphics to be stacked up right on top of one another. Here's the simple vertical layout: width is 640px, centered with a CSS border. I'd...
16
9264
by: Uncle Pirate | last post by:
This has me stumped. I am trying to use as little space as possible at the top of my document but Firefox/Mozilla insists on placing vertical space before any element. IE displays it correctly (as I want). At one point, I set some negative top margins which moved the graphics above the page in IE. Here's the link: http://abateofnm.org/ I've tried reformatting the HTML to assure there is no white space and I've tried setting top...
0
2292
by: Penguin | last post by:
Using Access 97, I've created a grading sheet. To save space, the subjects are in vertical columns on a sub-report, like so: Math Spelling Reading N C T A A E U A I C C X M L M C C P B C E U U R E U S R R E
7
15634
by: bienwell | last post by:
Hi, I'm using the CheckBoxList control in ASP.NET for Web development. This checkboxlist is bound by the database. If we have more items for this checkbox list, it takes space on the page. I want to have vertical scroll bar (like CheckedListBox in Window development) to save space. Can we do that in ASP.NET ? Please give me your suggestions ? Thanks in advance.
1
1905
by: PaulB | last post by:
In my application, I have many forms. Some of these forms contains some labels, which are placed in the header section, and act as a column header. Because of the available space, the orientation is vertical. This application (A2K format) is used by many users on different platforms and with both A2K and A2K3, without problems. However, one of the users reports that in the forms with vertical labels, the text is invisible. When these...
1
3476
by: Mark Fitzpatrick | last post by:
I haven't seen anyone mention it here yet so I thought it would be worth noting that MS has apparently released VS 2005 Service Pack 1. It's available at: http://www.microsoft.com/downloads/details.aspx?familyid=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=en A bit of a big download, but hopefully it will be worth it. --
1
6164
by: dave8421 | last post by:
Hi, I have a (strict) html document with the following portion: <ul> <li><img alt="" src="images/image1.jpg" /></li> <li><img alt="" src="images/image2.jpg" /></li> <li><img alt="" src="images/image3.jpg" /></li> <li><img alt="" src="images/image4.jpg" /></li> <li><img alt="" src="images/image5.jpg" /></li>
1
5657
by: platoon1sc | last post by:
Hi guys.I have a problem with Internet Explorer in my web-application. I have a vertical scrollbar into my jsps but firefox show the vertical srollbar, but IE doesn't. IE show a blank space where vertical scrollbat must be there. Where the FF show de scrollbar, IE show blank space, but doesn't show the scroll. My css for the scrool is: #content { clear: left; height:100%; width:100%; margin:5px; }
2
1508
Jezternz
by: Jezternz | last post by:
Okay basicly, I have a division inside a division. <html><body> <div id="container"> <div id="header">Main image</div> </div> </body> </html> and I want the container to grow as the the div's inside it are added. But for some reason it only grows if I add characters into it.(note this happens in FF, works fine in ie) eg: <html><body>
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10193
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6761
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.