- 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):
|
||||
|
||||
def __init__(self, filename=''):
|
||||
def __init__(self, opts, args):
|
||||
super(MainWindow, self).__init__(None, size=(600,800))
|
||||
|
||||
self.opts = opts
|
||||
self.args = args
|
||||
|
||||
self.dirname = '.'
|
||||
|
||||
self.filename = 'noname.spdl'
|
||||
self.load = False
|
||||
|
||||
# test
|
||||
if opts.test:
|
||||
self.filename = 'scythergui-default.spdl'
|
||||
self.load = True
|
||||
|
||||
# if there is an argument (file), we load it
|
||||
if len(args) > 0:
|
||||
filename = args[0]
|
||||
if filename != '' and os.path.isfile(filename):
|
||||
self.filename = filename
|
||||
self.load = True
|
||||
else:
|
||||
self.filename = 'noname.spdl'
|
||||
self.load = False
|
||||
|
||||
Icon.ScytherIcon(self)
|
||||
|
||||
@ -63,6 +75,8 @@ class MainWindow(wx.Frame):
|
||||
|
||||
#self.SetTitle(self.title)
|
||||
|
||||
self.firstCommand()
|
||||
|
||||
def CreateInteriorWindowComponents(self):
|
||||
''' Create "interior" window components. In this case it is just a
|
||||
simple multiline text control. '''
|
||||
@ -237,6 +251,12 @@ class MainWindow(wx.Frame):
|
||||
def OnCheck(self, event):
|
||||
self.RunScyther("check")
|
||||
|
||||
def firstCommand(self):
|
||||
if self.opts.command:
|
||||
# Trigger a command automatically
|
||||
self.RunScyther(self.opts.command)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class SettingsWindow(wx.Panel):
|
||||
|
@ -366,7 +366,7 @@ class ScytherRun(object):
|
||||
# Verification window
|
||||
|
||||
self.verifywin = verifywin = VerificationWindow(mainwin,"Running Scyther %s process" % mode)
|
||||
verifywin.CenterOnScreen()
|
||||
verifywin.Center()
|
||||
verifywin.Show(True)
|
||||
|
||||
# start the thread
|
||||
@ -381,12 +381,8 @@ class ScytherRun(object):
|
||||
# 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 the thread terminames, it should close the window normally, and we end up here as well.
|
||||
|
||||
val = verifywin.ShowModal()
|
||||
|
||||
# Cursor back to normal
|
||||
verifywin.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
|
||||
|
||||
if self.verified:
|
||||
# Scyther program is done (the alternative is that it was
|
||||
# cancelled)
|
||||
@ -402,23 +398,25 @@ class ScytherRun(object):
|
||||
else:
|
||||
txt = "Done."
|
||||
resultwin.SetStatusText(txt)
|
||||
resultwin.Refresh()
|
||||
|
||||
def claimDone(claim):
|
||||
if claim.button and len(claim.attacks) > 0:
|
||||
claim.button.Enable()
|
||||
resultwin.Refresh()
|
||||
|
||||
t = AttackThread(self,resultwin,claimDone,attackDone)
|
||||
t.start()
|
||||
|
||||
resultwin.thread = t
|
||||
resultwin.CenterOnScreen()
|
||||
resultwin.Center()
|
||||
resultwin.Show(True)
|
||||
|
||||
else:
|
||||
# Darn, some errors. report.
|
||||
title = "Scyther errors : %s" % mode
|
||||
errorwin = ErrorWindow(mainwin,title,errors=self.scyther.errors)
|
||||
errorwin.Show(True)
|
||||
errorwin.CenterOnScreen()
|
||||
errorwin.Center()
|
||||
val = errorwin.ShowModal()
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
""" Import externals """
|
||||
import wx
|
||||
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):
|
||||
def __init__(self):
|
||||
bmp = wx.Image(Misc.mypath("images/scyther-splash.png")).ConvertToBitmap()
|
||||
@ -42,37 +60,32 @@ class MySplashScreen(wx.SplashScreen):
|
||||
self.Raise()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class ScytherApp(wx.App):
|
||||
def OnInit(self):
|
||||
|
||||
wx.GetApp().SetAppName("Scyther-gui")
|
||||
|
||||
"""
|
||||
Load preferences file
|
||||
"""
|
||||
# Parse arguments
|
||||
(opts,args) = parseArgs()
|
||||
|
||||
# Load preferences file
|
||||
Preference.init()
|
||||
|
||||
"""
|
||||
Create and show the splash screen. It will then create and show
|
||||
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()
|
||||
|
||||
""" 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.mainWindow = Mainwindow.MainWindow(opts,args)
|
||||
self.SetTopWindow(self.mainWindow)
|
||||
self.mainWindow.Show()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user