Limit the size of wxListCtrl in wxpython

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:
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
wxlistctrlprop1.png


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)
then the result of the code is shown in picture below:
wxlistctrlprop0.png


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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top