def __getitem__(self, key): # KLUGE 1: provide this interface in this class # rather than in a wrapper class. (No harm, AFAIK.) # KLUGE 2: get current global graphicsMode # instead of getting it from how we're called. # (See also USE_CURRENT, which also does this, # but in its case it's not a kluge.) ### TODO to fix this kluge: make a "prefs value object" which # wraps this object but stores glpane, to use instead of this object. # But note that ThumbView has no graphicsMode attribute! win = env.mainWindow() glpane = win.glpane graphicsMode = glpane.graphicsMode context = graphicsMode return self.get_value(key, context)
def __getitem__(self, key): # get the "current glpane" and its graphicsMode # (for purposes of determining modes & prefs) # (how we do it is not necessarily a kluge, given that this is being # used to define a constant value for use when a better one was # not passed) win = env.mainWindow() glpane = win.glpane graphicsMode = glpane.graphicsMode # let the graphicsMode interpret the prefs key, # in case it wants to override it with a local pref # (or conceivably, someday, track it in a different way) # (note, ThumbView has no graphicsMode, but that doesn't # affect this code since it uses main glpane even when # drawing into a ThumbView. [bruce 080606 comment]) try: res = graphicsMode.get_prefs_value(key) except: msg = "bug: exception in %r.get_prefs_value(%r), %s" % \ (graphicsMode, key, "falling back to env.prefs") print_compact_traceback(msg + ": ") res = env.prefs[key] return res