By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

Grid question: How do I force grid elements to expand and use available space

P: n/a
Hi all,

Perplexed by this. I thought the sticky option was supposed to
accomplish this task, but it doesn't seem to be working. Here is what
I'm trying to accomplish.

Window
----------------------------
| --Beginning of group--
| Cell1 Cell2 Cell3
| Cell4 Cell5 Cell6
| -- End of group --
|
| --Beginning of group--
| Cell7 Cell8 Cell9
| Cell10 Cell11 Cell12
| -- End of group --
-----------------------------

Instead, here's what I'm getting:

----------------------------
| --Beginning of group--
| Cell1 Cell2 Cell3
| Cell4 Cell5 Cell6
| -- End of group --
|
| --Beginning of group--
| Cell7 Cell8 Cell9
| Cell10Cell11Cell12
| -- End of group --
-----------------------------
The cells in the top group are larger and take up more space;
therefore the cells below do not align correctly. I would like them to
all line up like they were in an spreadsheet. I want them in different
groups because they are in different categories, and I'm using the
group boundary as a separator.

Here is my code:

#### Insert options for Support Services
ssGroup = Pmw.Group(self.configScreen, tag_text="Support
Services", tag_foreground='dark green')

## Insert Title
Label( ssGroup.interior() , text='Part Number', font=('MS',
10, 'bold') ).grid(row=0, col=0, sticky=W, padx=0 )
Label( ssGroup.interior(), text='Description', font=('MS', 10,
'bold') ).grid(row=0, col=1, sticky=W, padx=2 )
Label( ssGroup.interior(), text='Quantity', font=('MS', 10,
'bold') ).grid(row=0, col=2, sticky=W, padx=0 )

x = 1
self.e = IntVar()
for part, list in info.masterList.items():
setattr( self.e, part, IntVar() )

for part, list in info.masterList.items():
print part
if list[5] == "ss":
Label( ssGroup.interior() , text=part ).grid(row=x,
col=0, sticky=W, padx=0 )
Label( ssGroup.interior(), text=list[0] ).grid(row=x,
col=1, sticky=W, padx=2 )
Entry( ssGroup.interior(), width=3, textvariable =
getattr(self.e, part),
text='0').grid(row=x, col=2, sticky=W, padx=4 )
e = getattr(self.e, part)
e.set(0)
x += 1

ssGroup.pack(expand=1, fill=X, ipady=5)

#### Insert options for Professional Services
psGroup = Pmw.Group(self.configScreen, tag_text="Professional
Services", tag_foreground='dark green')

## Insert Title
Label( psGroup.interior() , text='Part Number', font=('MS',
10, 'bold') ).grid(row=0, col=0, sticky=EW, padx=0 )
Label( psGroup.interior(), text='Description', font=('MS', 10,
'bold') ).grid(row=0, col=1, sticky=EW, padx=2 )
Label( psGroup.interior(), text='Quantity', font=('MS', 10,
'bold') ).grid(row=0, col=2, sticky=EW, padx=0 )
x = 1
for part, list in info.masterList.items():
print part
if list[5] == "ps":
Label( psGroup.interior() , text=part ).grid(row=x,
col=0, sticky=EW, padx=0 )
Label( psGroup.interior(), text=list[0] ).grid(row=x,
col=1, sticky=EW, padx=2 )
Entry( psGroup.interior(), width=3, textvariable =
getattr(self.e, part),
text='0').grid(row=x, col=2, sticky=EW, padx=4
)
e = getattr(self.e, part)
e.set(0)
x += 1

psGroup.pack(expand=1, fill=X, ipady=5)
The bottom group properly expands to take up the available space left
over from the larger top group. I thought that the sticky option was
supposed to make the cells expand, but it doesn't appear to do so in
this case. How do I force the grid cells to expand also?

Thanks ahead of time,
Marc
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.