Merge pull request #14 from kamphaus/master
Keyboard shortcuts & new file command.
This commit is contained in:
commit
5103876969
@ -248,6 +248,13 @@ class AttackWindow(wx.Frame):
|
|||||||
# reasons.
|
# reasons.
|
||||||
self.fit = False
|
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()
|
self.CreateInteriorWindowComponents()
|
||||||
|
|
||||||
Icon.ScytherIcon(self)
|
Icon.ScytherIcon(self)
|
||||||
@ -326,5 +333,8 @@ class AttackWindow(wx.Frame):
|
|||||||
self.update(True)
|
self.update(True)
|
||||||
self.Refresh()
|
self.Refresh()
|
||||||
|
|
||||||
|
def onCloseWindow(self,evt):
|
||||||
|
self.Destroy()
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# vim: set ts=4 sw=4 et list lcs=tab\:>-:
|
# vim: set ts=4 sw=4 et list lcs=tab\:>-:
|
||||||
|
@ -60,7 +60,7 @@ class MainWindow(wx.Frame):
|
|||||||
|
|
||||||
MainInitOnce()
|
MainInitOnce()
|
||||||
|
|
||||||
self.filename = 'noname.spdl'
|
self.filename = ''
|
||||||
self.filepath = ""
|
self.filepath = ""
|
||||||
|
|
||||||
self.load = False
|
self.load = False
|
||||||
@ -84,6 +84,7 @@ class MainWindow(wx.Frame):
|
|||||||
|
|
||||||
aTable = wx.AcceleratorTable([
|
aTable = wx.AcceleratorTable([
|
||||||
(wx.ACCEL_CTRL, ord('Q'), wx.ID_EXIT),
|
(wx.ACCEL_CTRL, ord('Q'), wx.ID_EXIT),
|
||||||
|
(wx.ACCEL_CTRL, ord('W'), wx.ID_EXIT),
|
||||||
(wx.ACCEL_NORMAL, wx.WXK_F1,
|
(wx.ACCEL_NORMAL, wx.WXK_F1,
|
||||||
ID_VERIFY),
|
ID_VERIFY),
|
||||||
(wx.ACCEL_NORMAL, wx.WXK_F2,
|
(wx.ACCEL_NORMAL, wx.WXK_F2,
|
||||||
@ -158,8 +159,9 @@ class MainWindow(wx.Frame):
|
|||||||
def CreateMenus(self):
|
def CreateMenus(self):
|
||||||
menuBar = wx.MenuBar()
|
menuBar = wx.MenuBar()
|
||||||
self.CreateMenu(menuBar, '&File', [
|
self.CreateMenu(menuBar, '&File', [
|
||||||
(wx.ID_OPEN, '&Open', 'Open a new file', self.OnOpen),
|
(wx.ID_NEW, '&New\tCTRL-N', 'Create a new file', self.OnNew),
|
||||||
(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',
|
(wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name',
|
||||||
self.OnSaveAs),
|
self.OnSaveAs),
|
||||||
(None, None, None, None),
|
(None, None, None, None),
|
||||||
@ -266,12 +268,23 @@ class MainWindow(wx.Frame):
|
|||||||
return True
|
return True
|
||||||
return False
|
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):
|
def OnSave(self, event):
|
||||||
textfile = open(os.path.join(self.dirname, self.filename), 'w')
|
if self.filename=='':
|
||||||
textfile.write(self.editor.GetText())
|
return self.OnSaveAs(event)
|
||||||
textfile.close()
|
else:
|
||||||
self.editor.SetSaved()
|
textfile = open(os.path.join(self.dirname, self.filename), 'w')
|
||||||
return True
|
textfile.write(self.editor.GetText())
|
||||||
|
textfile.close()
|
||||||
|
self.editor.SetSaved()
|
||||||
|
return True
|
||||||
|
|
||||||
def OnOpen(self, event):
|
def OnOpen(self, event):
|
||||||
if self.ConfirmLoss("Open"):
|
if self.ConfirmLoss("Open"):
|
||||||
|
@ -263,7 +263,14 @@ class ResultWindow(wx.Frame):
|
|||||||
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.thread = None
|
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_CLOSE, self.onCloseWindow)
|
||||||
|
self.Bind(wx.EVT_MENU, self.onCloseWindow, id=wx.ID_CLOSE)
|
||||||
|
|
||||||
|
|
||||||
self.CreateStatusBar()
|
self.CreateStatusBar()
|
||||||
self.BuildTable()
|
self.BuildTable()
|
||||||
|
Loading…
Reference in New Issue
Block a user