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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:25:31+00:00 2026-06-06T22:25:31+00:00

I am trying to use a wxSizer to arrange widgets inside a panel. I

  • 0

I am trying to use a wxSizer to arrange widgets inside a panel. I can see that widgets are arranged but they do not go inside the frame. Can anyone tell me what I’m doing wrong?

import wx

class MyRegion(wx.Frame):
    def __init__(self):        
        wx.Frame.__init__(self, None, -1)

        self.panel = wx.Panel(self,-1,pos=(70,200), size=(300,300))
        self.panel.SetBackgroundColour((128,128,128)) # dark grey       

        sizer = wx.BoxSizer(wx.VERTICAL)

        b1 = wx.Button(self, label="TEXT1")
        b2 = wx.Button(self, label="TEXT2")
        b3 = wx.Button(self, label="TEXT3")

        sizer.Add(b1)
        sizer.Add(b2)
        sizer.Add(b3)

        self.panel.SetSizer(sizer)
        sizer.Fit(self.panel)


if __name__ == "__main__":
    app = wx.PySimpleApp()
    myRegion = MyRegion()
    myRegion.Show()
    app.MainLoop()   
  • 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-06T22:25:33+00:00Added an answer on June 6, 2026 at 10:25 pm

    You should make the panel the parent of buttons instead of the frame.

    b1 = wx.Button(self.panel, label="TEXT1")
    

    The reason for this is that although the sizers control the positioning of the items the parent/child relationship in the UI is still controlled by the wx objects that map directly to the underlying OS controls.

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

Sidebar

Related Questions

Trying to use Java's regexp I want to match /app, /app/.* , but not
Can a wx.PyControl contain a wx.Sizer ? Note that what I am ultimately trying
I am trying use filehelpers class builder but I am kinda confused on what
I was trying use svn to find a checkin using svn log, but it
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use the Sum method in a lambda expression for a comparison, but
I'm trying use eco for client-side templating. I have multiple .eco templates that I'd
I have a regex that I'm trying use to validate against strings. Trying to
I have a 3rd party DLL that I am trying to use in a
I am trying use Thread but i have some problem (I am beginner at

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.