MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / validateFields

Method validateFields

gui/targetProfileEditor.py:271–304  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

269 wx.PostEvent(self.mainFrame, GE.TargetProfileChanged(profileID=p.ID))
270
271 def validateFields(self):
272 valid = True
273 try:
274 p = self.entityEditor.getActiveEntity()
275
276 for type_ in self.DAMAGE_TYPES:
277 editBox = getattr(self, "%sEdit" % type_)
278 # Raise exception if value is not valid
279 if not editBox.isValid():
280 reason = editBox.getInvalidationReason()
281 raise ValueError(reason)
282
283 value = editBox.GetValueFloat() or 0
284 setattr(p, "%sAmount" % type_, value / 100)
285
286 for attr in self.ATTRIBUTES:
287 editBox = getattr(self, "%sEdit" % attr)
288 # Raise exception if value is not valid
289 if not editBox.isValid():
290 reason = editBox.getInvalidationReason()
291 raise ValueError(reason)
292
293 value = editBox.GetValueFloat()
294 setattr(p, attr, value)
295
296 self.stNotice.SetLabel("")
297 self.totSizer.Layout()
298
299 except ValueError as e:
300 self.stNotice.SetLabel(e.args[0])
301 valid = False
302 finally: # Refresh for color changes to take effect immediately
303 self.Refresh()
304 return valid
305
306 def patternChanged(self, event=None):
307 """Event fired when user selects pattern. Can also be called from script"""

Callers 2

OnInputTimerMethod · 0.95
patternChangedMethod · 0.95

Calls 6

getActiveEntityMethod · 0.80
getInvalidationReasonMethod · 0.80
GetValueFloatMethod · 0.80
SetLabelMethod · 0.80
isValidMethod · 0.45
RefreshMethod · 0.45

Tested by

no test coverage detected