This one works fine for me. Salt and season to taste.
import wx
import wx.grid as gridlib
app= wx.PySimpleApp()
frame= wx.Frame( None )
resultGrid = gridlib.Grid( frame )
resultGrid.CreateGrid(5,3) # 5 rows by 3 columns
resultGrid.SetRowLabelSize(0)
resultGrid.SetColLabelValue(0, "Server")
resultGrid.SetColLabelValue(1, "UserName")
resultGrid.SetColLabelValue(2, "ReturnValue")
resultGrid.SetDefaultColSize(175)
sizer= wx.BoxSizer( wx.VERTICAL )
sizer.Add( resultGrid, 1, wx.EXPAND )
buttons= [ wx.Button( frame, label= '%i'% i ) for i in range( 3 ) ]
buttons[0].SetDefault()
buttons[0].SetFocus()
[ sizer.Add( button ) for button in buttons ]
frame.SetSizer( sizer )
class Ref:
def __init__( self, val ): self.val= val
i= Ref( 0 )
def f( event ):
print 'event!'
resultGrid.SetCellValue( i.val% 5, 0, 'what +%i.'% ( i.val+ 1 ) )
i.val+= 1
buttons[0].Bind( wx.EVT_BUTTON, f )
frame.Show()
app.MainLoop()
ยทยทยท
-----Original Message-----
From: Glenn Farkas [mailto:glenn@glennfarkas.com]
Sent: Tuesday, January 15, 2008 2:11 PMThe function behind the "Retrieve" button, for the display test, simply
does a call to insert a row into the grid. The information shows up in
the grid, but then it looks like the sizers resize themselves smaller
than the panel, leaving the window looking odd. If I do a resize of the
frame, the sizers resize correctly to the frame.