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

Method __init__

gui/builtinContextMenus/graphFitAmmoPicker.py:81–139  ·  view source on GitHub ↗
(self, parent, fit)

Source from the content-addressed store, hash-verified

79 indent = 15
80
81 def __init__(self, parent, fit):
82 wx.ScrolledCanvas.__init__(self, parent)
83 self.SetScrollRate(0, 15)
84
85 mods = self.getMods(fit)
86 drones = self.getDrones(fit)
87 fighters = self.getFighters(fit)
88 self.rbLabelMap = {}
89 self.rbCheckboxMap = {}
90
91 mainSizer = wx.BoxSizer(wx.VERTICAL)
92
93 moduleSizer = wx.BoxSizer(wx.VERTICAL)
94 mainSizer.Add(moduleSizer, 0, wx.ALL, 0)
95
96 self.droneSizer = wx.BoxSizer(wx.VERTICAL)
97 mainSizer.Add(self.droneSizer, 0, wx.ALL, 0)
98
99 fighterSizer = wx.BoxSizer(wx.VERTICAL)
100 mainSizer.Add(fighterSizer, 0, wx.ALL, 0)
101
102 firstRadio = True
103
104 for modInfo, modAmmo in mods:
105 text = '\n'.join('{}x {}'.format(amount, item.name) for item, amount in modInfo)
106 modRb = self.addRadioButton(moduleSizer, text, firstRadio)
107 firstRadio = False
108 # Get actual module, as ammo getters need it
109 mod = next((m for m in fit.modules if m.itemID == next(iter(modInfo))[0].ID), None)
110 _, ammoTree = Ammo.getInstance().getModuleStructuredAmmo(mod)
111 if len(ammoTree) == 1:
112 for ammoCatName, ammos in ammoTree.items():
113 for ammo in ammos:
114 self.addCheckbox(moduleSizer, ammo.name, modRb, indentLvl=1)
115 else:
116 for ammoCatName, ammos in ammoTree.items():
117 if len(ammos) == 1:
118 ammo = next(iter(ammos))
119 self.addCheckbox(moduleSizer, ammo.name, modRb, indentLvl=1)
120 else:
121 self.addLabel(moduleSizer, '{}:'.format(ammoCatName), modRb, indentLvl=1)
122 for ammo in ammos:
123 self.addCheckbox(moduleSizer, ammo.name, modRb, indentLvl=2)
124 if drones:
125 droneRb = self.addRadioButton(self.droneSizer, 'Drones', firstRadio)
126 from gui.builtinAdditionPanes.droneView import DroneView
127 for drone in sorted(drones, key=DroneView.droneKey):
128 self.addCheckbox(self.droneSizer, '{}x {}'.format(drone.amount, drone.item.name), droneRb, indentLvl=1)
129 addBtn = wx.Button(self, wx.ID_ANY, '+', style=wx.BU_EXACTFIT)
130 addBtn.Bind(wx.EVT_BUTTON, self.OnDroneGroupAdd)
131 mainSizer.Add(addBtn, 0, wx.LEFT, self.indent)
132 if fighters:
133 fighterRb = self.addRadioButton(fighterSizer, 'Fighters', firstRadio)
134 from gui.builtinAdditionPanes.fighterView import FighterDisplay
135 for fighter in sorted(fighters, key=FighterDisplay.fighterKey):
136 self.addCheckbox(fighterSizer, '{}x {}'.format(fighter.amount, fighter.item.name), fighterRb, indentLvl=1)
137
138 self.SetSizer(mainSizer)

Callers

nothing calls this directly

Calls 11

getModsMethod · 0.95
getDronesMethod · 0.95
getFightersMethod · 0.95
addRadioButtonMethod · 0.95
addCheckboxMethod · 0.95
addLabelMethod · 0.95
refreshStatusMethod · 0.95
itemsMethod · 0.80
__init__Method · 0.45
getInstanceMethod · 0.45

Tested by

no test coverage detected