From 16ea88e350db0efc04dd97cbbb430b8dedd1c53b Mon Sep 17 00:00:00 2001 From: jmg1138 Date: Fri, 10 Nov 2017 11:49:08 -0800 Subject: [PATCH 1/3] Replaced bad if statement Used a set of "ids", then did "if event.GetId() in ids" --- tmpNote.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/tmpNote.py b/tmpNote.py index cadfec6..743207f 100755 --- a/tmpNote.py +++ b/tmpNote.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # -*- coding: utf-8 -*- import wx @@ -276,25 +276,15 @@ def menu_bar(self): editmenu.AppendSeparator() editmenu.Append(wx.ID_CUT, 'Cut\tCtrl+X', 'Cut selection from file.') self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_CUT) - editmenu.Append(wx.ID_COPY, '&Copy\tCtrl+C', - 'Copy selection from file.') - self.Bind( - wx.EVT_MENU, - self.cut_copy_paste_del_sel_event, - id=wx.ID_COPY - ) - editmenu.Append(wx.ID_PASTE, '&Paste\tCtrl+V', - 'Paste clipboard into file.') - self.Bind( - wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_PASTE - ) + editmenu.Append(wx.ID_COPY, '&Copy\tCtrl+C', 'Copy selection from file.') + self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_COPY) + editmenu.Append(wx.ID_PASTE, '&Paste\tCtrl+V', 'Paste clipboard into file.') + self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_PASTE) editmenu.Append(wx.ID_DELETE, 'Delete', 'Delete the selected text.') - self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, - id=wx.ID_DELETE) + self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_DELETE) editmenu.AppendSeparator() editmenu.Append(wx.ID_SELECTALL, 'Select All', 'Select all text.') - self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, - id=wx.ID_SELECTALL) + self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_SELECTALL) # findmenu = wx.Menu() # menubar.Append(findmenu, 'F&ind') @@ -1072,10 +1062,8 @@ def close_all_action(self): def cut_copy_paste_del_sel_event(self, event): """Event requesting cut, copy, paste, delete, or select all text.""" - if event.GetId() == ( - wx.ID_CUT or wx.ID_COPY or wx.ID_PASTE or wx.ID_DELETE or - wx.ID_SELECTALL - ): + ids = set((wx.ID_CUT, wx.ID_COPY, wx.ID_PASTE, wx.ID_DELETE, wx.ID_SELECTALL)) + if event.GetId() in ids: self.cut_copy_paste_del_sel_action(event) else: event.Skip() @@ -1084,7 +1072,6 @@ def cut_copy_paste_del_sel_action(self, event): """Cut, copy, paste, delete, or select all text.""" self.show_notebook_if_not_shown() - text = self.FindFocus() if text is not None: if event.GetId() == wx.ID_CUT: From f22a530608a7d815aa33b73050b5ad9ccff10184 Mon Sep 17 00:00:00 2001 From: jmg1138 Date: Fri, 10 Nov 2017 11:53:02 -0800 Subject: [PATCH 2/3] Reduced line lengths --- tmpNote.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tmpNote.py b/tmpNote.py index 743207f..eef5013 100755 --- a/tmpNote.py +++ b/tmpNote.py @@ -276,15 +276,25 @@ def menu_bar(self): editmenu.AppendSeparator() editmenu.Append(wx.ID_CUT, 'Cut\tCtrl+X', 'Cut selection from file.') self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_CUT) - editmenu.Append(wx.ID_COPY, '&Copy\tCtrl+C', 'Copy selection from file.') + editmenu.Append( + wx.ID_COPY, '&Copy\tCtrl+C', 'Copy selection from file.' + ) self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_COPY) - editmenu.Append(wx.ID_PASTE, '&Paste\tCtrl+V', 'Paste clipboard into file.') - self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_PASTE) + editmenu.Append( + wx.ID_PASTE, '&Paste\tCtrl+V', 'Paste clipboard into file.' + ) + self.Bind( + wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_PASTE + ) editmenu.Append(wx.ID_DELETE, 'Delete', 'Delete the selected text.') - self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_DELETE) + self.Bind( + wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_DELETE + ) editmenu.AppendSeparator() editmenu.Append(wx.ID_SELECTALL, 'Select All', 'Select all text.') - self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_SELECTALL) + self.Bind( + wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_SELECTALL + ) # findmenu = wx.Menu() # menubar.Append(findmenu, 'F&ind') @@ -1062,7 +1072,9 @@ def close_all_action(self): def cut_copy_paste_del_sel_event(self, event): """Event requesting cut, copy, paste, delete, or select all text.""" - ids = set((wx.ID_CUT, wx.ID_COPY, wx.ID_PASTE, wx.ID_DELETE, wx.ID_SELECTALL)) + ids = set(( + wx.ID_CUT, wx.ID_COPY, wx.ID_PASTE, wx.ID_DELETE, wx.ID_SELECTALL + )) if event.GetId() in ids: self.cut_copy_paste_del_sel_action(event) else: From bf030369c6c5ded66aa84a607efa15f15376ae96 Mon Sep 17 00:00:00 2001 From: jmg1138 Date: Fri, 10 Nov 2017 11:54:42 -0800 Subject: [PATCH 3/3] Reduced line length --- tmpNote.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tmpNote.py b/tmpNote.py index eef5013..32057e3 100755 --- a/tmpNote.py +++ b/tmpNote.py @@ -279,7 +279,9 @@ def menu_bar(self): editmenu.Append( wx.ID_COPY, '&Copy\tCtrl+C', 'Copy selection from file.' ) - self.Bind(wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_COPY) + self.Bind( + wx.EVT_MENU, self.cut_copy_paste_del_sel_event, id=wx.ID_COPY + ) editmenu.Append( wx.ID_PASTE, '&Paste\tCtrl+V', 'Paste clipboard into file.' )