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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:03:32+00:00 2026-06-17T17:03:32+00:00

I am new to wxPython and I have a very basic question about getting

  • 0

I am new to wxPython and I have a very basic question about getting buttons to resize.

Im working on a mac with python 2.7.3 and using wxPython 2.8.10.1

I have been working with it for a few days and I think I understand the sizer layout methods. I am trying to get a grid of buttons to grow in size when the window is expanded. I know its a basic issue but I have spent hours.

I cant figure out how to get a screen shot image here but the buttons show fine and then stay the same size when the window is enlarged.

Thanks.

#!/usr/bin/env python
import wx
class Example(wx.Frame):

def __init__(self, *args, **kw):
    super(Example, self).__init__(*args, **kw) 
    self.InitUI()
    self.SetSize((550, 160))
    self.SetTitle("Label of Grids")
    self.Centre()
    self.Show()     

def InitUI(self):

    pnl = wx.Panel(self)       
    grid = wx.GridBagSizer(3, 3)
    for r in range(6):
        for c in range (4):
            buttonname = str(r)+"_"+str(c)
            labeltxt = "(row= "+str(r)+", col= "+str(c)+")"
            grid.Add(wx.Button(pnl, name = buttonname,label=labeltxt), (r, c),flag =wx.EXPAND)
    pnl.SetSizer(grid)

def main():

    app = wx.App()
    Example(None)
    app.MainLoop()    


if __name__ == '__main__':
    main()  
  • 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-17T17:03:35+00:00Added an answer on June 17, 2026 at 5:03 pm

    When you’re using GridBagSizer‘s you need to make calls to the AddGrowableCol(idx) and AddGrowableRow(idx) methods in order to allow individual rows and columns in the Grid to be fluid in size.

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

Sidebar

Related Questions

I'm very new to python and i have some stupid question, thank you for
I am fairly new to programming and to python and wxpython. I have looked
Using wxPython (I am completely new to it), I have created a taskbar icon
I am new to python , doing small GUI project using wxpython, Here is
I'm new to python, and I've been reading that using global to pass variables
I am very new to wxpython. I have a dialogue box where if the
I have created a GUI program using python and wxpython. It is now ready
I am new to Python. I am writing an application using wxPython and I
I'm relatively new to wxPython (but not Python itself), so forgive me if I've
New to PHP and MySQL, have heard amazing things about this website from Leo

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.