MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / getSubMenu

Method getSubMenu

gui/builtinContextMenus/targetProfile/adder.py:51–88  ·  view source on GitHub ↗
(self, callingWindow, context, rootMenu, i, pitem)

Source from the content-addressed store, hash-verified

49 return menuItem
50
51 def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
52 self.callingWindow = callingWindow
53 sTR = svc_TargetProfile.getInstance()
54 profiles = list(chain(sTR.getBuiltinTargetProfileList(), sTR.getUserTargetProfileList()))
55 profiles.sort(key=lambda p: smartSort(p.fullName))
56
57 self.eventProfileMap = {}
58 items = (OrderedDict(), OrderedDict())
59 for profile in profiles:
60 container = items
61 for categoryName in profile.hierarchy:
62 categoryName = _t(categoryName) if profile.builtin else categoryName
63 container = container[1].setdefault(categoryName, (OrderedDict(), OrderedDict()))
64 shortName = _t(profile.shortName) if profile.builtin else profile.shortName
65 container[0][shortName] = profile
66
67 # Category as menu item - expands further
68 msw = "wxMSW" in wx.PlatformInfo
69
70 def makeMenu(container, parentMenu, first=False):
71 menu = wx.Menu()
72 if first:
73 idealProfile = TargetProfile.getIdeal()
74 mitem = self._addProfile(rootMenu if msw else parentMenu, idealProfile, idealProfile.fullName)
75 menu.Append(mitem)
76 for name, pattern in container[0].items():
77 menuItem = self._addProfile(rootMenu if msw else parentMenu, pattern, name)
78 menu.Append(menuItem)
79 for name, subcontainer in container[1].items():
80 menuItem = self._addCategory(rootMenu if msw else parentMenu, name)
81 subMenu = makeMenu(subcontainer, menu)
82 menuItem.SetSubMenu(subMenu)
83 menu.Append(menuItem)
84 menu.Bind(wx.EVT_MENU, self.handleProfileAdd)
85 return menu
86
87 subMenu = makeMenu(items, rootMenu, first=True)
88 return subMenu
89
90
91TargetProfileAdder.register()

Callers

nothing calls this directly

Calls 6

smartSortFunction · 0.90
_tFunction · 0.50
getInstanceMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected