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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:53:27+00:00 2026-05-27T01:53:27+00:00

Hello i have created 2 frames, and when I run this program it will

  • 0

Hello i have created 2 frames, and when I run this program it will show each frame as their own application (at least on windows). Is there a way to use both frames but put them in one application?

import wx

class MainFrame(wx.Frame): 
    def __init__(self): 
        wx.Frame.__init__(self, None, wx.NewId(), "Main") 
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.button = wx.Button(self, wx.NewId(), "Open a child")
        self.sizer.Add(self.button, proportion=0, border=2, flag=wx.ALL)
        self.SetSizer(self.sizer)
        self.button.Bind(wx.EVT_BUTTON, self.on_button)

        self.Layout()

    def on_button(self, evt):
        frame = ChildFrame(self)
        frame.Show(True)
        frame.MakeModal(True)

class ChildFrame(wx.Frame): 
    def __init__(self, parent): 
        wx.Frame.__init__(self, parent, wx.NewId(), "Child")
        self.Bind(wx.EVT_CLOSE, self.on_close)

    def on_close(self, evt):
        self.MakeModal(False)
        evt.Skip()

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

app = MyApp(0)
app.MainLoop()    

Here is an image of what I do not want:
https://i.stack.imgur.com/7gayc.png

that is what I do not want,
I would like both frames to be in ONE application.

  • 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-27T01:53:28+00:00Added an answer on May 27, 2026 at 1:53 am

    These frames already are running in the same wxPython application (MyApp).
    Probably what you mean is to have the two frames/windows in the same wxPython window.

    I think this is not possible because wx.Frame class is by definition an independent window.

    What you can do very easily is to modify your current classes to derive from wx.Panel instead of from wx.Frame and then put the two panels in the same Common Frame.

    For example for the ChildFrame you modify like this:

    class ChildPanel(wx.Panel): 
        def __init__(self, parent): 
            wx.Panel.__init__(self, parent, wx.NewId())
        .........................................
    

    Then you create the common Frame and instatiate your panels (and set them in a sizer):

    class Common(wx.Frame): 
        def __init__(self, parent): 
            wx.Frame.__init__(self, parent, wx.NewId(), "Common")
            self.Bind(wx.EVT_CLOSE, self.on_close)
    
            self.child = ChildPanel(self, .....)
            self.main = MainPanel(self, .....)
    
            ................... 
    

    If as suggested in Inerdial’s comment you are actually looking for MDI windows:

    enter image description here

    Then you have to use the wx.MDIParentFrame and wx.MDIChildFrame’s classes. For an example, check the MDIDemo.py example in the wxPython docs and demos package. Note that although wxPython supports Multiple Document Inteface windows, Windows has deprecated MDI.

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

Sidebar

Related Questions

hello i have created one windows application in c# .net and its working fine
Hello I have created and application which contains a gridview that is populated by
I have created a simple hello world application in xcode using the command line
I have created an element like this: var myDiv = new Element('div'); myDiv.update('Hello!'); I
I have created a very basic Hello world application where I am trying to
I have created a simple command line tool that outputs hello world. This is
hello all i am using this code to show flip animation...... i have a
I have created a sample Hello World program in android it was working fine
I have created a simple vc++ console application and try to print Hello World.
Hello I have created an application using qt and I managed to save some

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.