import wx
import wx.aui

class MyFrame(wx.Frame):
	
	def __init__(self, parent, id=-1, title="", pos=wx.DefaultPosition,size=(1200,800), style=wx.DEFAULT_FRAME_STYLE |wx.SUNKEN_BORDER |wx.CLIP_CHILDREN):

		wx.Frame.__init__(self, parent, id, title, pos, size, style)
		self._mgr = wx.aui.AuiManager()
		self._mgr.SetManagedWindow(self)

		self._mgr.AddPane(self.Buttons(), wx.aui.AuiPaneInfo().Name("Displays").Caption("Displays").
		Left().Layer(1).Position(1).CloseButton(False))
		
		self._mgr.AddPane(self.CreateTextCtrl(), wx.aui.AuiPaneInfo().
						  Name("Print Text").Caption('').Float().FloatingPosition(wx.Point(100,100)).
						  Left().Show(False).CloseButton(True).MaximizeButton(True))
		
		self._mgr.Update()		

		self._mgr.GetPane("Displays").Show().Left().Layer(0).Row(0).Position(0)
		self._mgr.Update()

##########################################################################################
	def Buttons(self):
		
		panel = wx.Panel(self, -1, wx.Point(0,0), size = (200,600))	
		self.TextButton = wx.Button(panel, -1, "Normal Text")
		self.TextButton.SetPosition((25, 25))
		self.Bind(wx.EVT_BUTTON, self.OnPrintText, self.TextButton)

		return panel

##########################################################################################
	def OnPrintText(self,event):
	
		self._mgr.GetPane(self.Button.PaneName).Caption('Print Text').Show(True).Left().Layer(0).Row(0).Position(0)
		self._mgr.Update()
		print self._mgr.GetPane(self.Button.PaneName).caption
		wx.Yield()
		lines = 1000
		display = ''
		self.textbox.Clear()
		while lines >0:
			
			lines += -1
			display = ('This is line ' + str(1000-lines) + '\n')
			self.textbox.AppendText(display)
		self._mgr.GetPane(self.Button.PaneName).Caption('Printing Done')
		self._mgr.Update()
		print self._mgr.GetPane(self.Button.PaneName).caption
		
		
##########################################################################################
	def CreateTextCtrl(self):

		panel = wx.Panel(self, -1, wx.Point(0,0), size = (200,600))
		panel.SetBackgroundColour('light grey')
		self.textbox = wx.TextCtrl(panel,-1, '', wx.Point(5, 100), wx.Size(190, 400),
						   wx.BORDER_SUNKEN| wx.VSCROLL|wx.TE_MULTILINE)
		button = wx.Button(panel, -1, "CLOSE")
		button.SetPosition((25, 25))
		button.CenterOnParent(wx.HORIZONTAL)
		button.PaneName = 'Print Text'
		
		self.Bind(wx.EVT_BUTTON, self.OnClose, button)
		self.panel = panel
		self.Button = button
		return self.panel

##########################################################################################
	def OnClose(self, event):
		a = event.GetId()
		a = self.FindWindowById(a)
		self._mgr.GetPane(a.PaneName).Hide()
		self._mgr.Update()



##########################################################################################
if __name__ == '__main__':
	app = wx.PySimpleApp()
	frame = MyFrame(parent=None, id=-1)
	frame.Show()
	app.MainLoop()