i'm trying to get scrollbars for a wx.grid in a wx.dialog. This is my
original code, which has a resizable dialog but no scrollbars for the
grid:
class DialogChemicalTable(wx.Dialog):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Dialog.__init__(self, id=wx.ID_ANY,
name='DialogChemicalTable', parent=prnt,
#pos=wx.Point(780, 336),
#size=wx.Size(598, 411),
style=wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE,
title='Edit Chemical Table')
# panels
panelMain = wx.Panel(self, wx.ID_ANY)
panelTable = wx.Panel(panelMain, wx.ID_ANY)
panelBottom = wx.Panel(panelMain, wx.ID_ANY)
panelBottom.SetBackgroundColour('gray')
grid = wx.grid.Grid(panelTable, -1)
table = ChemicalGridTable()
grid.SetTable(table, True)
boxSizerTable = wx.BoxSizer(wx.VERTICAL)
boxSizerTable.Add(grid)
panelTable.SetSizer(boxSizerTable)
it was suggested i make the following changes, but this produces a
dialog that is not resizable (although the grid is large enough to not
need scrollbars):
# panels
#panelMain = wx.Panel(self, wx.ID_ANY)
panelTable = wx.Panel(self, wx.ID_ANY)
panelBottom = wx.Panel(self, wx.ID_ANY)
panelBottom.SetBackgroundColour('gray')
grid = wx.grid.Grid(panelTable, -1)
table = ChemicalGridTable()
grid.SetTable(table, True)
boxSizerTable = wx.BoxSizer(wx.VERTICAL)
boxSizerTable.Add(grid)
panelTable.SetSizer(boxSizerTable)
boxSizerBottom = wx.BoxSizer(wx.HORIZONTAL)
# navigation buttons
buttonUpFirst = wx.BitmapButton(bitmap = wx.Bitmap('images/
UpFirst.png', wx.BITMAP_TYPE_PNG), parent = panelBottom, id =
wx.ID_ANY, name = "upFirst")
buttonUpFirst.SetToolTip(wx.ToolTip("Up to first entry"))
buttonUp = wx.BitmapButton(bitmap = wx.Bitmap('images/up.png',
wx.BITMAP_TYPE_PNG), parent = panelBottom, id = wx.ID_ANY, name =
"up")
buttonUp.SetToolTip(wx.ToolTip("Up one entry"))
buttonDown = wx.BitmapButton(bitmap = wx.Bitmap('images/
down.png', wx.BITMAP_TYPE_PNG), parent = panelBottom, id = wx.ID_ANY,
name = "down")
buttonDown.SetToolTip(wx.ToolTip("Down one entry"))
buttonDownLast = wx.BitmapButton(bitmap = wx.Bitmap('images/
DownLast.png', wx.BITMAP_TYPE_PNG), parent = panelBottom, id =
wx.ID_ANY, name = "downLast")
buttonDownLast.SetToolTip(wx.ToolTip("Down to last entry"))
staticBoxSizerNavigate =
wx.StaticBoxSizer(wx.StaticBox(panelBottom, -1,"Navigate"),
wx.HORIZONTAL)
staticBoxSizerNavigate.Add(buttonUpFirst)
staticBoxSizerNavigate.Add(buttonUp)
staticBoxSizerNavigate.Add(buttonDown)
staticBoxSizerNavigate.Add(buttonDownLast)
boxSizerBottom.Add(staticBoxSizerNavigate, 1, wx.LEFT)
# edit buttons
buttonPost = wx.BitmapButton(bitmap = wx.Bitmap('images/
Post.png', wx.BITMAP_TYPE_PNG), parent = panelBottom, id = wx.ID_ANY,
name = "upFirst")
buttonPost.SetToolTip(wx.ToolTip("Save changes"))
buttonCancel = wx.BitmapButton(bitmap = wx.Bitmap('images/
cancel.png', wx.BITMAP_TYPE_PNG), parent = panelBottom, id =
wx.ID_ANY, name = "up")
buttonCancel.SetToolTip(wx.ToolTip("Exit and do not save
changes"))
staticBoxSizerEdit =
wx.StaticBoxSizer(wx.StaticBox(panelBottom, -1,"Edit"), wx.HORIZONTAL)
staticBoxSizerEdit.Add(buttonPost)
staticBoxSizerEdit.Add(buttonCancel)
boxSizerBottom.Add(staticBoxSizerEdit, 1, wx.CENTER)
dialogBoxSizer = wx.BoxSizer(wx.VERTICAL)
dialogBoxSizer.Add(self, proportion=1, flag=wx.EXPAND)
panelBottom.SetSizer(boxSizerBottom)
boxSizerMain = wx.BoxSizer(wx.VERTICAL)
boxSizerMain.Add(panelTable, 1, wx.ALIGN_TOP | wx.EXPAND)
boxSizerMain.Add(panelBottom, 0, wx.ALIGN_BOTTOM | wx.EXPAND)
self.SetSizerAndFit(boxSizerMain)
self.Layout
self.SetSizer(dialogBoxSizer)
self.Layout()
self.Center()
self.Show(True)
any help would be appreciated.
thanks,
bob k.