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/file.close()self.last_name_saved = os.path.basename(path)self.statusbar.SetStatusText(self.last_name_saved + ' saved', 0)self.modify = Falseself.statusbar.SetStatusText('', 1)except IOError, error:dlg = wx.MessageDialog(self, 'Error saving file\n' + str(error))dlg.ShowModal()save_dlg.Destroy()def OnCut(self, event):self.text.Cut()def OnCopy(self, event):self.text.Copy()def OnPaste(self, event):self.text.Paste()def QuitApplication(self, event):if self.modify:dlg = wx.MessageDialog(self, 'Save before Exit?', '', wx.YES_NO | wx.YES_DEFAULT |wx.CANCEL | wx.ICON_QUESTION)val = dlg.ShowModal()if val == wx.ID_YES:self.OnSaveFile(event)if not self.modify:wx.Exit()elif val == wx.ID_CANCEL:dlg.Destroy()else:self.Destroy()else:self.Destroy()def OnDelete(self, event):frm, to = self.text.GetSelection()self.text.Remove(frm, to)def OnSelectAll(self, event):self.text.SelectAll()def OnTextChanged(self, event):self.modify = Trueself.statusbar.SetStatusText(' modified', 1)event.Skip()def OnKeyDown(self, event):keycode = event.GetKeyCode()if keycode == wx.WXK_INSERT:if not self.replace:self.statusbar.SetStatusText('INS', 2)self.replace = Trueelse:self.statusbar.SetStatusText('', 2)self.replace = Falseevent.Skip()def ToggleStatusBar(self, event):if self.statusbar.IsShown():self.statusbar.Hide()else:self.statusbar.Show()def StatusBar(self):self.statusbar = self.CreateStatusBar()7 de 12 27/04/2008 1:09

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

Saved successfully!

Ooh no, something went wrong!