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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:03:47+00:00 2026-06-06T10:03:47+00:00

I am fairly new to programming and to python and wxpython. I have looked

  • 0

I am fairly new to programming and to python and wxpython. I have looked over this code for literally HOURS and I tried finding an answer everywhere online. I am having trouble getting a new window to show up after a menu item is clicked. Here is my code so far…

import wx

class MainWindow(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Python Test App',size=(600,400))
        panel=wx.Panel(self)
        wx.Frame.CenterOnScreen(self)
        ##wx.Frame.Maximize(self)

        status=self.CreateStatusBar()
        menubar=wx.MenuBar()
        file_menu=wx.Menu()
        edit_menu=wx.Menu()

        ID_FILE_NEW = 1
        ID_FILE_OPEN = 2

        ID_EDIT_UNDO = 3
        ID_EDIT_REDO = 4


        file_menu.Append(ID_FILE_NEW,"New Window","This is a new window")
        file_menu.Append(ID_FILE_OPEN,"Open...","This will open a new window")

        edit_menu.Append(ID_EDIT_UNDO,"Undo","This will undo your last action")
        edit_menu.Append(ID_EDIT_REDO,"Redo","This will redo your last undo")


        menubar.Append(file_menu,"File")
        menubar.Append(edit_menu,"Edit")
        self.SetMenuBar(menubar)

        self.Bind(wx.EVT_MENU, NewWindow.new_frame, None, 1)

class NewWindow(wx.Frame):

    def __init__(self,MainWindow,id):
        wx.Frame.__init__(self, None, id, 'New Window', size=(600,400))
        wx.Frame.CenterOnScreen(self)
        self.Show(False)

    def new_frame(self, event):
        NewWindow.Show(True)



if __name__=='__main__':
        app=wx.PySimpleApp()
        frame=MainWindow(parent=None,id=-1)
        frame.Show()
        app.MainLoop()

When I try to run this code, I get this error message once I click on the menu item “New Window”

TypeError: unbound method new_frame() must be called with NewWindow instance as first argument (got CommandEvent instance instead)

Again, I am fairly new to programming. Any help is greatly appreciated and also, I know my code may not be the “cleanest” looking code around. Thanks in advance!

  • 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-06T10:03:48+00:00Added an answer on June 6, 2026 at 10:03 am

    Modifying your code to some extent i was able to show a new window when user clicks a New Window option,

    Do check the stuff that i have modified a let me know if this is what you want??

    import wx
    
    class MainWindow(wx.Frame):
    
        def __init__(self,parent,id):
            wx.Frame.__init__(self,parent,id,'Python Test App',size=(600,400))
            panel=wx.Panel(self)
            wx.Frame.CenterOnScreen(self)
    
            status=self.CreateStatusBar()
            menubar=wx.MenuBar()
            file_menu=wx.Menu()
            edit_menu=wx.Menu()
    
            ID_FILE_NEW = 1
            ID_FILE_OPEN = 2
    
            ID_EDIT_UNDO = 3
            ID_EDIT_REDO = 4
    
    
            file_menu.Append(ID_FILE_NEW,"New Window","This is a new window")
            file_menu.Append(ID_FILE_OPEN,"Open...","This will open a new window")
    
            edit_menu.Append(ID_EDIT_UNDO,"Undo","This will undo your last action")
            edit_menu.Append(ID_EDIT_REDO,"Redo","This will redo your last undo")
    
    
            menubar.Append(file_menu,"File")
            menubar.Append(edit_menu,"Edit")
            self.SetMenuBar(menubar)
    
            self.Bind(wx.EVT_MENU, self.test, None, 1)
    
        def test(self, event):
            self.new = NewWindow(parent=None, id=-1)
            self.new.Show()
    
    class NewWindow(wx.Frame):
    
        def __init__(self,parent,id):
            wx.Frame.__init__(self, parent, id, 'New Window', size=(400,300))
            wx.Frame.CenterOnScreen(self)
            #self.new.Show(False)
    
    if __name__=='__main__':
            app=wx.PySimpleApp()
            frame=MainWindow(parent=None,id=-1)
            frame.Show()
            app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to Python and programming in general. I have done a few
i have a question because i am fairly new to python, socket programming and
I am fairly new to Python programming and Threads isn't my area of expertise.
I'm fairly new to database programming in WinForms, and have been using BindingSource, DataSet,
I am fairly new to Python programming, and completely new to cross-platform GUI building
I'm fairly new to actual programming languages, and Python is my first one. I
I'm fairly new to programming and from learning I have seen different ways of
I'm fairly new to programming and have been focussing a great deal on Java
Okay, so this should be a simple question, but I'm fairly new at programming,
I'm fairly new to programming in general but have been working with Java for

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.