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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:59:22+00:00 2026-05-22T00:59:22+00:00

I want to add panel classes to a sizer in a frame class that

  • 0

I want to add panel classes to a sizer in a frame class that I will call in the main line of the code.

The error I get is TypeError: wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item. I assume this has to do with the fact that it is a panel class and not the instance of the panel class..

Either way, how would I do such a thing?

Code is below:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import wx

class step_1(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY)

        sizer = wx.BoxSizer(wx.VERTICAL)
        txtOne = wx.TextCtrl(self, wx.ID_ANY, "")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(txtOne, 0, wx.ALL, 5)

        self.SetSizer(sizer)

class step_2(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY)

        sizer = wx.BoxSizer(wx.VERTICAL)
        txtOne = wx.TextCtrl(self, wx.ID_ANY, "")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(txtOne, 0, wx.ALL, 5)

        self.SetSizer(sizer)

class main_frame(wx.Frame):
    """Main Frame holding the main panel."""
    def __init__(self,*args,**kwargs):
        wx.Frame.__init__(self,*args,**kwargs)
        p = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(step_1,0,border = 5)
        sizer.Add(step_2,0,border = 5)
        p.SetSizerAndFit(sizer)
        self.Show()

if __name__ == "__main__":
    app = wx.App(False)
    frame = main_frame(None,-1,size = (400,300))
    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-22T00:59:23+00:00Added an answer on May 22, 2026 at 12:59 am

    Like you said yourself: You’re not passing instances of the step_1 and step_2 classes to the sizer, which of course you should be. Simply create instances of them:

    class main_frame(wx.Frame):
        """Main Frame holding the main panel."""
        def __init__(self,*args,**kwargs):
            wx.Frame.__init__(self,*args,**kwargs)
            p = wx.Panel(self)
    
            stp1 = step_1(p) 
            stp2 = step_2(p) 
    
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(stp1, 0, border = 5)
            sizer.Add(stp2, 0, border = 5)
            p.SetSizerAndFit(sizer)
            self.Show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to add images or labels with image in it to a panel
I am in a situation where I want to add usercontrols in a panel.
I have dbml with single table users i want add partial class for User
I have a list of string values that I want add to a hashtable
I used RollingFileAppender. And I want add a blank line to the log when
I want to add a simple panel to a dialog created using Visual Studio
I want to add an image to the slide thumbnail in left panel, but
I want to add a checkbox in a alert panel . But now I
I create a new element inside Ext.Panel by template i want to add an
I want to add a panel in android activity.I'll try explain its behaviour. It

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.