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

Class SourceWrapperList

graphs/gui/lists.py:264–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262
263
264class SourceWrapperList(BaseWrapperList):
265
266 DEFAULT_COLS = (
267 'Graph Color',
268 'Base Icon',
269 'Base Name')
270
271 def __init__(self, graphFrame, parent):
272 super().__init__(graphFrame, parent)
273
274 self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu)
275
276 fit = Fit.getInstance().getFit(self.graphFrame.mainFrame.getActiveFit())
277 if fit is not None:
278 self.appendItem(fit)
279 self.updateView()
280
281 def appendItem(self, item):
282 # Find out least used color
283 colorUseMap = {c: 0 for c in BASE_COLORS}
284 for wrapper in self._wrappers:
285 if wrapper.colorID not in colorUseMap:
286 continue
287 colorUseMap[wrapper.colorID] += 1
288
289 def getDefaultParams():
290 leastUses = min(colorUseMap.values(), default=0)
291 for colorID in BASE_COLORS:
292 if leastUses == colorUseMap.get(colorID, 0):
293 return colorID
294 return None
295
296 colorID = getDefaultParams()
297 self._wrappers.append(SourceWrapper(item=item, colorID=colorID))
298
299 def spawnMenu(self, event):
300 clickedPos = self.getRowByAbs(event.Position)
301 self.ensureSelection(clickedPos)
302
303 selection = self.getSelectedWrappers()
304 mainItem = self.getWrapper(clickedPos)
305
306 itemContext = None if mainItem is None else _t('Fit')
307 menu = ContextMenu.getMenu(self, mainItem, selection, ('graphFitList', itemContext), ('graphFitListMisc', itemContext))
308 if menu:
309 self.PopupMenu(menu)
310
311 @property
312 def defaultTTText(self):
313 return _t('Drag a fit into this list to graph it')
314
315
316class TargetWrapperList(BaseWrapperList):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected