- Added parameters for automatic starts. (try filename --verify)
- Splash screen can now be disabled.
This commit is contained in:
parent
1376f930fd
commit
6b5f83f762
@ -28,16 +28,28 @@ ID_CHECK = 103
|
|||||||
|
|
||||||
class MainWindow(wx.Frame):
|
class MainWindow(wx.Frame):
|
||||||
|
|
||||||
def __init__(self, filename=''):
|
def __init__(self, opts, args):
|
||||||
super(MainWindow, self).__init__(None, size=(600,800))
|
super(MainWindow, self).__init__(None, size=(600,800))
|
||||||
|
|
||||||
|
self.opts = opts
|
||||||
|
self.args = args
|
||||||
|
|
||||||
self.dirname = '.'
|
self.dirname = '.'
|
||||||
|
|
||||||
if filename != '' and os.path.isfile(filename):
|
self.filename = 'noname.spdl'
|
||||||
self.filename = filename
|
self.load = False
|
||||||
|
|
||||||
|
# test
|
||||||
|
if opts.test:
|
||||||
|
self.filename = 'scythergui-default.spdl'
|
||||||
self.load = True
|
self.load = True
|
||||||
else:
|
|
||||||
self.filename = 'noname.spdl'
|
# if there is an argument (file), we load it
|
||||||
self.load = False
|
if len(args) > 0:
|
||||||
|
filename = args[0]
|
||||||
|
if filename != '' and os.path.isfile(filename):
|
||||||
|
self.filename = filename
|
||||||
|
self.load = True
|
||||||
|
|
||||||
Icon.ScytherIcon(self)
|
Icon.ScytherIcon(self)
|
||||||
|
|
||||||
@ -63,6 +75,8 @@ class MainWindow(wx.Frame):
|
|||||||
|
|
||||||
#self.SetTitle(self.title)
|
#self.SetTitle(self.title)
|
||||||
|
|
||||||
|
self.firstCommand()
|
||||||
|
|
||||||
def CreateInteriorWindowComponents(self):
|
def CreateInteriorWindowComponents(self):
|
||||||
''' Create "interior" window components. In this case it is just a
|
''' Create "interior" window components. In this case it is just a
|
||||||
simple multiline text control. '''
|
simple multiline text control. '''
|
||||||
@ -237,6 +251,12 @@ class MainWindow(wx.Frame):
|
|||||||
def OnCheck(self, event):
|
def OnCheck(self, event):
|
||||||
self.RunScyther("check")
|
self.RunScyther("check")
|
||||||
|
|
||||||
|
def firstCommand(self):
|
||||||
|
if self.opts.command:
|
||||||
|
# Trigger a command automatically
|
||||||
|
self.RunScyther(self.opts.command)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class SettingsWindow(wx.Panel):
|
class SettingsWindow(wx.Panel):
|
||||||
|
@ -366,7 +366,7 @@ class ScytherRun(object):
|
|||||||
# Verification window
|
# Verification window
|
||||||
|
|
||||||
self.verifywin = verifywin = VerificationWindow(mainwin,"Running Scyther %s process" % mode)
|
self.verifywin = verifywin = VerificationWindow(mainwin,"Running Scyther %s process" % mode)
|
||||||
verifywin.CenterOnScreen()
|
verifywin.Center()
|
||||||
verifywin.Show(True)
|
verifywin.Show(True)
|
||||||
|
|
||||||
# start the thread
|
# start the thread
|
||||||
@ -381,12 +381,8 @@ class ScytherRun(object):
|
|||||||
# start the window and show until something happens
|
# start the window and show until something happens
|
||||||
# if it terminates, this is a cancel, and should also kill the thread. (what happens to a spawned Scyther in that case?)
|
# if it terminates, this is a cancel, and should also kill the thread. (what happens to a spawned Scyther in that case?)
|
||||||
# if the thread terminames, it should close the window normally, and we end up here as well.
|
# if the thread terminames, it should close the window normally, and we end up here as well.
|
||||||
|
|
||||||
val = verifywin.ShowModal()
|
val = verifywin.ShowModal()
|
||||||
|
|
||||||
# Cursor back to normal
|
|
||||||
verifywin.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
|
|
||||||
|
|
||||||
if self.verified:
|
if self.verified:
|
||||||
# Scyther program is done (the alternative is that it was
|
# Scyther program is done (the alternative is that it was
|
||||||
# cancelled)
|
# cancelled)
|
||||||
@ -402,23 +398,25 @@ class ScytherRun(object):
|
|||||||
else:
|
else:
|
||||||
txt = "Done."
|
txt = "Done."
|
||||||
resultwin.SetStatusText(txt)
|
resultwin.SetStatusText(txt)
|
||||||
|
resultwin.Refresh()
|
||||||
|
|
||||||
def claimDone(claim):
|
def claimDone(claim):
|
||||||
if claim.button and len(claim.attacks) > 0:
|
if claim.button and len(claim.attacks) > 0:
|
||||||
claim.button.Enable()
|
claim.button.Enable()
|
||||||
|
resultwin.Refresh()
|
||||||
|
|
||||||
t = AttackThread(self,resultwin,claimDone,attackDone)
|
t = AttackThread(self,resultwin,claimDone,attackDone)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
resultwin.thread = t
|
resultwin.thread = t
|
||||||
resultwin.CenterOnScreen()
|
resultwin.Center()
|
||||||
resultwin.Show(True)
|
resultwin.Show(True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Darn, some errors. report.
|
# Darn, some errors. report.
|
||||||
title = "Scyther errors : %s" % mode
|
title = "Scyther errors : %s" % mode
|
||||||
errorwin = ErrorWindow(mainwin,title,errors=self.scyther.errors)
|
errorwin = ErrorWindow(mainwin,title,errors=self.scyther.errors)
|
||||||
errorwin.Show(True)
|
errorwin.Center()
|
||||||
errorwin.CenterOnScreen()
|
|
||||||
val = errorwin.ShowModal()
|
val = errorwin.ShowModal()
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
""" Import externals """
|
""" Import externals """
|
||||||
import wx
|
import wx
|
||||||
import sys
|
import sys
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -15,6 +16,23 @@ import Misc
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def parseArgs():
|
||||||
|
usage = "usage: %s [optional initial settings]" % sys.argv[0]
|
||||||
|
parser = OptionParser(usage=usage)
|
||||||
|
|
||||||
|
# command
|
||||||
|
parser.add_option("-V","--verify",dest="command",default=None,action="store_const",const="verify")
|
||||||
|
parser.add_option("-s","--state-space",dest="command",default=None,action="store_const",const="statespace")
|
||||||
|
parser.add_option("-a","--auto-claims",dest="command",default=None,action="store_const",const="autoverify")
|
||||||
|
parser.add_option("-c","--check",dest="command",default=None,action="store_const",const="check")
|
||||||
|
|
||||||
|
# misc debug etc
|
||||||
|
parser.add_option("","--test",dest="test",default=False,action="store_true")
|
||||||
|
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class MySplashScreen(wx.SplashScreen):
|
class MySplashScreen(wx.SplashScreen):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
bmp = wx.Image(Misc.mypath("images/scyther-splash.png")).ConvertToBitmap()
|
bmp = wx.Image(Misc.mypath("images/scyther-splash.png")).ConvertToBitmap()
|
||||||
@ -42,37 +60,32 @@ class MySplashScreen(wx.SplashScreen):
|
|||||||
self.Raise()
|
self.Raise()
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class ScytherApp(wx.App):
|
class ScytherApp(wx.App):
|
||||||
def OnInit(self):
|
def OnInit(self):
|
||||||
|
|
||||||
wx.GetApp().SetAppName("Scyther-gui")
|
wx.GetApp().SetAppName("Scyther-gui")
|
||||||
|
|
||||||
"""
|
# Parse arguments
|
||||||
Load preferences file
|
(opts,args) = parseArgs()
|
||||||
"""
|
|
||||||
|
|
||||||
|
# Load preferences file
|
||||||
Preference.init()
|
Preference.init()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Create and show the splash screen. It will then create and show
|
Create and show the splash screen. It will then create and show
|
||||||
the main frame when it is time to do so.
|
the main frame when it is time to do so.
|
||||||
|
|
||||||
|
The splash screen is disabled for automatic commands, and also
|
||||||
|
by a setting in the preferences file.
|
||||||
"""
|
"""
|
||||||
|
if not opts.command:
|
||||||
|
if not (Preference.get('splashscreen') in ['false','off','disable','0']):
|
||||||
|
splash = MySplashScreen()
|
||||||
|
splash.Show()
|
||||||
|
|
||||||
|
self.mainWindow = Mainwindow.MainWindow(opts,args)
|
||||||
splash = MySplashScreen()
|
|
||||||
splash.Show()
|
|
||||||
|
|
||||||
""" Build up """
|
|
||||||
infile = ''
|
|
||||||
args = sys.argv[1:]
|
|
||||||
if len(args) > 0:
|
|
||||||
if args[0] == 'test':
|
|
||||||
infile = 'scythergui-default.spdl'
|
|
||||||
else:
|
|
||||||
infile = args[0]
|
|
||||||
|
|
||||||
self.mainWindow = Mainwindow.MainWindow(infile)
|
|
||||||
self.SetTopWindow(self.mainWindow)
|
self.SetTopWindow(self.mainWindow)
|
||||||
self.mainWindow.Show()
|
self.mainWindow.Show()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user