Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8187567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:36:09+00:00 2026-06-07T02:36:09+00:00

I have three columns in my wx.ListCtrl(size=(-1,200)) . I would like the columns to

  • 0

I have three columns in my wx.ListCtrl(size=(-1,200)). I would like the columns to fill up the width of the ListCtrl after its created. Ideally, the first column can expand to fill up the extra space available. The second and third columns don’t need to expand, and preferably will not change in width (formatting ocd).

Currently, each ListCtrl column is set up using (width=-1).

I have a feeling I can use this section of the code to my advantage…

# Expand first column to fit longest entry item
list_ctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE)

Pseudo-code (perhaps):

# After wx.ListCtrl creation
Get width of ListCtrl control
Get width of each ListCtrl column
Calculate unused width of ListCtrl
Set first column width to original width + unused width

Added:

Given the following example, I don’t understand how to initiate the autowidthmixin. Currently, I am trying to put the listctrl inside a foldpanel. The foldpanel is a class and a function within the class creates the listctrl. I am not even confident that this can be done given the structure of my code at the moment!

class MyPanel(wx.Panel):

    def __init__(self, parent, dictionary):
        self.dictionary = dictionary
        """Constructor"""
        wx.Panel.__init__(self, parent)

        # Layout helpers (sizers) and content creation (setPanel)
        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.mainSizer)
        list_ctrl = self.setPanel()
        self.mainSizer.Add(list_ctrl, 0, wx.ALL | wx.EXPAND, 5)
        self.GetSizer().SetSizeHints(self)

    def setPanel(self):
        index = 0

        list_ctrl = wx.ListCtrl(self, size=(-1, 200),
                                style=wx.LC_REPORT | wx.BORDER_SUNKEN)

        list_ctrl.InsertColumn(0, "Variable", format=wx.LIST_FORMAT_LEFT, width=-1)
        list_ctrl.InsertColumn(1, "x", format=wx.LIST_FORMAT_RIGHT, width=-1)
        list_ctrl.InsertColumn(2, u"\u03D0", format=wx.LIST_FORMAT_RIGHT, width=-1)

        for key, value in self.dictionary.iteritems():
            list_ctrl.InsertStringItem(index, str(key))
            list_ctrl.SetStringItem(index, 1, ("%.2f" % value[0]))
            list_ctrl.SetStringItem(index, 2, ("%.8f" % value[1]))
            index += 1

        list_ctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE)
        list_ctrl.SetColumnWidth(1, wx.LIST_AUTOSIZE)
        list_ctrl.SetColumnWidth(2, wx.LIST_AUTOSIZE)

        return list_ctrl
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:36:11+00:00Added an answer on June 7, 2026 at 2:36 am

    You need to use the ListCtrlAutoWidthMixin mixin class. The wxPython demo application has an example in the ListCtrl demo. According to the documentation, you can use its setResizeColumn method to tell it which column to resize. The default is the last column.

    EDIT (07/05/2012): In your code, create a ListCtrl class similar to the one in the demo. It would look something like this:

        class TestListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
        def __init__(self, parent, ID, pos=wx.DefaultPosition,
                     size=wx.DefaultSize, style=0):
            wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
            listmix.ListCtrlAutoWidthMixin.__init__(self)
            self.setResizeColumn(0)
    

    Then when you instantiate it, you’d just call list_ctrl = TestListCtrl(arg1, arg2…argN)

    Note that I included a call to setResizeColumn() in my code above. It’s not tested, but it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying a different kind of sorting in Oracle.Its like I have three
I have three columns with date, var1 and var2. I like to create bar
I have three columns employeeID, intime and outtime.I want to get only first intime
I have three columns which are div s acting like table cells, one in
I have three columns that look something like this: Column1 Date1 Date2 Test2 2012-06-10
Have Three columns..Combine width of all three is fixed.. 2nd ( center ) column
I have three columns of information and I'd like to present a portion of
I have three columns in mysql table: tax_id, company_name, store_name. I need that tax_id
I have three columns, y, m, and d (year, month, and day) and want
i have three columns for Date In, Date Out, Total Days. If in Date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.