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

Class TargetWrapperList

graphs/gui/lists.py:316–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314
315
316class TargetWrapperList(BaseWrapperList):
317
318 DEFAULT_COLS = (
319 'Graph Lightness',
320 'Graph Line Style',
321 'Base Icon',
322 'Base Name')
323
324 def __init__(self, graphFrame, parent):
325 super().__init__(graphFrame, parent)
326
327 self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu)
328
329 self.appendItem(TargetProfile.getIdeal())
330 self.updateView()
331
332 def appendItem(self, item):
333 # Find out least used lightness
334 lightnessUseMap = {(l, s): 0 for l in LIGHTNESSES for s in STYLES}
335 for wrapper in self._wrappers:
336 key = (wrapper.lightnessID, wrapper.lineStyleID)
337 if key not in lightnessUseMap:
338 continue
339 lightnessUseMap[key] += 1
340
341 def getDefaultParams():
342 leastUses = min(lightnessUseMap.values(), default=0)
343 for lineStyleID in STYLES:
344 for lightnessID in LIGHTNESSES:
345 if leastUses == lightnessUseMap.get((lightnessID, lineStyleID), 0):
346 return lightnessID, lineStyleID
347 return None, None
348
349 lightnessID, lineStyleID = getDefaultParams()
350 self._wrappers.append(TargetWrapper(item=item, lightnessID=lightnessID, lineStyleID=lineStyleID))
351
352 def spawnMenu(self, event):
353 clickedPos = self.getRowByAbs(event.Position)
354 self.ensureSelection(clickedPos)
355
356 selection = self.getSelectedWrappers()
357 mainItem = self.getWrapper(clickedPos)
358
359 itemContext = None if mainItem is None else _t('Target')
360 menu = ContextMenu.getMenu(self, mainItem, selection, ('graphTgtList', itemContext), ('graphTgtListMisc', itemContext))
361 if menu:
362 self.PopupMenu(menu)
363
364 def OnResistModeChanged(self, event):
365 if set(event.fitIDs).intersection(w.item.ID for w in self._wrappers if w.isFit):
366 self.updateView()
367
368 @property
369 def defaultTTText(self):
370 return _t('Drag a fit into this list to have your fits graphed against it')
371
372 # Context menu handlers
373 def addProfile(self, profile):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected