13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>wxPython</strong> griptshttp://www.zetcode.com/wxpython/gripts/class Editor(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(600, 500))# variablesself.modify = Falseself.last_name_saved = ''self.replace = False# setting up menubarmenubar = wx.MenuBar()file = wx.Menu()new = wx.MenuItem(file, 101, '&New\tCtrl+N', 'Creates a new document')new.SetBitmap(wx.Bitmap('icons/stock_new-16.png'))file.AppendItem(new)open = wx.MenuItem(file, 102, '&Open\tCtrl+O', 'Open an existing file')open.SetBitmap(wx.Bitmap('icons/stock_open-16.png'))file.AppendItem(open)file.AppendSeparator()save = wx.MenuItem(file, 103, '&Save\tCtrl+S', 'Save the file')save.SetBitmap(wx.Bitmap('icons/stock_save-16.png'))file.AppendItem(save)saveas = wx.MenuItem(file, 104, 'Save &As...\tShift+Ctrl+S','Save the file with a different name')saveas.SetBitmap(wx.Bitmap('icons/stock_save_as-16.png'))file.AppendItem(saveas)file.AppendSeparator()quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the Application')quit.SetBitmap(wx.Bitmap('icons/stock_exit-16.png'))file.AppendItem(quit)edit = wx.Menu()cut = wx.MenuItem(edit, 106, '&Cut\tCtrl+X', 'Cut the Selection')cut.SetBitmap(wx.Bitmap('icons/stock_cut-16.png'))edit.AppendItem(cut)copy = wx.MenuItem(edit, 107, '&Copy\tCtrl+C', 'Copy the Selection')copy.SetBitmap(wx.Bitmap('icons/stock_copy-16.png'))edit.AppendItem(copy)paste = wx.MenuItem(edit, 108, '&Paste\tCtrl+V', 'Paste text from clipboard')paste.SetBitmap(wx.Bitmap('icons/stock_paste-16.png'))edit.AppendItem(paste)delete = wx.MenuItem(edit, 109, '&Delete', 'Delete the selected text')delete.SetBitmap(wx.Bitmap('icons/stock_delete-16.png',))edit.AppendItem(delete)edit.AppendSeparator()edit.Append(110, 'Select &All\tCtrl+A', 'Select the entire text')view = wx.Menu()view.Append(111, '&Statusbar', 'Show StatusBar')help = wx.Menu()about = wx.MenuItem(help, 112, '&About\tF1', 'About Editor')about.SetBitmap(wx.Bitmap('icons/stock_about-16.png'))help.AppendItem(about)menubar.Append(file, '&File')menubar.Append(edit, '&Edit')4 de 12 27/04/2008 1:09

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!