Added watch mode
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
""" Import externals """
|
||||
import wx
|
||||
import threading
|
||||
import subprocess
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -39,6 +40,8 @@ from . import Icon
|
||||
from . import Error
|
||||
from . import Makeimage
|
||||
|
||||
from .Misc import dotOutputWrite
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
if Preference.havePIL:
|
||||
import Image
|
||||
@@ -254,7 +257,7 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
def __init__(
|
||||
self, parent, parentwindow, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
|
||||
style=wx.DEFAULT_DIALOG_STYLE
|
||||
style=wx.DEFAULT_DIALOG_STYLE, watchMode = False, watchModeFile = None
|
||||
):
|
||||
|
||||
wx.Frame.__init__(self,parentwindow,-1,title,pos,size,style)
|
||||
@@ -263,6 +266,8 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
self.parent = parent
|
||||
self.thread = None
|
||||
self.watchMode = watchMode
|
||||
self.watchModeFile = watchModeFile
|
||||
aTable = wx.AcceleratorTable([
|
||||
(wx.ACCEL_CTRL, ord('W'), wx.ID_CLOSE),
|
||||
(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CLOSE),
|
||||
@@ -277,12 +282,18 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
def onViewButton(self,evt):
|
||||
btn = evt.GetEventObject()
|
||||
try:
|
||||
w = Attackwindow.AttackWindow(btn.claim)
|
||||
w.Show(True)
|
||||
except Error.PILError:
|
||||
Error.ShowAndReturn("Problem with PIL imaging library: disabled zooming. Please retry to verify the protocol again.")
|
||||
self.onCloseWindow(None)
|
||||
|
||||
if self.watchMode:
|
||||
print("Watching generating image")
|
||||
dotOutputWrite(btn.claim.attacks[0].scytherDot, self.watchModeFile + ".png",["-Tpng"])
|
||||
subprocess.run(['xdg-open', self.watchModeFile + ".png"])
|
||||
else:
|
||||
try:
|
||||
w = Attackwindow.AttackWindow(btn.claim)
|
||||
w.Show(True)
|
||||
except Error.PILError:
|
||||
Error.ShowAndReturn("Problem with PIL imaging library: disabled zooming. Please retry to verify the protocol again.")
|
||||
self.onCloseWindow(None)
|
||||
|
||||
def onCloseWindow(self,evt):
|
||||
""" TODO we should kill self.thread """
|
||||
@@ -423,8 +434,10 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
class ScytherRun(object):
|
||||
|
||||
def __init__(self,mainwin,mode,spdl,errorcallback=None):
|
||||
def __init__(self,mainwin,mode,spdl,errorcallback=None, watchMode=False, watchModeFile = None):
|
||||
|
||||
self.watchMode = watchMode
|
||||
self.watchModeFile = watchModeFile
|
||||
self.mainwin = mainwin
|
||||
self.mode = mode
|
||||
self.spdl = spdl
|
||||
@@ -505,7 +518,7 @@ class ScytherRun(object):
|
||||
|
||||
# Great, we verified stuff, progress to the claim report
|
||||
title = "Scyther results : %s" % self.mode
|
||||
self.resultwin = resultwin = ResultWindow(self,self.mainwin,title)
|
||||
self.resultwin = resultwin = ResultWindow(self,self.mainwin,title, watchMode=self.watchMode, watchModeFile=self.watchModeFile)
|
||||
|
||||
def attackDone(attack,total,done):
|
||||
if resultwin:
|
||||
|
||||
Reference in New Issue
Block a user