Search code examples
wxpythonwxgrid

wxPython, wxGrid: remove the white part on the bottom of the grid?


I'm building a small wxPython app which role is to display Clearquest information in a wxGrid. The grid's parent is a panel, the panel parent is a notebook. Everytime I click on a button, I create a new page, get my information and display them. So far so good.

My issue is that, when I scroll to the bottom of the grid, there is an horizontal blank space that I would like to get rid off. Could anyone tell me if there is a way to remove it?

Here is a picture to help understand my issue. I would like to get rid of the white space in the red rectangle.

edit: As asked below, here are some precisions about how the sizers are defined: As you can see, the window is divided in two parts: - the left part is dedicated to the notebook. Each tab of the notebook is a panel in which a wx.Grid is used to display my data - the right part is dedicated to the buttons (it's a Static Box) that triggers the data retrieval.

First, I declare the frame in which I set the panel that will contain the notebook and the Static Box for the buttons (I show the code for only one button, the others don't matter):

class MainFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, parent=None, title='ClearQuest Python Edition')
        self.queryHandler = CQHandler.QueryHandler()
        panel = wx.Panel(self)
        queryButtonsBox = wx.StaticBox(panel, -1, 'Run queries')
        queryButtonsSizer = wx.StaticBoxSizer(queryButtonsBox, wx.VERTICAL)
        queryButtonDAS = wx.Button(panel, label="DAS", name="1")
        queryButtonsSizer.Add(queryButtonDAS, flag=wx.TOP | wx.EXPAND, border = 5)
        queryButtonDAS.Bind(wx.EVT_BUTTON, self.QueryButtonClick)
        self.noteBook = MyNoteBook(panel)
        HBox = wx.BoxSizer(wx.HORIZONTAL)
        HBox.Add(self.noteBook, 1, wx.EXPAND, 0)
        HBox.Add(queryButtonsSizer, 0, wx.ALL, 5)
        panel.SetSizer(HBox)

And here is how the notebook and each tab of the notebook are declared and called:

class MyNoteBook(wx.Notebook):

    def __init__(self, parent):
        wx.Notebook.__init__(self, parent, id=wx.ID_ANY, style=wx.BK_DEFAULT)

    def AddQueryPanel(self, title):
        newTab = TabPanel(self)
        self.AddPage(newTab, title, True)
        self.CurrentPage.dataGrid.ForceRefresh()


class TabPanel(wx.Panel):

        def __init__(self, parent):
            wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
            self.dataGrid = MainGrid(self)
            horizontalSizer = wx.BoxSizer(wx.HORIZONTAL)
            horizontalSizer.Add(self.dataGrid, 1, wx.EXPAND | wx.ALL, 0)
            self.SetSizer(horizontalSizer)

And finally, a small sample of my MainGrid, if it can help:

class MainGrid(GridLib.Grid):

    def __init__(self, parent):
        self.queryHandler = CQHandler.QueryHandler()
        self.GetQueryInfo()
        self.style = GUI.Style.StyleHandler()
        GridLib.Grid.__init__(self, parent)
        self.SetGridLineColour("black")
        self.SetRowLabelSize(25)
        self.SetDefaultRowSize(20)
        self.CreateGrid(self.numberOfRows, self.NumberOfColumns)
        self.ConfigureEvents()
        for i in range(self.NumberOfColumns):
            self.SetColLabelValue(i, self.Headers[i])
        self.EnableEditing(False)
        self.CRList = self.queryHandler.GetCRList()
        self.DisplayCR()

Solution

  • How are the sizers applied? need some details about the code.