Hello:
Thanks for the previous help, particularly to Robin.
And while Im at it, Robin thanks for the book--it
would be more difficult for a beginner like me without
it. I have three vertical BoxSizers placed in a
horizontal BoxSizer. In one vertical BoxSizer is a
wxGrid and I would like the grid to show all its
columns (i.e., no scroll). If any extra room is left,
I would like the spacing between vertical sizers to
adjust accordingly. The following code works except
that not all columns of the wxGrid are shown. Can
anyone tell me where I am going wrong? I dont want to
set the size of the wxGrid by hand (I'd like it to
size automatically).
Also, note that if you maximize the frame, there will
be an ugly white block to the right of the wxGrid. Im
just curious if there is a way to get rid of that.
Thanks much, John
#!/usr/bin/env python
import wx
import wx.grid
class myApp(wx.App):
def OnInit(self):
frame = Frame1("hello",(50,160),(450,340))
frame.Show()
self.SetTopWindow(frame)
return True
class Frame1(wx.Frame):
def __init__(self,title,pos,size):
wx.Frame.__init__(self,None,-1,title,pos,size)
panelA = wx.Panel(self, -1, name='panelA',
pos=wx.Point(0, 0), style=wx.TAB_TRAVERSAL )
mainBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
boxsizer_1 = wx.BoxSizer(wx.VERTICAL)
boxsizer_2 = wx.BoxSizer(wx.VERTICAL)
boxsizer_3 = wx.BoxSizer(wx.VERTICAL)
txtctrl_1= wx.TextCtrl(panelA, -1, size=(100,-1))
txtctrl_2= wx.TextCtrl(panelA, -1, size=(100,-1))
grid_1 = wx.grid.Grid(panelA, -1, size=(-1,-1))
boxsizer_1.Add(txtctrl_1, 0, wx.TOP | wx.EXPAND,
border=0)
boxsizer_2.Add(txtctrl_2, 0, wx.TOP | wx.EXPAND,
border=0)
boxsizer_3.Add(grid_1, 0, wx.TOP | wx.EXPAND,
border=0)
# put columns together
mainBoxSizer.Add(boxsizer_1, 0, flag=wx.EXPAND |
wx.ALL, border=6)
mainBoxSizer.Add(boxsizer_2, 0, flag=wx.EXPAND |
wx.ALL, border=6)
mainBoxSizer.Add(boxsizer_3, 1, flag=wx.EXPAND |
wx.ALL, border=6)
grid_1.CreateGrid(8,12)
grid_1.SetDefaultColSize(55)
grid_1.SetRowLabelSize(40)
panelA.SetSizerAndFit(mainBoxSizer)
if __name__ == '__main__':
#app = MixLowApp(True)
app = myApp(False)
app.MainLoop()
···
____________________________________________________________________________________
Got a little couch potato?
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz