'Can't create window of class wxWindowClassNR (error 1406: cannot create a top-level child. Btw, I am using wx 2.6 on windows. Can anyone suggest a.
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 wxclass 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.CreateStatusBarmenubar=wx.MenuBarfilemenu=wx.Menueditmenu=wx.MenuIDFILENEW = 1IDFILEOPEN = 2IDEDITUNDO = 3IDEDITREDO = 4filemenu.Append(IDFILENEW,'New Window','This is a new window')filemenu.Append(IDFILEOPEN,'Open.' 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 wxclass 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.CreateStatusBarmenubar=wx.MenuBarfilemenu=wx.Menueditmenu=wx.MenuIDFILENEW = 1IDFILEOPEN = 2IDEDITUNDO = 3IDEDITREDO = 4filemenu.Append(IDFILENEW,'New Window','This is a new window')filemenu.Append(IDFILEOPEN,'Open.' You don't seem to understand how classes work in Python. You try to call NewWindow.newframe, but you never actually create an instance of that class.The error message is because you are calling the method on the class instead of on an instance of the class. What you want to do is something like: newWin = NewWindow(.) # replace. With the appropriate parametersnewWin.Show(True)You don't provide enough information in your example to know what the appropriate parameters are for the NewWindow call (e.g., you don't show where you create the main window), but the MainWindow and id parameters in NewWindow.init aren't just there for looks: wxPython needs to know the parent window.
You should look into the wxPython documentation to understand how to create a wxFrame.