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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:02:41+00:00 2026-06-17T21:02:41+00:00

I’m creating an Interface, and I need to open a new window with a

  • 0

I’m creating an Interface, and I need to open a new window with a click of a button.
So I’ve created the Main Window, and I’ve created all the buttons, and created the new Window under a class. I’m not entirely sure if that is needed but I’ll include that piece of information too. New to python so sorry if It’s full of mistakes.

If someone could also answer how to hide the Main Menu when opening another window, that would be great. Cheers.

import wxversion
wxversion.select("2.8")
import wx

class App(wx.App):

def OnInit(self):
   frame = window()
   frame.Show()
   self.SetTopWindow(frame)
   return True

class window(wx.Frame):

title = "Main Menu"

def __init__(self,parent,id):
    wx.Frame.__init__(self,parent,id,'Window', size=(1000,700))
    panel=wx.Panel(self, -1)

    self.SetBackgroundColour(wx.Colour(100,100,100))
    self.Centre()
    self.Show()

    status=self.CreateStatusBar()

    menubar=wx.MenuBar()
    filemenu=wx.Menu()
    exitmenu = filemenu.Append(wx.NewId(),"Exit", "Exit Program")

    menubar.Append(filemenu,"File")
    self.Bind(wx.EVT_MENU, self.onExit, exitmenu)
    self.SetMenuBar(menubar)

    font1 = wx.Font(30, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')

    Text1=wx.StaticText(panel, -1, "Rhythm Trainer", (10,15))
    Text1.SetFont(font1)
    Text1.SetForegroundColour('white')
    self.Show(True)

    btn1 = wx.Button(panel, label='Basic', pos=(100,200), size=(150, 50))
    btn1.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, u'Consolas'))

    btn1.Bind( wx.EVT_BUTTON, window2)

    btn2 = wx.Button(panel, label='Advanced', pos=(100,270), size=(150, 50))
    btn2.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, u'Consolas'))

    btn3 = wx.Button(panel, label='Notations', pos=(100,340), size=(150, 50))
    btn3.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, u'Consolas'))

    btn4 = wx.Button(panel, label='Settings', pos=(100,410), size=(150, 50))
    btn4.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, u'Consolas'))

    btn5 = wx.Button(panel, label="Quit", pos=(820, 550), size=(150, 50))
    btn5.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, u'Consolas'))
    self.Bind(wx.EVT_BUTTON, self.OnClick, btn5)


def OnClick(self, event):
    self.Close()

def OnQuitButton(self, event):

    wx.Sleep(1)   
    self.Destroy()

def onExit(self, event):
     self.Destroy()

def newwindow(self, event):
     window2.show


class window2(wx.Frame):

title = "new Window"

def __init__(self,parent,id):
    wx.Frame.__init__(self, id,'Window2', size=(1000,700))
    panel=wx.Panel(self, -1)

    self.SetBackgroundColour(wx.Colour(100,100,100))
    self.Centre()
    self.Show()


if __name__=='__main__':
    app=wx.PySimpleApp()
    frame=window(parent=None,id=-1)
    frame.Show()
    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-06-17T21:02:42+00:00Added an answer on June 17, 2026 at 9:02 pm

    If all you want to do is hide the first frame and show the second, I wrote a tutorial on exactly that on my blog.

    If you don’t care if the first frame is still onscreen along with the second, then in your onClick method, you need to instantiate the second window and Show it. Something like this:

    secondWindow = window2()
    secondWindow.Show()
    

    Do NOT close the first frame! That will just end the entire script. You only want to close that when you want the entire program to exit.

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT

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.