diff --git a/cq_editor/widgets/debugger.py b/cq_editor/widgets/debugger.py index bb95053..3693b7d 100644 --- a/cq_editor/widgets/debugger.py +++ b/cq_editor/widgets/debugger.py @@ -191,8 +191,27 @@ class Debugger(QObject,ComponentMixin): if self.preferences['Reload imported modules']: stack.enter_context(module_manager()) - exec(code, locals_dict, globals_dict) + exec(code, locals_dict, globals_dict) + def _rand_color(self, alpha = 0., cfloat=False): + #helper function to generate a random color dict + #for CQ-editor's show_object function + lower = 10 + upper = 100 #not too high to keep color brightness in check + if cfloat: #for two output types depending on need + return ( + (rrr(lower,upper)/255), + (rrr(lower,upper)/255), + (rrr(lower,upper)/255), + alpha, + ) + return {"alpha": alpha, + "color": ( + rrr(lower,upper), + rrr(lower,upper), + rrr(lower,upper), + )} + def _inject_locals(self,module): cq_objects = {} @@ -208,28 +227,9 @@ class Debugger(QObject,ComponentMixin): _show_object(obj,name,options=dict(color='red',alpha=0.2)) - def _rand_color(alpha = 0., cfloat=False): - #helper function to generate a random color dict - #for CQ-editor's show_object function - lower = 10 - upper = 100 #not too high to keep color brightness in check - if cfloat: #for two output types depending on need - return ( - (rrr(lower,upper)/255), - (rrr(lower,upper)/255), - (rrr(lower,upper)/255), - alpha, - ) - return {"alpha": alpha, - "color": ( - rrr(lower,upper), - rrr(lower,upper), - rrr(lower,upper), - )} - module.__dict__['show_object'] = _show_object module.__dict__['debug'] = _debug - module.__dict__['rand_color'] = _rand_color + module.__dict__['rand_color'] = self._rand_color module.__dict__['log'] = lambda x: info(str(x)) module.__dict__['cq'] = cq