gridSizer inside a panel element

G

Gandalf

why when I try to insert gridSizer to a panel which already inside
another panel the gridSizer doesn't work?

this is the code:

panel3= wx.Panel(self, -1, (0, 60), size=(400, 240) ,
style=wx.SIMPLE_BORDER);
panel3.SetBackgroundColour('#dadadb')
panel = wx.Panel(panel3, wx.ID_ANY, style=wx.SIMPLE_BORDER,
size=(150, 60))
panel.SetBackgroundColour("#fffFFF")

bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_OTHER, (16,
16))
inputIco = wx.StaticBitmap(panel, wx.ID_ANY, bmp)

labelThree= wx.StaticText(panel, wx.ID_ANY, 'Hello')

label2=wx.StaticText(panel, wx.ID_ANY, 'Pease, Quite, Hello, Shalom')
topSizer = wx.BoxSizer(wx.VERTICAL)
gridSizer = wx.GridSizer(rows=2, cols=1, hgap=5, vgap=5)
input = wx.BoxSizer(wx.HORIZONTAL)
output = wx.BoxSizer(wx.HORIZONTAL)


input.Add((20,20), 1, wx.EXPAND) # this is a spacer
input.Add(inputIco, 0, wx.ALL, 5)
input.Add(labelThree, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)

output.Add((20,20), 1, wx.EXPAND) # this is a spacer

output.Add(label2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)

gridSizer.Add(input, 0, wx.ALIGN_LEFT)
gridSizer.Add(output, 0, wx.ALIGN_RIGHT)

topSizer.Add(gridSizer, 0, wx.ALL|wx.EXPAND, 5)
panel.SetSizer(topSizer)
 
I

Iain King

why when I try to insert gridSizer to a panel which already inside
another panel the gridSizer doesn't work?

this is the code:

panel3= wx.Panel(self, -1, (0, 60), size=(400, 240) ,
style=wx.SIMPLE_BORDER);
panel3.SetBackgroundColour('#dadadb')
panel = wx.Panel(panel3, wx.ID_ANY, style=wx.SIMPLE_BORDER,
size=(150, 60))
panel.SetBackgroundColour("#fffFFF")

bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_OTHER, (16,
16))
inputIco = wx.StaticBitmap(panel, wx.ID_ANY, bmp)

labelThree= wx.StaticText(panel, wx.ID_ANY, 'Hello')

label2=wx.StaticText(panel, wx.ID_ANY, 'Pease, Quite, Hello, Shalom')
topSizer = wx.BoxSizer(wx.VERTICAL)
gridSizer = wx.GridSizer(rows=2, cols=1, hgap=5, vgap=5)
input = wx.BoxSizer(wx.HORIZONTAL)
output = wx.BoxSizer(wx.HORIZONTAL)

input.Add((20,20), 1, wx.EXPAND) # this is a spacer
input.Add(inputIco, 0, wx.ALL, 5)
input.Add(labelThree, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)

output.Add((20,20), 1, wx.EXPAND) # this is a spacer

output.Add(label2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)

gridSizer.Add(input, 0, wx.ALIGN_LEFT)
gridSizer.Add(output, 0, wx.ALIGN_RIGHT)

topSizer.Add(gridSizer, 0, wx.ALL|wx.EXPAND, 5)
panel.SetSizer(topSizer)

I'm not sure you can just add sizers together like that. When I'm
doing this I'd make panels for each sub-sizer; so input and output
would be panels rather than the sizers themselves. For example
(untested):

grid = wx.Panel(panel, wx.ID_ANY)

input = wx.Panel(grid, wx.ID_ANY)
inputIco = wx.StaticBitmap(input, wx.ID_ANY, bmp)
labelThree= wx.StaticText(input, wx.ID_ANY, 'Hello')
sz = wx.BoxSizer(wx.HORIZONTAL)
sz.Add((20,20), 1, wx.EXPAND) # this is a spacer
sz.Add(inputIco, 0, wx.ALL, 5)
sz.Add(labelThree, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
input.SetSizer(sz)

output = = wx.Panel(grid, wx.ID_ANY)
label2=wx.StaticText(output, wx.ID_ANY, 'Pease, Quite, Hello, Shalom')
sz = wx.BoxSizer(wx.HORIZONTAL)
sz.Add((20,20), 1, wx.EXPAND) # this is a spacer
sz.Add(label2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
output.SetSizer(sz)

sz = wx.GridSizer(rows=2, cols=1, hgap=5, vgap=5)
sz.Add(input, 0, wx.ALIGN_LEFT)
sz.Add(output, 0, wx.ALIGN_RIGHT)
grid.SetSizer(sz)

sz = wx.BoxSizer(wx.VERTICAL)
sz.Add(grid, 0, wx.ALL|wx.EXPAND, 5)
panel.SetSizer(sz)

Iain
 
M

Mike Driscoll

why when I try to insert gridSizer to a panel which already inside
another panel the gridSizer doesn't work?

this is the code:

<snip>

I'm not sure how to do multiple panels like that. And I'm not really
sure what you're trying to achieve by doing that anyway. Regardless,
you should post these types of questions to the wxPython user's group
where they can tell you exactly what you need to know:

http://wxpython.org/maillist.php

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top