From 9ce483095de32a046afad6c5932079104fc2c285 Mon Sep 17 00:00:00 2001 From: ccremers Date: Fri, 11 Aug 2006 09:41:12 +0000 Subject: [PATCH] - Refactoring, explanations, added button. --- gui/Gui/Attackwindow.py | 13 ++++++------- gui/Gui/Scytherthread.py | 14 +++++++------- gui/Gui/Settingswindow.py | 2 +- gui/Scyther/Claim.py | 26 ++++++++++++++++++-------- gui/todo.txt | 27 ++++++++++++++++++++------- 5 files changed, 52 insertions(+), 30 deletions(-) diff --git a/gui/Gui/Attackwindow.py b/gui/Gui/Attackwindow.py index cded545..17fcc19 100644 --- a/gui/Gui/Attackwindow.py +++ b/gui/Gui/Attackwindow.py @@ -147,12 +147,10 @@ class AttackWindow(wx.Frame): # Make zoom buttons if Preference.usePIL(): buttons = wx.BoxSizer(wx.HORIZONTAL) - bt = wx.Button(self,wx.ID_ZOOM_100) + bt = wx.ToggleButton(self,-1,"Fit to window") + bt.SetValue(self.fit) buttons.Add(bt,0) - self.Bind(wx.EVT_BUTTON, self.OnZoom100, bt) - bt = wx.Button(self,wx.ID_ZOOM_FIT) - buttons.Add(bt,0) - self.Bind(wx.EVT_BUTTON, self.OnZoomFit, bt) + self.Bind(wx.EVT_TOGGLEBUTTON, self.OnFit, bt) sizer.Add(buttons, 0, wx.ALIGN_LEFT) # Add attacks (possible with tabs) @@ -197,13 +195,14 @@ class AttackWindow(wx.Frame): self.Refresh() def OnZoom100(self,evt): - self.Refresh() self.fit = False self.update() + self.Refresh() def OnZoomFit(self,evt): - self.Refresh() self.fit = True self.update() + self.Refresh() + diff --git a/gui/Gui/Scytherthread.py b/gui/Gui/Scytherthread.py index fb7923d..0704dfa 100644 --- a/gui/Gui/Scytherthread.py +++ b/gui/Gui/Scytherthread.py @@ -380,15 +380,15 @@ class ResultWindow(wx.Frame): grid.Add(bmpfield,(ypos,xpos),(1,1),wx.ALIGN_CENTER_VERTICAL|wx.ALL,10) else: # new style text control Ok/Fail - rank = cl.getRank() - rankt = [('Fail','red'), - ('Fail','dark red'), - ('Ok','dark green'), - ('Ok','forest green')] - txt = wx.StaticText(self,-1,rankt[rank][0]) + rankc = cl.getColour() + if cl.okay: + rankt = "Ok" + else: + rankt = "Fail" + txt = wx.StaticText(self,-1,rankt) font = wx.Font(11,wx.NORMAL,wx.NORMAL,wx.BOLD) txt.SetFont(font) - txt.SetForegroundColour(rankt[rank][1]) + txt.SetForegroundColour(rankc) grid.Add(txt,(ypos,xpos),(1,1),wx.ALL,10) xpos += 1 diff --git a/gui/Gui/Settingswindow.py b/gui/Gui/Settingswindow.py index 9f21049..cc9ccdb 100644 --- a/gui/Gui/Settingswindow.py +++ b/gui/Gui/Settingswindow.py @@ -83,7 +83,7 @@ class SettingsWindow(wx.Panel): else: defsize = 11 self.fontsize = int(Preference.get('fontsize',defsize)) - txt = wx.StaticText(self,-1,"Attack graph font size") + txt = wx.StaticText(self,-1,"Attack graph font size (in points)") ctrl = wx.SpinCtrl(self, -1, "",style=wx.RIGHT) ctrl.SetRange(6,32) ctrl.SetValue(self.fontsize) diff --git a/gui/Scyther/Claim.py b/gui/Scyther/Claim.py index 59202ab..e446008 100644 --- a/gui/Scyther/Claim.py +++ b/gui/Scyther/Claim.py @@ -93,6 +93,24 @@ class Claim(object): else: return 3 + def getVerified(self): + """ + returns an element of [None,'Verified','Falsified'] + """ + opts = ['Falsified',None,None,'Verified'] + return opts[self.getRank()] + + + def getColour(self): + """ + Returns a colour that expresses the state + """ + colours = ['red', + 'dark red', + 'dark green', + 'pale green'] + return colours[self.getRank()] + def getComment(self): """ returns a sentence describing the results for this claim @@ -117,14 +135,6 @@ class Claim(object): return remark + "." - def getVerified(self): - """ - returns an element of [None,'Verified','Falsified'] - """ - opts = ['Falsified',None,None,'Verified'] - return opts[self.getRank()] - - def __str__(self): """ Resulting string diff --git a/gui/todo.txt b/gui/todo.txt index 682d491..62fc156 100644 --- a/gui/todo.txt +++ b/gui/todo.txt @@ -1,15 +1,28 @@ URGENT +- + TO BE DONE +- Config file should use Python's confParse module. +- Save preferences in local file on close. + WOULD LIKE TO HAVE -- Attacks are not kept centered well. + +- Font selector for graphs. +- Nice graph scaling for all platforms (now only supported under Linux + using the Python Imaging Library through postscript) +- Support for using an external editor. + - toggle for 'watch file'. + - toggle for 'auto-verify on change' or something like that. - Ideally we somehow color the correct/incorrect tags in the editor. - Line numbering is needed for the editor window otherwise you cannot interpret attacks. Probably use wx.Py editor things. -- Preferences window. - - Save in local file on close. - - Scyther executable should be able to be set by means of preferences. - (Using a file select dialog) -- Refactoring: constructing the comment of a claim (now in - Gui/Scytherthread) should really be in Scyther/Claim. +- Scyther executable should be able to be set by means of preferences. +- Save attacks (dot/xml/png) to file. + +IN AN IDEAL WORLD... + +- Use Python modules to generate the attack graphs from the XML, also + allow for eg. ASCII output. +