Código python:
Ver original
import wx.stc import wx class Toolbars(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(700, 650),) menubar = wx.MenuBar() file = wx.Menu() new = wx.MenuItem(file, 2, '&Nuevo\tCtrl+N', 'new file') file.AppendItem(new) open = wx.MenuItem(file, 21, '&Abrir\tCtrl+O', 'open file') file.AppendItem(open) save = wx.MenuItem(file, 12, '&Guardar\tCtrl+S', 'save file') file.AppendItem(save) file.AppendSeparator() quit = wx.MenuItem(file, 1, '&Salir\tCtrl+Q', 'Exit program') file.AppendItem(quit) edit = wx.Menu() copy = wx.MenuItem(edit, 3, '&Copy\tCtrl+C', 'Copy selected') edit.AppendItem(copy) cut = wx.MenuItem(edit, 4, '&Cut\tCtrl+X', 'Cut selected') edit.AppendItem(cut) tool = wx.Menu() mask = wx.MenuItem(tool, 5, '&Tool\tCtrl+l') tool.AppendItem(mask) menubar.Append(file, '&Archivo') menubar.Append(edit, '&Edicion') menubar.Append(tool, '&Herramientas') self.SetMenuBar(menubar) sizer = wx.BoxSizer(wx.VERTICAL) self.display = wx.TextCtrl(self, -1, '', style=wx.TE_RIGHT) sizer.Add(self.display, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 4) self.Bind(wx.EVT_MENU, self.OnQuit, id=1) self.Bind(wx.EVT_MENU, self.OnOpen, id=21) self.Bind(wx.EVT_MENU, self.OnSave, id=12) vbox = wx.BoxSizer(wx.VERTICAL) toolbar1 = wx.ToolBar(self, 1) toolbar1.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../Lamp/fil.png')) toolbar1.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../lamp/fil.png')) toolbar1.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../lamp/exit.png')) wx.CheckBox(toolbar1, 3, 'Sels', pos=(800, 5)) toolbar1.Realize() toolbar2 = wx.ToolBar(self, 1) toolbar2.AddLabelTool(wx.ID_EXIT, '', wx.Bitmap('../lamp/exit.png')) Mode = ['Esculpir', 'Edicion', 'Pagina', 'zero'] cbb = wx.ComboBox(toolbar2, pos=(100, 0), size=(80, -1), choices=Mode, style=wx.CB_READONLY) wx.RadioButton(toolbar2, 4, 'sets', pos=(800,5)) toolbar2.Realize() vbox.Add(toolbar1, 0, wx.EXPAND) vbox.Add(toolbar2, 1, wx.EXPAND) self.Bind(wx.EVT_TOOL, self.OnExit, id=wx.ID_EXIT) self.Bind(wx.EVT_COMBOBOX, self.OnSelect) self.SetSizer(vbox) self.dirname = '' self.statusbar = self.CreateStatusBar() self.Centre() self.Show(True) def OnSelect(self, event): item = event.GetSelection() def OnOpen(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.control.SetValue(filehandle.read()) filehandle.close() self.SetTitle("Editing ... "+self.filename) dlg.Destroy() def OnSave(self,e): dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", \ wx.SAVE | wx.OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: itcontains = self.control.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, event): self.Close() def OnQuit(self, event): self.Close() app = wx.App() Toolbars(None, -1, 'Universal Grapics') app.MainLoop()