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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:31:09+00:00 2026-06-18T07:31:09+00:00

I am trying to build a 3-panel GUI and everything was going great until

  • 0

I am trying to build a 3-panel GUI and everything was going great until I tried to nest panels/windows inside of other panels and hide them upon GUI startup.

See this image… The yellow/green/blue boxes were automatically expanded to fill up their panels during init, but the little purple box is built BUT then hidden during wx.Panel init until a 2 second timer expires and then at that time that object’s Show() method is invoked. At that time it does not not fill up the containing panel. It seems that hiding a panel during init causes the panel sizer to pick the default size, 20×20.

sizer test

Here is the code:

import wx
import  wx.lib.scrolledpanel as scrolled

class NavPanel(wx.Panel):
    """"""
    def __init__(self, parent, actionPanel):
        """Constructor"""
        wx.Panel.__init__(self, parent) #, size=(200,600))
        self.actionPanel = actionPanel
        self.SetBackgroundColour("Yellow")

class ActionPanel(wx.Panel):
    """"""
    def __init__(self, parent, target_item=None):
        """Constructor"""
        wx.Panel.__init__(self, parent)
        self.SetBackgroundColour("Green")

        self.sc = NestedScrolledActionPanel(self)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.sc, 1, wx.EXPAND)
        self.SetSizer(sizer)

    def show_child(self):
        # Putting a sizer here doesn't work either...
        self.sc.Show()


class NestedScrolledActionPanel(wx.ScrolledWindow):
    """"""
    def __init__(self, parent, target_item=None):
        """Constructor"""
        wx.ScrolledWindow.__init__(self, parent)
        self.SetBackgroundColour("Purple")

        # I don't want to show this at starutp, but hiding it causes the sizer to startup at 20x20!
        # Comment out this line and the sizer set in ActionPanel works, but you see it at startup
        self.Hide()       

class ConsolePanel(scrolled.ScrolledPanel): 
    """"""
    def __init__(self, parent):
        """Constructor"""

        scrolled.ScrolledPanel.__init__(self, parent, -1)
        self.SetBackgroundColour("Blue")

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

        mainSplitter = wx.SplitterWindow(self)
        topSplitter = wx.SplitterWindow(mainSplitter)

        self.rightPanel = ActionPanel(topSplitter)
        self.rightPanel.SetBackgroundColour("Green")

        leftPanel = NavPanel(topSplitter, self.rightPanel)
        leftPanel.SetBackgroundColour("Yellow")

        topSplitter.SplitVertically(leftPanel, self.rightPanel, sashPosition=0)
        topSplitter.SetMinimumPaneSize(200)

        bottomPanel = ConsolePanel(mainSplitter)

        mainSplitter.SplitHorizontally(topSplitter, bottomPanel, sashPosition=400)
        mainSplitter.SetSashGravity(1)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(mainSplitter, 1, wx.EXPAND)
        self.SetSizer(sizer)

        return


########################################################################
class MainFrame(wx.Frame):
    """"""
    def __init__(self):
        """Constructor"""

        wx.Frame.__init__(self, None, title="Sizer Test",
                          size=(800,600))

        self.panel = MainPanel(self)

        self.Centre()
        self.Show()

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(2000)

    def OnTimer(self, e):
        self.panel.rightPanel.show_child()

if __name__ == '__main__':
    app = wx.App(redirect=False)
    print "Launching frame"
    frame = MainFrame()
    print "starting mainloop"
    app.MainLoop()

The reason why I want this panel hidden upon GUI startup is because I will have many different panels residing in that ActionPanel space (the green box) and when the user clicks on a tree node in the yellow box, the panel that is displayed in the green box will be hidden and a different panel will be shown. If I don’t hide all of the panels at startup, they are “stacked” on top of each other and I will have to set a timer to go through and hide them all at some point after GUI launches??? That seems hokey. How else can I do it?

  • 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-18T07:31:11+00:00Added an answer on June 18, 2026 at 7:31 am

    Add self.Layout() to your show_child method. Just showing the child does not trigger a layout like a size event would. For those times when layout needs to change without a size event you need to call Layout yourself.

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

Sidebar

Related Questions

Trying to build Xuggler under Windows. Xuggler is core native code functions wrapped into
I'm trying to build an admin panel where users can populate the database with
I am new to Java GUI and trying to build a simulator. In every
I am trying to build a simple Java GUI (I've been learning for only
I'm trying to build a simple jQuery panel slider on a website (two in
I'm trying to build a collapsible panel in Flex 4. I thought I'd use
I am trying to build a custom share panel with buttons. This is how
I'm trying to build a modalpopupextender, along with a panel and content, and need
I'm trying to build a very simple VPS control panel; i have the following
Trying to build a GUI application in Java/Swing. I'm mainly used to painting GUIs

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.