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 9135329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:48:36+00:00 2026-06-17T08:48:36+00:00

During a refactoring session, I put a lot of my gui code into little

  • 0

During a refactoring session, I put a lot of my gui code into little functions which directly inserts data into a wx.Sizer object.

For instance, this little function:

def buildStatusDisplay(self, status_disp, flag):
    grid = wx.FlexGridSizer(cols=1, hgap=5, vgap=0)
    font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.LIGHT, False, 'Segoe UI')
    for option in status_disp:
        left = wx.StaticText(self, -1, option)
        left.SetFont(font)
        grid.Add(left, 0, flag=flag)
    return grid

So it creates all of the StaticText objects using the throwaway left, and then returns the FlexGrid. However, I need some of the labels in the StaticText objects to update based on user input, but, I’m not sure how to access them.

I’ve looped through the sizer that gets returned from the function, but I don’t see anything relating to a way that would let me get reference to the objects which make up the sizer.

for i in dir(sizer):
    print i 

>>Add
>>AddF
>>AddGrowableCol
>>AddGrowableRow
>>AddItem
>>AddMany
>>AddSizer
>>AddSpacer
>>AddStretchSpacer
>>AddWindow
>>CalcMin
>>CalcRowsCols
>>Children
>>ClassName
>>Clear
>>ColWidths
>>Cols
>>ComputeFittingCli
>>ComputeFittingWin
>>ContainingWindow
>>DeleteWindows
>>Destroy
>>Detach
>>Fit
>>FitInside
>>FlexibleDirection
>>GetChildren
>>GetClassName
>>GetColWidths
>>GetCols
>>GetContainingWind
>>GetFlexibleDirect
>>GetHGap
>>GetItem
>>GetItemIndex
>>GetMinSize
>>GetMinSizeTuple
>>GetNonFlexibleGro
>>GetPosition
>>GetPositionTuple
>>GetRowHeights
>>GetRows
>>GetSize
>>GetSizeTuple
>>GetVGap
>>HGap
>>Hide
>>Insert
>>InsertF
>>InsertItem
>>InsertSizer
>>InsertSpacer
>>InsertStretchSpac
>>InsertWindow
>>IsSameAs
>>IsShown
>>Layout
>>MinSize
>>NonFlexibleGrowMo
>>Position
>>Prepend
>>PrependF
>>PrependItem
>>PrependSizer
>>PrependSpacer
>>PrependStretchSpa
>>PrependWindow
>>RecalcSizes
>>Remove
>>RemoveGrowableCol
>>RemoveGrowableRow
>>RemovePos
>>RemoveSizer
>>RemoveWindow
>>Replace
>>RowHeights
>>Rows
>>SetCols
>>SetContainingWind
>>SetDimension
>>SetFlexibleDirect
>>SetHGap
>>SetItemMinSize
>>SetMinSize
>>SetNonFlexibleGro
>>SetRows
>>SetSizeHints
>>SetVGap
>>SetVirtualSizeHin
>>Show
>>ShowItems
>>Size
>>VGap
>>_ReplaceItem
>>_ReplaceSizer
>>_ReplaceWin
>>_SetItemMinSize
>>__class__
>>__del__
>>__delattr__
>>__dict__
>>__doc__
>>__format__
>>__getattribute__
>>__hash__
>>__init__
>>__module__
>>__new__
>>__reduce__
>>__reduce_ex__
>>__repr__
>>__setattr__
>>__sizeof__
>>__str__
>>__subclasshook__
>>__swig_destroy__
>>__weakref__
>>_setOORInfo

GetChildren() returns only SizerItems which don’t seem to hold any reference to the underlying objects either.

Anyone know how to access something inside of a sizer? I suppose I could just explode the function a bit and either return a list of the objects as well as the sizer, or simple dump the function and keep identifiers to the objects I need to modify in main.. but… my gui code is already spaghetti enough. If I can avoid it, I would like to.

  • 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-17T08:48:36+00:00Added an answer on June 17, 2026 at 8:48 am

    On the wx.SizerItem, there is a GetWindow which gives you exactly that. Use IsWindow to check if there is a ‘window’ available. All underlying objects inherit from wx.Window, so that is what you want.

    Here is an example, obj is a wx.Frame object:

    >>> obj
    <main.views.Main; proxy of <Swig Object of type 'wxFrame *' at 0x7fbaa1c70820> >
    >>> obj.Sizer
    <wx._core.BoxSizer; proxy of <Swig Object of type 'wxBoxSizer *' at 0x7fba9c9d48d0> >
    >>> obj.Sizer.Children
    wxSizerItemList: [<wx._core.SizerItem; proxy of <Swig Object of type 'wxSizerItem *' at 0x7fbaa1c21630> >, <wx._core.SizerItem; proxy of <Swig Object of type 'wxSizerItem *' at 0x7fbaa1c7faf0> >]
    >>> obj.Sizer.Children[0]
    <wx._core.SizerItem; proxy of <Swig Object of type 'wxSizerItem *' at 0x7fbaa1c21630> >
    >>> obj.Sizer.Children[0].Window
    <wx._windows.Panel; proxy of <Swig Object of type 'wxPanel *' at 0x7fba9c9d4d10> >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, during a refactoring session, I was looking over some code I wrote and
During refactoring, I sometimes have to split one source file into two or more
I'm refactoring some code. Right now there are quite a few places with functions
During Session Start, one has access to the Request object. How about Session End,
During some recent refactoring we changed how our user avatars are stored not realizing
During the process of testing my Perl code using Smart Match(~~) I have faced
During refactoring it would be quite handy just to copy part of HAML template
During some refactoring, I'm moving files around. Obviously SVN sees this as deleting the
How to make sure that code is still working after refactoring ( i.e, after
I'm refactoring a bunch of classes, written by different people, which do not have

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.