From 94f7b2ce435b9f9623cddfb48d7c350b4d9cef9f Mon Sep 17 00:00:00 2001 From: Christophe Kamphaus Date: Sun, 28 Feb 2016 23:18:21 +0100 Subject: [PATCH 1/4] Added standard keyboard shortcuts for closing windows --- gui/Gui/Attackwindow.py | 10 ++++++++++ gui/Gui/Mainwindow.py | 1 + gui/Gui/Scytherthread.py | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/gui/Gui/Attackwindow.py b/gui/Gui/Attackwindow.py index 39b9f06..24962cc 100644 --- a/gui/Gui/Attackwindow.py +++ b/gui/Gui/Attackwindow.py @@ -248,6 +248,13 @@ class AttackWindow(wx.Frame): # reasons. self.fit = False + aTable = wx.AcceleratorTable([ + (wx.ACCEL_CTRL, ord('W'), wx.ID_CLOSE), + (wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CLOSE), + ]) + self.SetAcceleratorTable(aTable) + self.Bind(wx.EVT_CLOSE, self.onCloseWindow) + self.Bind(wx.EVT_MENU, self.onCloseWindow, id=wx.ID_CLOSE) self.CreateInteriorWindowComponents() Icon.ScytherIcon(self) @@ -326,5 +333,8 @@ class AttackWindow(wx.Frame): self.update(True) self.Refresh() + def onCloseWindow(self,evt): + self.Destroy() + #--------------------------------------------------------------------------- # vim: set ts=4 sw=4 et list lcs=tab\:>-: diff --git a/gui/Gui/Mainwindow.py b/gui/Gui/Mainwindow.py index 70ce112..ff927b1 100644 --- a/gui/Gui/Mainwindow.py +++ b/gui/Gui/Mainwindow.py @@ -84,6 +84,7 @@ class MainWindow(wx.Frame): aTable = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('Q'), wx.ID_EXIT), + (wx.ACCEL_CTRL, ord('W'), wx.ID_EXIT), (wx.ACCEL_NORMAL, wx.WXK_F1, ID_VERIFY), (wx.ACCEL_NORMAL, wx.WXK_F2, diff --git a/gui/Gui/Scytherthread.py b/gui/Gui/Scytherthread.py index 2cd5d1a..5691c44 100644 --- a/gui/Gui/Scytherthread.py +++ b/gui/Gui/Scytherthread.py @@ -263,7 +263,14 @@ class ResultWindow(wx.Frame): self.parent = parent self.thread = None + aTable = wx.AcceleratorTable([ + (wx.ACCEL_CTRL, ord('W'), wx.ID_CLOSE), + (wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CLOSE), + ]) + self.SetAcceleratorTable(aTable) self.Bind(wx.EVT_CLOSE, self.onCloseWindow) + self.Bind(wx.EVT_MENU, self.onCloseWindow, id=wx.ID_CLOSE) + self.CreateStatusBar() self.BuildTable() From b3862747385a37a2670c3abd75be33f08d58599b Mon Sep 17 00:00:00 2001 From: Christophe Kamphaus Date: Sun, 28 Feb 2016 23:21:24 +0100 Subject: [PATCH 2/4] Added standard keyboard shortcuts for opening and saving files --- gui/Gui/Mainwindow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/Gui/Mainwindow.py b/gui/Gui/Mainwindow.py index ff927b1..7c7d870 100644 --- a/gui/Gui/Mainwindow.py +++ b/gui/Gui/Mainwindow.py @@ -159,8 +159,8 @@ class MainWindow(wx.Frame): def CreateMenus(self): menuBar = wx.MenuBar() self.CreateMenu(menuBar, '&File', [ - (wx.ID_OPEN, '&Open', 'Open a new file', self.OnOpen), - (wx.ID_SAVE, '&Save', 'Save the current file', self.OnSave), + (wx.ID_OPEN, '&Open\tCTRL-O', 'Open a new file', self.OnOpen), + (wx.ID_SAVE, '&Save\tCTRL-S', 'Save the current file', self.OnSave), (wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name', self.OnSaveAs), (None, None, None, None), From 53de782d3c04b0d9eccb7e2608c9d3b881300646 Mon Sep 17 00:00:00 2001 From: Christophe Kamphaus Date: Sun, 28 Feb 2016 23:24:20 +0100 Subject: [PATCH 3/4] Changed default filename to empty string When trying to save a new file it opens the save-as dialog --- gui/Gui/Mainwindow.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gui/Gui/Mainwindow.py b/gui/Gui/Mainwindow.py index 7c7d870..3a9fe74 100644 --- a/gui/Gui/Mainwindow.py +++ b/gui/Gui/Mainwindow.py @@ -60,7 +60,7 @@ class MainWindow(wx.Frame): MainInitOnce() - self.filename = 'noname.spdl' + self.filename = '' self.filepath = "" self.load = False @@ -268,11 +268,14 @@ class MainWindow(wx.Frame): return False def OnSave(self, event): - textfile = open(os.path.join(self.dirname, self.filename), 'w') - textfile.write(self.editor.GetText()) - textfile.close() - self.editor.SetSaved() - return True + if self.filename=='': + return self.OnSaveAs(event) + else: + textfile = open(os.path.join(self.dirname, self.filename), 'w') + textfile.write(self.editor.GetText()) + textfile.close() + self.editor.SetSaved() + return True def OnOpen(self, event): if self.ConfirmLoss("Open"): From faf6c57069980c97bb267fe08c7b8bdca9a25c81 Mon Sep 17 00:00:00 2001 From: Christophe Kamphaus Date: Sun, 28 Feb 2016 23:33:18 +0100 Subject: [PATCH 4/4] Added a new-file command with standard new-file keyboard shortcut --- gui/Gui/Mainwindow.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gui/Gui/Mainwindow.py b/gui/Gui/Mainwindow.py index 3a9fe74..0e99167 100644 --- a/gui/Gui/Mainwindow.py +++ b/gui/Gui/Mainwindow.py @@ -159,6 +159,7 @@ class MainWindow(wx.Frame): def CreateMenus(self): menuBar = wx.MenuBar() self.CreateMenu(menuBar, '&File', [ + (wx.ID_NEW, '&New\tCTRL-N', 'Create a new file', self.OnNew), (wx.ID_OPEN, '&Open\tCTRL-O', 'Open a new file', self.OnOpen), (wx.ID_SAVE, '&Save\tCTRL-S', 'Save the current file', self.OnSave), (wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name', @@ -267,6 +268,14 @@ class MainWindow(wx.Frame): return True return False + def OnNew(self, event): + if self.ConfirmLoss("Open"): + self.editor.SetText('') + self.filename = '' + self.editor.SetOpened() + return True + return False + def OnSave(self, event): if self.filename=='': return self.OnSaveAs(event)