mirror of
https://github.com/jdegenstein/jmwright-CQ-Editor.git
synced 2025-12-20 14:37:04 +01:00
Update debugger.py
This commit is contained in:
@@ -191,8 +191,27 @@ class Debugger(QObject,ComponentMixin):
|
|||||||
if self.preferences['Reload imported modules']:
|
if self.preferences['Reload imported modules']:
|
||||||
stack.enter_context(module_manager())
|
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):
|
def _inject_locals(self,module):
|
||||||
|
|
||||||
cq_objects = {}
|
cq_objects = {}
|
||||||
@@ -208,28 +227,9 @@ class Debugger(QObject,ComponentMixin):
|
|||||||
|
|
||||||
_show_object(obj,name,options=dict(color='red',alpha=0.2))
|
_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__['show_object'] = _show_object
|
||||||
module.__dict__['debug'] = _debug
|
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__['log'] = lambda x: info(str(x))
|
||||||
module.__dict__['cq'] = cq
|
module.__dict__['cq'] = cq
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user