From b836ceb216c9bc335cb8a42befce9b9a5805cbfe Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sat, 23 Mar 2019 22:07:08 -0400 Subject: [PATCH] Use checked api instead of bitmap for factor reload (#1897) --- gui/builtinContextMenus/factorReload.py | 9 +++------ gui/contextMenu.py | 10 +++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gui/builtinContextMenus/factorReload.py b/gui/builtinContextMenus/factorReload.py index 5600c4c5c..c70028efc 100644 --- a/gui/builtinContextMenus/factorReload.py +++ b/gui/builtinContextMenus/factorReload.py @@ -29,12 +29,9 @@ class FactorReload(ContextMenu): sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) - def getBitmap(self, context, selection): + @property + def checked(self): sFit = Fit.getInstance() - if sFit.serviceFittingOptions["useGlobalForceReload"]: - return BitmapLoader.getBitmap("state_active_small", "gui") - else: - return None - + return sFit.serviceFittingOptions["useGlobalForceReload"] FactorReload.register() diff --git a/gui/contextMenu.py b/gui/contextMenu.py index b479ab913..ec9048429 100644 --- a/gui/contextMenu.py +++ b/gui/contextMenu.py @@ -79,7 +79,8 @@ class ContextMenu(object): multiple = not isinstance(bitmap, wx.Bitmap) for it, text in enumerate(texts): id = cls.nextID() - rootItem = wx.MenuItem(rootMenu, id, text) + check = m.checked + rootItem = wx.MenuItem(rootMenu, id, text, kind=wx.ITEM_NORMAL if m.checked is None else wx.ITEM_CHECK) rootMenu.info[id] = (m, fullContext, it) sub = m.getSubMenu(srcContext, selection, rootMenu, it, rootItem) @@ -114,6 +115,9 @@ class ContextMenu(object): rootMenu.Append(rootItem) + if check is not None: + rootItem.Check(check) + empty = False if display_amount > 0 and i != len(fullContexts) - 1: @@ -177,6 +181,10 @@ class ContextMenu(object): def getBitmap(self, context, selection): return None + @property + def checked(self): + '''If menu item is toggleable, this should return bool value''' + return None # noinspection PyUnresolvedReferences from gui.builtinContextMenus import ( # noqa: E402,F401