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

Class FighterView

gui/builtinAdditionPanes/fighterView.py:64–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63
64class FighterView(wx.Panel):
65
66 def __init__(self, parent):
67 wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL)
68 self.mainFrame = gui.mainFrame.MainFrame.getInstance()
69 self.labels = [("Light", _t("Light")), ("Heavy", _t("Heavy")), ("Support", _t("Support"))]
70
71 mainSizer = wx.BoxSizer(wx.VERTICAL)
72
73 self.fighterDisplay = FighterDisplay(self)
74 mainSizer.Add(self.fighterDisplay, 1, wx.EXPAND, 0)
75
76 textSizer = wx.BoxSizer(wx.HORIZONTAL)
77 textSizer.AddStretchSpacer()
78
79 for attr, label in self.labels:
80 lbl = wx.StaticText(self, wx.ID_ANY, label)
81 textSizer.Add(lbl, 0, wx.ALIGN_CENTER | wx.LEFT, 5)
82
83 lbl = wx.StaticText(self, wx.ID_ANY, "0")
84 setattr(self, "label%sUsed" % attr, lbl)
85 textSizer.Add(lbl, 0, wx.ALIGN_CENTER | wx.LEFT, 5)
86
87 textSizer.Add(wx.StaticText(self, wx.ID_ANY, "/"), 0, wx.ALIGN_CENTER)
88
89 lbl = wx.StaticText(self, wx.ID_ANY, "0")
90 setattr(self, "label%sTotal" % attr, lbl)
91 textSizer.Add(lbl, 0, wx.ALIGN_CENTER)
92 textSizer.AddStretchSpacer()
93
94 mainSizer.Add(textSizer, 0, wx.EXPAND, 5)
95
96 self.SetSizer(mainSizer)
97 self.SetAutoLayout(True)
98
99 self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
100
101 def fitChanged(self, event):
102 event.Skip()
103 activeFitID = self.mainFrame.getActiveFit()
104 if activeFitID is not None and activeFitID not in event.fitIDs:
105 return
106
107 sFit = Fit.getInstance()
108 fit = sFit.getFit(activeFitID)
109
110 if fit:
111 for x, _ in self.labels:
112 if fit.isStructure:
113 slot = getattr(FittingSlot, "FS_{}".format(x.upper()))
114 else:
115 slot = getattr(FittingSlot, "F_{}".format(x.upper()))
116 used = fit.getSlotsUsed(slot)
117 total = fit.getNumSlots(slot)
118 color = wx.Colour(204, 51, 51) if used > total else wx.SystemSettings.GetColour(
119 wx.SYS_COLOUR_WINDOWTEXT)
120
121 lbl = getattr(self, "label%sUsed" % x.capitalize())

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected