本文整理汇总了Python中DimensionListCtrl.DimensionListCtrl.setEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Python DimensionListCtrl.setEnvironment方法的具体用法?Python DimensionListCtrl.setEnvironment怎么用?Python DimensionListCtrl.setEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DimensionListCtrl.DimensionListCtrl
的用法示例。
在下文中一共展示了DimensionListCtrl.setEnvironment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ThreatEnvironmentPanel
# 需要导入模块: from DimensionListCtrl import DimensionListCtrl [as 别名]
# 或者: from DimensionListCtrl.DimensionListCtrl import setEnvironment [as 别名]
class ThreatEnvironmentPanel(wx.Panel):
def __init__(self,parent,dp):
wx.Panel.__init__(self,parent,THREAT_PANELENVIRONMENT_ID)
self.dbProxy = dp
self.theThreatId = None
self.theEnvironmentDictionary = {}
self.theSelectedIdx = -1
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
environmentBox = wx.StaticBox(self)
environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
mainSizer.Add(environmentListSizer,0,wx.EXPAND)
self.environmentList = EnvironmentListCtrl(self,THREATENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
lhoodBox = wx.StaticBox(self)
lhoodSizer = wx.StaticBoxSizer(lhoodBox,wx.HORIZONTAL)
environmentDimSizer.Add(lhoodSizer,0,wx.EXPAND)
lhoodSizer.Add(wx.StaticText(self,-1,'Likelihood'))
lhoodList = ['Incredible','Improbable','Remote','Occasional','Probable','Frequent']
self.lhoodCtrl = wx.ComboBox(self,THREATENVIRONMENT_COMBOLIKELIHOOD_ID,choices=lhoodList,size=wx.DefaultSize,style=wx.CB_READONLY)
lhoodSizer.Add(self.lhoodCtrl,1,wx.EXPAND)
aaSizer = wx.BoxSizer(wx.HORIZONTAL)
environmentDimSizer.Add(aaSizer,1,wx.EXPAND)
self.attackerList = DimensionListCtrl(self,THREATENVIRONMENT_LISTATTACKERS_ID,wx.DefaultSize,'Attacker','attacker',self.dbProxy)
attackerBox = wx.StaticBox(self)
attackerSizer = wx.StaticBoxSizer(attackerBox,wx.HORIZONTAL)
attackerSizer.Add(self.attackerList,1,wx.EXPAND)
aaSizer.Add(attackerSizer,1,wx.EXPAND)
self.assetList = DimensionListCtrl(self,THREATENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
assetBox = wx.StaticBox(self)
assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
assetSizer.Add(self.assetList,1,wx.EXPAND)
aaSizer.Add(assetSizer,1,wx.EXPAND)
propertiesBox = wx.StaticBox(self)
propertiesSizer = wx.StaticBoxSizer(propertiesBox,wx.HORIZONTAL)
environmentDimSizer.Add(propertiesSizer,1,wx.EXPAND)
values = self.dbProxy.getDimensionNames('threat_value')
valueLookup = ValueDictionary(values)
self.propertiesList = PropertiesListCtrl(self,THREATENVIRONMENT_LISTPROPERTIES_ID,valueLookup)
propertiesSizer.Add(self.propertiesList,1,wx.EXPAND)
self.SetSizer(mainSizer)
self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
def loadControls(self,threat):
self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
self.theThreatId = threat.id()
# We load the environment name control before anything else. Weird stuff happens if we don't do this. Don't ask me why!!!
environmentNames = []
if (len(threat.environmentProperties()) > 0):
for cp in threat.environmentProperties():
environmentNames.append(cp.name())
self.environmentList.load(environmentNames)
for cp in threat.environmentProperties():
environmentName = cp.name()
self.theEnvironmentDictionary[environmentName] = cp
environmentName = environmentNames[0]
p = self.theEnvironmentDictionary[environmentName]
self.lhoodCtrl.SetStringSelection(p.likelihood())
self.attackerList.setEnvironment(environmentName)
self.attackerList.load(p.attackers())
self.assetList.setEnvironment(environmentName)
self.assetList.load(p.assets())
self.propertiesList.setEnvironment(environmentName)
self.propertiesList.load(p.properties(),p.rationale())
self.environmentList.Select(0)
self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
self.theSelectedIdx = 0
def OnEnvironmentSelected(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
p = self.theEnvironmentDictionary[environmentName]
self.lhoodCtrl.SetStringSelection(p.likelihood())
self.attackerList.setEnvironment(environmentName)
self.attackerList.load(p.attackers())
self.assetList.setEnvironment(environmentName)
self.assetList.load(p.assets())
self.propertiesList.setEnvironment(environmentName)
self.propertiesList.load(p.properties(),p.rationale())
def OnEnvironmentDeselected(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
syProperties,pRationale = self.propertiesList.properties()
self.theEnvironmentDictionary[environmentName] = ThreatEnvironmentProperties(environmentName,self.lhoodCtrl.GetValue(),self.assetList.dimensions(),self.attackerList.dimensions(),syProperties,pRationale)
self.lhoodCtrl.SetValue('')
self.attackerList.setEnvironment('')
self.attackerList.DeleteAllItems()
#.........这里部分代码省略.........
示例2: MitigateEnvironmentPanel
# 需要导入模块: from DimensionListCtrl import DimensionListCtrl [as 别名]
# 或者: from DimensionListCtrl.DimensionListCtrl import setEnvironment [as 别名]
class MitigateEnvironmentPanel(wx.Panel):
def __init__(self,parent,dp):
wx.Panel.__init__(self,parent,MITIGATE_PANELENVIRONMENT_ID)
self.theResponsePanel = parent
self.dbProxy = dp
self.theEnvironmentDictionary = {}
self.theSelectedIdx = -1
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
environmentBox = wx.StaticBox(self)
environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
mainSizer.Add(environmentListSizer,0,wx.EXPAND)
self.environmentList = RiskEnvironmentListCtrl(self,MITIGATE_LISTENVIRONMENTS_ID,self.dbProxy)
environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
typeBox = wx.StaticBox(self,-1,'Type')
typeBoxSizer = wx.StaticBoxSizer(typeBox,wx.HORIZONTAL)
environmentDimSizer.Add(typeBoxSizer,0,wx.EXPAND)
self.typeCombo = wx.ComboBox(self,MITIGATE_COMBOTYPE_ID,"",choices=['Deter','Prevent','Detect','React'],style=wx.CB_READONLY)
typeBoxSizer.Add(self.typeCombo,1,wx.EXPAND)
pointBox = wx.StaticBox(self,-1,'Detection Point')
pointBoxSizer = wx.StaticBoxSizer(pointBox,wx.HORIZONTAL)
environmentDimSizer.Add(pointBoxSizer,0,wx.EXPAND)
self.pointCombo = wx.ComboBox(self,MITIGATE_COMBODETECTIONPOINT_ID,"",choices=['Before','At','After'],style=wx.CB_READONLY)
pointBoxSizer.Add(self.pointCombo,1,wx.EXPAND)
dmBox = wx.StaticBox(self,-1,)
dmBoxSizer = wx.StaticBoxSizer(dmBox,wx.HORIZONTAL)
environmentDimSizer.Add(dmBoxSizer,1,wx.EXPAND)
self.dmList = DimensionListCtrl(self,MITIGATE_LISTDETMECH_ID,wx.DefaultSize,'Detection Mechanism','detection_mechanism',self.dbProxy,listStyle=wx.LC_REPORT)
dmBoxSizer.Add(self.dmList,1,wx.EXPAND)
self.typeCombo.Disable()
self.pointCombo.Disable()
self.dmList.Disable()
self.SetSizer(mainSizer)
self.typeCombo.Bind(wx.EVT_COMBOBOX,self.onTypeChange)
self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
def onTypeChange(self,evt):
self.activateTypeCtrls()
mitType = self.typeCombo.GetValue()
riskCombo = self.theResponsePanel.FindWindowById(RESPONSE_COMBORISK_ID)
riskName = riskCombo.GetValue()
if (riskName != ''):
riskNameCtrl = self.theResponsePanel.FindWindowById(RESPONSE_TEXTNAME_ID)
riskNameLabel = mitType + ' ' + riskName
riskNameCtrl.SetValue(riskNameLabel)
def activateTypeCtrls(self):
mitType = self.typeCombo.GetValue()
if ((mitType == 'Deter') or (mitType == 'Prevent')):
self.pointCombo.SetValue('')
self.pointCombo.Disable()
self.dmList.DeleteAllItems()
self.dmList.Disable()
elif (mitType == 'Detect'):
self.pointCombo.Enable()
self.dmList.Disable()
elif (mitType == 'React'):
self.pointCombo.Disable()
self.dmList.Enable()
def loadControls(self,accept):
self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
environmentNames = []
for cp in accept.environmentProperties():
environmentNames.append(cp.name())
self.environmentList.load(environmentNames)
for cp in accept.environmentProperties():
environmentName = cp.name()
self.theEnvironmentDictionary[environmentName] = cp
environmentNames.append(environmentName)
environmentName = environmentNames[0]
p = self.theEnvironmentDictionary[environmentName]
self.typeCombo.SetStringSelection(p.type())
self.pointCombo.SetStringSelection(p.detectionPoint())
self.dmList.setEnvironment(environmentName)
self.dmList.load(p.detectionMechanisms())
self.environmentList.Select(0)
self.activateTypeCtrls()
self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
self.theSelectedIdx = 0
def OnEnvironmentSelected(self,evt):
self.theSelectedIdx = evt.GetIndex()
#.........这里部分代码省略.........
示例3: setEnvironment
# 需要导入模块: from DimensionListCtrl import DimensionListCtrl [as 别名]
# 或者: from DimensionListCtrl.DimensionListCtrl import setEnvironment [as 别名]
def setEnvironment(self,environmentName):
DimensionListCtrl.setEnvironment(self,environmentName)
示例4: VulnerabilityEnvironmentPanel
# 需要导入模块: from DimensionListCtrl import DimensionListCtrl [as 别名]
# 或者: from DimensionListCtrl.DimensionListCtrl import setEnvironment [as 别名]
class VulnerabilityEnvironmentPanel(wx.Panel):
def __init__(self,parent,dp):
wx.Panel.__init__(self,parent,armid.VULNERABILITY_PANELENVIRONMENT_ID)
self.dbProxy = dp
self.theVulId = None
self.theEnvironmentDictionary = {}
self.theSelectedIdx = -1
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
environmentBox = wx.StaticBox(self)
environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
mainSizer.Add(environmentListSizer,0,wx.EXPAND)
self.environmentList = EnvironmentListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
sevBox = wx.StaticBox(self)
sevSizer = wx.StaticBoxSizer(sevBox,wx.HORIZONTAL)
environmentDimSizer.Add(sevSizer,0,wx.EXPAND)
sevSizer.Add(wx.StaticText(self,-1,'Severity'))
sevList = ['Negligible','Marginal','Critical','Catastrophic']
self.sevCtrl = wx.ComboBox(self,armid.VULNERABILITYENVIRONMENT_COMBOSEVERITY_ID,choices=sevList,size=wx.DefaultSize,style=wx.CB_READONLY)
sevSizer.Add(self.sevCtrl,1,wx.EXPAND)
aSizer = wx.BoxSizer(wx.HORIZONTAL)
environmentDimSizer.Add(aSizer,1,wx.EXPAND)
self.assetList = DimensionListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
assetBox = wx.StaticBox(self)
assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
assetSizer.Add(self.assetList,1,wx.EXPAND)
aSizer.Add(assetSizer,1,wx.EXPAND)
self.SetSizer(mainSizer)
self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
def loadControls(self,vulnerability):
self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
self.theVulId = vulnerability.id()
# We load the environment name control before anything else. Weird stuff happens if we don't do this. Don't ask me why!!!
environmentNames = []
if (len(vulnerability.environmentProperties()) > 0):
for cp in vulnerability.environmentProperties():
environmentNames.append(cp.name())
self.environmentList.load(environmentNames)
for cp in vulnerability.environmentProperties():
environmentName = cp.name()
self.theEnvironmentDictionary[environmentName] = cp
environmentName = environmentNames[0]
p = self.theEnvironmentDictionary[environmentName]
self.sevCtrl.SetStringSelection(p.severity())
self.assetList.setEnvironment(environmentName)
self.assetList.load(p.assets())
self.environmentList.Select(0)
self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
self.theSelectedIdx = 0
def OnEnvironmentSelected(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
p = self.theEnvironmentDictionary[environmentName]
self.sevCtrl.SetStringSelection(p.severity())
self.assetList.setEnvironment(environmentName)
self.assetList.load(p.assets())
def OnEnvironmentDeselected(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
self.theEnvironmentDictionary[environmentName] = VulnerabilityEnvironmentProperties(environmentName,self.sevCtrl.GetValue(),self.assetList.dimensions())
self.sevCtrl.SetValue('')
self.assetList.setEnvironment('')
self.assetList.DeleteAllItems()
self.theSelectedIdx = -1
def OnAddEnvironment(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
self.theEnvironmentDictionary[environmentName] = VulnerabilityEnvironmentProperties(environmentName,'',[])
self.environmentList.Select(self.theSelectedIdx)
self.assetList.setEnvironment(environmentName)
inheritedEnv = self.environmentList.inheritedEnvironment()
if (inheritedEnv != '' and self.theVulId != None):
p = self.dbProxy.inheritedVulnerabilityProperties(self.theVulId,inheritedEnv)
self.theEnvironmentDictionary[environmentName] = p
self.sevCtrl.SetStringSelection(p.severity())
self.assetList.setEnvironment(environmentName)
self.assetList.load(p.assets())
def OnDeleteEnvironment(self,evt):
selectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(selectedIdx)
del self.theEnvironmentDictionary[environmentName]
#.........这里部分代码省略.........
示例5: AttackerEnvironmentPanel
# 需要导入模块: from DimensionListCtrl import DimensionListCtrl [as 别名]
# 或者: from DimensionListCtrl.DimensionListCtrl import setEnvironment [as 别名]
class AttackerEnvironmentPanel(wx.Panel):
def __init__(self,parent,dp):
wx.Panel.__init__(self,parent,armid.ATTACKER_PANELENVIRONMENT_ID)
self.dbProxy = dp
self.theAttackerId = None
self.theEnvironmentDictionary = {}
self.theSelectedIdx = -1
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
environmentBox = wx.StaticBox(self)
environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
mainSizer.Add(environmentListSizer,0,wx.EXPAND)
self.environmentList = EnvironmentListCtrl(self,armid.ATTACKERENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
rmSizer = wx.BoxSizer(wx.HORIZONTAL)
environmentDimSizer.Add(rmSizer,1,wx.EXPAND)
self.roleList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTROLES_ID,wx.DefaultSize,'Role','role',self.dbProxy)
roleBox = wx.StaticBox(self)
roleSizer = wx.StaticBoxSizer(roleBox,wx.HORIZONTAL)
roleSizer.Add(self.roleList,1,wx.EXPAND)
rmSizer.Add(roleSizer,1,wx.EXPAND)
self.motiveList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTMOTIVES_ID,wx.DefaultSize,'Motive','motivation',self.dbProxy)
motiveBox = wx.StaticBox(self)
motiveSizer = wx.StaticBoxSizer(motiveBox,wx.HORIZONTAL)
motiveSizer.Add(self.motiveList,1,wx.EXPAND)
rmSizer.Add(motiveSizer,1,wx.EXPAND)
capBox = wx.StaticBox(self)
capSizer = wx.StaticBoxSizer(capBox,wx.HORIZONTAL)
environmentDimSizer.Add(capSizer,1,wx.EXPAND)
self.capabilitiesList = CapabilitiesListCtrl(self,armid.ATTACKERENVIRONMENT_LISTCAPABILITIES_ID,self.dbProxy)
capSizer.Add(self.capabilitiesList,1,wx.EXPAND)
self.SetSizer(mainSizer)
self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
def loadControls(self,attacker):
self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
self.theAttackerId = attacker.id()
environmentNames = []
for cp in attacker.environmentProperties():
environmentNames.append(cp.name())
self.environmentList.load(environmentNames)
for cp in attacker.environmentProperties():
environmentName = cp.name()
self.theEnvironmentDictionary[environmentName] = cp
environmentNames.append(environmentName)
environmentName = environmentNames[0]
p = self.theEnvironmentDictionary[environmentName]
self.roleList.setEnvironment(environmentName)
self.roleList.load(p.roles())
self.motiveList.setEnvironment(environmentName)
self.motiveList.load(p.motives())
self.capabilitiesList.setEnvironment(environmentName)
self.capabilitiesList.load(p.capabilities())
self.environmentList.Select(0)
self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
self.theSelectedIdx = 0
def OnEnvironmentSelected(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
p = self.theEnvironmentDictionary[environmentName]
self.roleList.setEnvironment(environmentName)
self.roleList.load(p.roles())
self.motiveList.setEnvironment(environmentName)
self.motiveList.load(p.motives())
self.capabilitiesList.setEnvironment(environmentName)
self.capabilitiesList.load(p.capabilities())
def OnEnvironmentDeselected(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
self.theEnvironmentDictionary[environmentName] = AttackerEnvironmentProperties(environmentName,self.roleList.dimensions(),self.motiveList.dimensions(),self.capabilitiesList.capabilities())
self.roleList.setEnvironment('')
self.roleList.DeleteAllItems()
self.motiveList.setEnvironment('')
self.motiveList.DeleteAllItems()
self.capabilitiesList.setEnvironment('')
self.capabilitiesList.DeleteAllItems()
self.theSelectedIdx = -1
def OnAddEnvironment(self,evt):
self.theSelectedIdx = evt.GetIndex()
environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
self.theEnvironmentDictionary[environmentName] = AttackerEnvironmentProperties(environmentName,[],[],[])
self.environmentList.Select(self.theSelectedIdx)
self.capabilitiesList.setEnvironment(environmentName)
inheritedEnv = self.environmentList.inheritedEnvironment()
if (inheritedEnv != '' and self.theAttackerId != None):
p = self.dbProxy.inheritedAttackerProperties(self.theAttackerId,inheritedEnv)
self.theEnvironmentDictionary[environmentName] = p
self.roleList.setEnvironment(environmentName)
#.........这里部分代码省略.........