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

  • Home
  • SEARCH
  • 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 6636263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:09:50+00:00 2026-05-25T23:09:50+00:00

I want to display a button that when I click adds to the main

  • 0

I want to display a button that when I click adds to the main panel a static text that automatic adds to the BoxSizer of the panel. I have this code but dosen’t work good. Anyone can help me? I am desperate. Thanks

import wx

class MyApp(wx.App):
    def OnInit(self):
        self.frame = MainFrame(None,title='')
        self.SetTopWindow(self.frame)
        self.frame.Show()
        return True

class MainFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(MainFrame, self).__init__(*args, **kwargs)

        #Atributos
        self.panel = MainPanel(self)
        self.CreateStatusBar()

        #Layout
        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.panel,1,wx.EXPAND)
        self.SetSizer(self.sizer)

class MainPanel(wx.Panel):
    def __init__(self, parent):
        super(MainPanel, self).__init__(parent)

        #Atributos
        bmp = wx.Bitmap('./img.png',wx.BITMAP_TYPE_PNG)
        self.boton = wx.BitmapButton(self,bitmap=bmp)

        # Layout
        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.boton)
        self.SetSizer(self.sizer)

        self.Bind(wx.EVT_BUTTON,self.add,self.boton)

    def add(self,event):
        self.sizer.Add(wx.StaticText(self,label='Testing'))


if __name__ == "__main__":
    app = MyApp(False)
    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-05-25T23:09:51+00:00Added an answer on May 25, 2026 at 11:09 pm

    If your problem is that your text initially shows up behind the button when it is clicked, you can force the sizer to update by adding a call to your Panel’s Layout method.

    class MainPanel(wx.Panel):
        def __init__(self, parent):
            super(MainPanel, self).__init__(parent)
    
            #Atributos
            bmp = wx.Bitmap('./img.png',wx.BITMAP_TYPE_PNG)
            self.boton = wx.BitmapButton(self,bitmap=bmp)
    
            # Layout
            self.sizer = wx.BoxSizer(wx.HORIZONTAL)
            self.sizer.Add(self.boton)
            self.SetSizer(self.sizer)
    
            self.Bind(wx.EVT_BUTTON,self.add,self.boton)
    
        def add(self,event):
            self.sizer.Add(wx.StaticText(self,label='Testing'))
            self.Layout()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ContextMenuStrip (ctMenuMassEdit) that I want to display when left-clicking a button
This is my div <div id="car2" style="display:none;"></div> Then I have a Show button that
I have a menu with button objects in As3. I want to display the
want to have a Hyperlink-Button in a gridView in which I can display a
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I have a main window in Which I have a button. When i click
I have a .click() function that performs certain actions when a button is clicked.
I have a footer area that is display:none by default. This bottom footer area
i am developing a game.i want to display score on button click.but it should
We have a Button that is styled like this: <a class=mini pink button>Arrange Viewing</a>

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.