- Joined
- Apr 13, 2011
- Messages
- 5
- Reaction score
- 0
I want to limit the size of a list control box. Let us take the following code:
The result of above code is shown in picture below
If I make the horizontal box sizer's proportion=0 (as shown in the code snippet below):
then the result of the code is shown in picture below:
The problem with proportion=1 is that after 'Age' column, there is a lot of empty space the list control box is eating up for the third column which doesn't exist.
The problem with proportion=0 is that it is too short in width.
I want to display the list control box with 'Name' and 'Age' columns only and save the rest of the space. How do I do that?
Code:
import wx
class Students(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(380, 230))
hbox = wx.BoxSizer(wx.HORIZONTAL)
panel = wx.Panel(self, -1)
self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT)
self.list.InsertColumn(0, 'name')
self.list.InsertColumn(1, 'age')
hbox.Add(self.list, 1,wx.EXPAND)
panel.SetSizer(hbox)
self.Centre()
self.Show(True)
app = wx.App()
Students(None, -1, 'studs')
app.MainLoop()
If I make the horizontal box sizer's proportion=0 (as shown in the code snippet below):
Code:
hbox.Add(self.list, 0,wx.EXPAND)
The problem with proportion=1 is that after 'Age' column, there is a lot of empty space the list control box is eating up for the third column which doesn't exist.
The problem with proportion=0 is that it is too short in width.
I want to display the list control box with 'Name' and 'Age' columns only and save the rest of the space. How do I do that?