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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:54:32+00:00 2026-06-08T17:54:32+00:00

I have a wxpython program where I subclass wx.Dialog as per a tutorial. Within

  • 0

I have a wxpython program where I subclass wx.Dialog as per a tutorial. Within the dialog I create a panel and a sizer.

class StretchDialog(wx.Dialog):

'''A generic image processing dialogue which handles data IO and user interface.
This is extended for individual stretches to allow for the necessary parameters
to be defined.'''

def __init__(self, *args, **kwargs):
    super(StretchDialog, self).__init__(*args, **kwargs)

    self.InitUI()
    self.SetSize((600,700))

def InitUI(self):
    panel =  wx.Panel(self)
    sizer = wx.GridBagSizer(10,5)

The block comment describes what functionality I am trying to achieve, essentially dynamically generating more complex dialogs using this as the base. To do that I have tried:

class LinearStretchSubClass(StretchDialog):
'''This class subclasses Stretch Dialog and extends it by adding 
    the necessary UI elements for a linear stretch'''

def InitUI(self):
    '''Inherits all of the UI items from StretchDialog.InitUI if called as a method'''
    testtext = wx.StaticText(panel, label="This is a test")
    sizer.Add(testtext, pos=(10,3))

I call the subclass via the InitUI method to be able to extend, but not overwrite the UI generation in the parent class’ InitUI. What I am not able to do is pass the panel and presumably sizer attributes from the parent to the child.

I tried many variations of panel = StretchDialog.panel and panel = StretchDialog.InitUI.panel to no end.

Is it possible to achieve this in wxpython by subclassing a parent? If so, how am I messing up the namespace when trying to access panel?

  • 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-08T17:54:33+00:00Added an answer on June 8, 2026 at 5:54 pm

    your InitUI in the child class causes InitUI not to be called in StretchDialog

    you can do it like this

    class StretchDialog(wx.Dialog):
    
        '''A generic image processing dialogue which handles data IO and user interface.
          This is extended for individual stretches to allow for the necessary parameters
          to be defined.'''
    
        def __init__(self, *args, **kwargs):
            super(StretchDialog, self).__init__(*args, **kwargs)
    
            self.InitUI()
            self.SetSize((600,700))
    
       def InitUI(self):
           #save references for later access
           self.panel =  wx.Panel(self)
           self.sizer = wx.GridBagSizer(10,5)
    

    Then in your child class

    class LinearStretchSubClass(StretchDialog):
    '''This class subclasses Stretch Dialog and extends it by adding 
    the necessary UI elements for a linear stretch'''
    
        def InitUI(self):
        '''Inherits all of the UI items from StretchDialog.InitUI if called as a method'''
             StretchDialog.InitUI(self) #call parent function
             testtext = wx.StaticText(self.panel, label="This is a test")
             self.sizer.Add(testtext, pos=(10,3))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wxPython frame, with a Panel. In my Panel class, I have
I have a two panel wxPython GUI set up. In my right panel, I
I have recently been using WxPython to create a GUI Network simulator like Cisco
I have a wxPython program which reads from different datasets, performs various types of
I am creating a program using wxpython which entails the need to create many
I have a python program with a wxpython GUI and some command line parameters.
I am writing a drawing program, Whyteboard -- http://code.google.com/p/whyteboard/ I have implemented image rotating
I have a wxPython application which contains a matplotlib panel (courtesy of wxmpl, though
I have a TextCtrl in my wxPython program and I'd like to set its
Have been wondering about this for days now: I have a basic wxpython program

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.