Use checked api instead of bitmap for factor reload (#1897)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user