#!/usr/bin/env python

import wx

class EditDialog(wx.Dialog):
    def __init__(self, title):
	wx.Dialog.__init__(self, None, -1, title)
	vbox = wx.BoxSizer(wx.VERTICAL)
	vslot1 = wx.FlexGridSizer(rows=2, cols=2, hgap=5, vgap=5)
	vbox.Add(vslot1)
	ticker_label = wx.StaticText(self, -1, "Var")
	self.ticker_textctrl = wx.TextCtrl(self, -1)
	descript_label = wx.StaticText(self, -1, "Var Description")
	self.descript_textctrl = wx.TextCtrl(self, -1,
		size=(400, -1))
	vslot1.AddMany([ticker_label, self.ticker_textctrl,
	    descript_label, self.descript_textctrl])

	sizer = self.CreateSeparatedButtonSizer(wx.OK|wx.CANCEL)
	vbox.Add(sizer, 1, wx.GROW)
	self.SetSizer(vbox)
	self.Fit()
	self.ticker_textctrl.SetFocus()

class DetailFrame(wx.Frame):
    def __init__(self):
	wx.Frame.__init__(self, None, -1,
		"Frame 2")
	panel = wx.Panel(self, -1)

	self.dialog_btn = wx.Button(panel, -1, "Dialog")
	sizer = wx.BoxSizer(wx.VERTICAL)
	sizer.Add(self.dialog_btn)

	panel.SetSizer(sizer)

	self.Bind(wx.EVT_BUTTON, self.OnDialog, self.dialog_btn)
    
    def OnDialog(self, event):
	edit_d = EditDialog('Dialog')
	edit_d.ShowModal()
	edit_d.Destroy()

class Frame(wx.Frame):
    def __init__(self):
	wx.Frame.__init__(self, None, -1,
		"Frame 1")
	panel = wx.Panel(self, -1)

	sizer = wx.BoxSizer(wx.VERTICAL)
	btn = wx.Button(panel, -1, "Click for Frame 2")
	self.Bind(wx.EVT_BUTTON, self.OnDetails, btn)
	sizer.Add(btn, 0, wx.ALL, 2)
	
	panel.SetSizer(sizer)
	
    def OnDetails(self, event):
	detailsFrame = DetailFrame()
	detailsFrame.Show()

class App(wx.App):
    def OnInit(self):
	main_frame = Frame()
	main_frame.Show()
	return True

app = App(0)
app.MainLoop()
