Taking out the sizer.Fit(self) line changes the size, but
unfortunately doesn't fix the problem. When I comment out that line,
the control is a different size but it appears to be some kind of
default size and much bigger than necessary. I tried wx.CallAfter but
that didn't work either.
This is my rather ugly solution to the problem:
w = self.ballotC.GetColumnWidth(0) + self.ballotC.GetColumnWidth(1) + 20
sizer.SetItemMinSize(self.ballotC, (w, -1))
This tells the sizer to give a specified minimum width for the
wx.ListCtrl. The column widths get me close to the right size, but I
need a little padding and throw in 20 pixels.
I've been using wxPython for a few years and can generally figure
things out, but I'm really stumped by this one. I'm trying to use a
wx.ListCtrl for this first time, but the default sizing isn't what I
would like.It appears that for a wxListCtrl the following
GetSize()
GetBestSize()
GetEffectiveMinSize()
always return (100, 80) regardless of the contents of the wxListCtrl.I would like to set the size of the wxListCtrl so that it is big
enough to not need scroll bars. Is there an easy way to do this?If it helps, I have an example below.
Jeff
It looks like the "sizer.Fit(self)" line in your MyFrame class is the
issue. I commented that line out on my machine and it worked fine then.
I'm using Windows XP, wxPython 2.8.9.1., Python 2.5.2. I can't tell you
exactly why this is happening though. I'm guessing that when the Fit is
called in the Frame, it's doing it before the ListCtrl is fully
initialized so that the panel is not expanded yet. You could try
sticking the Fit() call in MyFrame in a wx.CallAfter() to see if that
works...
Or maybe someone else will have a clue.
···
-------------------