You don’t set the size of the grid, so it’s just using the minimum amount of size necessary. If you want a more accurate size, you would be better off changing that line to
self.GetTopLevelParent().GetSize()
This will get you a lot closer to what you want. When I tried it, the grid was actually wider than the screen and had scrollbars. I personally prefer that to the white background. If you want, you could set the size of the frame and use that size for your grid as well.
Mike
···
On Thursday, July 17, 2014 4:01:17 PM UTC-5, steve wrote:
Hi,
I try to place a wx.grid on a panel, and make its columns expand to parent, but I get a white space on the right side of cells:
I do:
import wx.grid as gridlib
class SidePanelGrid(gridlib.Grid):
def init(self, parent):
gridlib.Grid.init(self, parent, -1, name=“Side Panel Capacity Grid”)
self.CreateGrid(3,4)
self.HideRowLabels()
self.HideColLabels()
self.ShowScrollbars(wx.SHOW_SB_NEVER,wx.SHOW_SB_NEVER)
widt, heig = self.GetSize()
print "widt: ", widt
for row in xrange(3):
self.DisableRowResize(row)
for col in xrange(4):
self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
for col in xrange(4):
self.SetColSize(col, (widt/4))
self.DisableColResize(col)
But I set the size of each column to 1/4 of grid size (there are 4 columns), so why is there whitespace on the right side of the cells?
self.SetColSize(col, (widt/4))
···
On Friday, July 18, 2014 12:23:59 AM UTC+3, Mike Driscoll wrote:
On Thursday, July 17, 2014 4:01:17 PM UTC-5, steve wrote:
Hi,
I try to place a wx.grid on a panel, and make its columns expand to parent, but I get a white space on the right side of cells:
I do:
import wx.grid as gridlib
class SidePanelGrid(gridlib.Grid):
def init(self, parent):
gridlib.Grid.init(self, parent, -1, name=“Side Panel Capacity Grid”)
self.CreateGrid(3,4)
self.HideRowLabels()
self.HideColLabels()
self.ShowScrollbars(wx.SHOW_SB_NEVER,wx.SHOW_SB_NEVER)
widt, heig = self.GetSize()
print "widt: ", widt
for row in xrange(3):
self.DisableRowResize(row)
for col in xrange(4):
self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
for col in xrange(4):
self.SetColSize(col, (widt/4))
self.DisableColResize(col)
self.my_grid = SidePanelGrid(self)
It doesn’t work. What do I do wrong above?
You don’t set the size of the grid, so it’s just using the minimum amount of size necessary. If you want a more accurate size, you would be better off changing that line to
self.GetTopLevelParent().GetSize()
This will get you a lot closer to what you want. When I tried it, the grid was actually wider than the screen and had scrollbars. I personally prefer that to the white background. If you want, you could set the size of the frame and use that size for your grid as well.
Because the grid is expanding, but the columns are not. The columns don’t expand when you change the size of your frame. If you want that to happen, you would have to catch EVT_SIZE and modify the grid’s column sizes yourself.
Mike
···
On Thursday, July 17, 2014 4:28:31 PM UTC-5, steve wrote:
But I set the size of each column to 1/4 of grid size (there are 4 columns), so why is there whitespace on the right side of the cells?
But the whitespace is there when I first start the application as well. I don’t resize the window manually.
···
On Friday, July 18, 2014 12:41:11 AM UTC+3, Mike Driscoll wrote:
On Thursday, July 17, 2014 4:28:31 PM UTC-5, steve wrote:
But I set the size of each column to 1/4 of grid size (there are 4 columns), so why is there whitespace on the right side of the cells?
self.SetColSize(col, (widt/4))
Because the grid is expanding, but the columns are not. The columns don’t expand when you change the size of your frame. If you want that to happen, you would have to catch EVT_SIZE and modify the grid’s column sizes yourself.
wx.GROW is alias of wx.EXPAND, don’t know what happens if you use
both at the same time, don’t they negate each other?
wx.GROW
8192
wx.EXPAND
8192
Werner
Honestly, aren’t they teaching you kids Boolean algebra in high
school any more? “|” is the logical “or” operator. 1|1 == 1. In
fact, for any x, x|x == x.
···
Werner wrote:
wx.GROW is alias of wx.EXPAND, don't know what happens if you use
both at the same time, don’t they negate each other?
wx.GROW
8192
wx.EXPAND
8192
Kids, not sure I qualify for that and no never had algebra but then I didn’t
do high school or the equivalent when I want to school back a little
while ago,
but I know I should one day maybe learn this stuff.
Werner
···
On 7/18/2014 17:59, Tim Roberts wrote:
Honestly, aren't they teaching you kids Boolean algebra in high
school any more? “|” is the logical “or” operator. 1|1 == 1. In
fact, for any x, x|x ==
:-) ;-) ., ,
Werner wrote:
wx.GROW is alias of wx.EXPAND, don't know what happens if you
use both at the same time, don’t they negate each other?
wx.GROW
8192
wx.EXPAND
8192
Hi Steve,
Well actually , Tim, "|" is the bitwise or operator; "or" is of course the
logical or operator.
···
On Fri, Jul 18, 2014 at 11:59 AM, Tim Roberts <timr@probo.com> wrote:
Honestly, aren't they teaching you kids Boolean algebra in high school
any more? "|" is the logical "or" operator. 1|1 == 1. In fact, for any
x, x|x == x.