I want to limit the size of a list control box. Let us take the following 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()

The result of above code is shown in picture below
[IMG]http://img638.imageshack.us/img638/1996/wxlistctrlprop1.png[/IMG]

If I make the horizontal box sizer's proportion=0 (as shown in the code snippet below):

hbox.Add(self.list, 0,wx.EXPAND)

then the result of the code is shown in picture below:
[IMG]http://img846.imageshack.us/img846/8183/wxlistctrlprop0.png[/IMG]

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.