Contact me: hankecnc@gmail.com

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290

推推 grbl 3年前 (2023-02-02) 230次浏览
关闭
mj1911 开了这个issue 2019 年 10 月 7 日 · 6条评论
关闭

插件问题:是否可以取消选中 execute() 方法中的复选框?#1290

mj1911 开了这个issue 2019 年 10 月 7 日 · 6条评论

评论

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290

您好,我正在尝试修改示例插件。我想让用户为他们希望执行的任务选中某些框。执行插件时,应清除复选框。有没有办法以编程方式从 def execute(self, app) 中清除这些复选框?我努力了:

self["CheckBox"] = 0 # no error, but does not work.
self["CheckBox"]["bool"] = False # TypeError: 'int' object does not support item assignment
self.variables["CheckBox"] = 0 # TypeError: list indices must be integers, not str
self.variables["%s.%d"%("CheckBox",self.current)] = 0 # TypeError: %d format: a number is required, not NoneType
self["CheckBox"].set(False) # AttributeError: 'int' object has no attribute 'set'
self["CheckBox"].bool = False # AttributeError: 'int' object has no attribute 'bool'
self.variables.CheckBox = False # AttributeError: 'list' object has no attribute 'CheckBox'
self.variables.CheckBox.set(False) # AttributeError: 'list' object has no attribute 'CheckBox'
self.variables["CheckBox"] = False # TypeError: list indices must be integers, not str
self.variables.index["CheckBox"] = 0 # TypeError: 'builtin_function_or_method' object does not support item assignment
self.variables.index["CheckBox"].set(False) # TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
self.variables.index["CheckBox"].index["bool"] = False # TypeError: 'builtin_function_or_method' obj has no attrib '__getitem__'
self.variables[5] = False # no error, but no work. gave an error when re-checking the box, however.
self.variables[5][:2] = False # TypeError: 'tuple' object does not support item assignment
self.variables[5][2] = 0 # same
self.variables[5:2] = 0 # TypeError: can only assign an iterable

global config	# from Utils.py
config.set(variables, "CheckBox", str(int(0))) # NameError: global name 'config' is not defined
setbool(variables, "CheckBox", str(int(0))) # NameError: global name 'config' is not defined

希望这个功能存在,我只是对确切的措辞一无所知。谢谢你。

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290
作者

好的,在整个模块进行调试后,我了解到:

self["CheckBox"] = True   # changes value, but not checkbox state
self["CheckBox"] = False  # changes value, but not checkbox state

有没有办法将此值传播回控件,因此复选框实际上发生了变化?运行时有太多 tkinter 条目,我什至很难找到控件。

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290
合作者

您能否准确描述用例是什么?我觉得有点好笑。

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290
作者

当然。插件可以生成圆形、矩形和三角形。用户选中“圆”,并输入 5mm 的尺寸、坐标等。然后按下执行按钮并创建 gcode。然后用户选中“矩形”,将大小更改为 20mm,然后单击执行。但是他们忘记取消选中“圆”,所以现在将执行两个操作(20mm 圆和 20mm 矩形)。这些(圆、矩形、三角形)复选框必须在每次执行后自动取消选中以防止这种情况发生。

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290
合作者

这听起来像是选择框的用例,与我在切割策略中使用的相同:

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290
作者

这是一个非常好的解决方案。不确定为什么我如此专注于为此使用复选框。感谢您的建议。

插件问题:是否可以取消选中 execute() 方法中的复选框? #1290
合作者

没问题。感谢您对 bCNC 开发的关注:-)