Greetings all,
I'm mostly a newbie to wxPython and I'm writing an application to help me learn some of its ins and outs.
I'm trying to write an application with one top-level window, and multiple child windows that will exist only inside the top-level window frame, much the same way that the Windows PythonWin program manages its text editing sessions. There's only one button on the Start bar regardless of how many editing sessions the program actually has open.
I've been working with this for a couple of days now, and I don't feel like I'm making any headway. I'm assuming that what I want to do is possible, but I don't know for sure. Any help would be appreciated.
I've put together this small bit of sample code to demonstrate what I'm trying to do.
···
=================
SAMPLE CODE START
'''Document Object Model Test (I think that's what it's called)'''
import wx
class topWindow(wx.Frame):
def __init__( self ):
wx.Frame.__init__(self, None, -1, "My Top Window", pos=(100,100), size=(300,300))
panel = wx.Panel(self)
self.CreateStatusBar()
menu = wx.Menu()
child = menu.Append(-1, "Open child window", "Open a child window")
menu.AppendSeparator()
exit = menu.Append(-1, "Exit", "Done testing")
self.Bind(wx.EVT_MENU, self.OnChild, child)
self.Bind(wx.EVT_MENU, self.OnExit, exit)
menuBar = wx.MenuBar()
menuBar.Append(menu, "Start Here")
self.SetMenuBar(menuBar)
def OnChild(self, event):
# I'm specifying the current window as the parent,
# so how do I keep the child inside the parent window?
f = childWindow(self, -1)
f.Show()
def OnExit(self, event):
self.Close()
class childWindow(wx.Frame):
def __init__( self, parent, id ):
wx.Frame.__init__(self, parent, id, "My Child Window", pos=(25,25), size=(250,100))
panel = wx.Panel(self)
wx.StaticText(panel, wx.NewId(), "I want this window inside the top window.", (10,10))
wx.StaticText(panel, wx.NewId(), "And I don't want it moving outside the top", (10,25))
wx.StaticText(panel, wx.NewId(), "window. Is this possible?", (10,40))
if __name__ == '__main__':
app = wx.PySimpleApp()
f = topWindow()
app.SetTopWindow(f)
f.Show()
app.MainLoop()
===============
SAMPLE CODE END
Thanks in advance,
Paul