he aqui el code:
Código python:
Ver original
import wx import wx.stc import os class ControlPanel(wx.Panel): BMP_SIZE = 10 BMP_BORDER = 3 NUM_COLS = 4 SPACING = 4 maxThickness = 16 def __init__(self, parent, ID): wx.Panel.__init__(self, parent, ID, style=wx.EXPAND) class MDIFrame(wx.MDIParentFrame): def __init__(self, parent, id, title): wx.MDIParentFrame.__init__(self, parent, id, title, size=(600,400)) menubar = wx.MenuBar() menu = wx.Menu() menu.Append(5000, "&Nueva Ventan\tCtrl+N", 'Nueva ventana') menu.AppendSeparator() menu.Append(100, "&Abrir\tCtrl+A", 'Abrir archivo') menu.Append(150, "&Guardar\tCtrl+G", 'Guardar archivo ') menu.AppendSeparator() menu.Append(5001, '&Salir\tCtrl+S', 'Salir del programa') edit = wx.Menu() edit.Append(205, "&Deshacer\tCtrl+Z", 'Deshacer hecho') edit.AppendSeparator() edit.Append(210, "C&ortar\tCtrl+X", 'Cortar seleccionado') edit.Append(220, "&Copiar\tCtrl+C", 'Copiar Todo') edit.Append(230, "&Pegar\tCtrl+V", 'Pegar ultimo seleccionado') help = wx.Menu() help.Append(235, "&Ayuda\tCtrl+A", 'Funcion del programa') menubar.Append(menu, "&Archivo") menubar.Append(edit, '&Editar') menubar.Append(help, 'A&yuda') self.SetMenuBar(menubar) self.createPanel() self.CreateToolBar() self.Bind(wx.EVT_MENU, self.OnNewWindow, id=5000) self.Bind(wx.EVT_MENU, self.OnOpenFile, id=100) self.Bind(wx.EVT_MENU, self.OnSaveFile, id=150) self.Bind(wx.EVT_MENU, self.OnExit, id=5001) self.dirname = '' self.CreateStatusBar() self.Show(True) def createPanel(self): controlPanel = ControlPanel(self, -1) box = wx.BoxSizer(wx.HORIZONTAL) box.Add(controlPanel, 0, wx.EXPAND) self.SetSizer(box) def OnOpenFile(self,e): dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", wx.OPEN) if dlg.ShowModal() == wx.ID_OK: self.filename=dlg.GetFilename() self.dirname=dlg.GetDirectory() filehandle=open(os.path.join(self.dirname, self.filename),'r') self.MDIChildFrame.SetValue(filehandle.read()) filehandle.close() self.SetTitle("Editing ... "+self.filename) dlg.Destroy() def OnSaveFile(self,e): dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", \ wx.SAVE | wx.OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: itcontains = self.OneNewWindow.GetValue() self.filename=dlg.GetFilename() self.dirname=dlg.GetDirectory() filehandle=open(os.path.join(self.dirname, self.filename),'w') filehandle.write(itcontains) filehandle.close() dlg.Destroy() def OnExit(self, evt): self.Close(True) def OnNewWindow(self, evt): win = wx.MDIChildFrame(self, -1, "Nuevo archivo") wx.stc.StyledTextCtrl(win) win.Show(True) app = wx.PySimpleApp() MDIFrame(None, -1, 'iozk') app.MainLoop()