#!/usr/bin/env python
import wx
import wx.py


class MyFrame(wx.Frame):
    def __init__(self,parent,title):
        wx.Frame.__init__(self,parent, title=title, size=(500,500))
        class Editor(wx.py.editwindow.EditWindow):
            def __init__(self,parent, margins=True, **kwargs):
                wx.py.editwindow.EditWindow.__init__(self,parent, **kwargs)
            @property
            def text(self):
                return self.GetText()
        global Ed
        Ed = Editor(self, parent, size = (400,400))
        self.button = wx.Button(self, wx.ID_OK, pos = (200,410))
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
        self.CreateStatusBar()
        #make a menu
        filemenu=wx.Menu()
        # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
        menuAbout = filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program")
        #filemenu.AppendSeparator()
        menuExit = filemenu.Append(wx.ID_EXIT,"&Exit"," Terminate the program")
        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
        self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
        menuBar = wx.MenuBar()
        menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar
        self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame content.
        self.Show(True)
    def OnAbout(self,event):
            #dialog box
        dlg = wx.MessageDialog(self, "Text editor, for now", "more later", wx.OK)
        dlg.ShowModal()
        dlg.Destroy()
    def OnExit(self,event):
        self.Close(True)
    def OnClick(self,event):
        global Ed
        exec(Ed.text)

app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
frame = MyFrame(None, "Emily's Editor")
app.MainLoop()
