Here is The Trick Python Macro Button Toggle Link:
http://hardwired.cc/?p=137
Not Mine!
Using the code from the above link, which is copied below, I have installed the Fan ON/OFF Toggle Button Macro. I can not test now but, it should work on the machine. It does work in the Pronterface GUI. I have read the Pronterface Readme example about a toggle Macro. The code calls to Python and modules are cryptic to me still. Yep, YANC (Yet Another Non-Coder.) So, ...
I have a request and questions to the Python coders ------ Would someone please put colors to the ON & OFF buttons? How would the button background be coded for color? I'm unable to fake it to cobble some success...
I do see in the macro code two variables (self & cur_button) for the button text and button instance(?). I kinda understand the object oriented variables dotted together. Would there be a third color variable pulled from air or a module as a color variable? Then, this too would be dotted to the other two variables/objects? Where does cur_button come from? Is 'hasattr' a module function call? Are these wxWidget or pyglet or what?
How to Install the Fan Button Toggle Macro
To others that will use the button - Create a new button in Pronterface. Name your button, Fan. To the right of the 'command' name field there is an ellipses - "..." Press that. Then, a macro naming box opens with an input field and two smashed buttons, which can not be read (OK & Cancel ???). Type a Macro name like: fan. Now, click the smashed button on the left (OK?). A programming window opens. Copy-n-Paste the code below into the Pronterface Macro code window. Click 'Save'. Click 'OK'. You now have a Fan ON/OFF Toggle Button. Note:You might have to restart Pronterface. If you restarted the application, you should have a new 'Fan' button. Once you select it the first time - it will become a Toggle button for the 'Fan ON' and the 'Fan OFF'. Kinda nice. I am seeking a little color too...
macro fan
!global _fan
!if '_fan' in globals() and _fan:
!_fan = 0
M107
!if hasattr(self,"cur_button") and self.cur_button is not None:
!self.onecmd('button %d "Fan ON" fan' % self.cur_button)
!else:
!_fan = 1
M106
!if hasattr(self,"cur_button") and self.cur_button is not None:
!self.onecmd('button %d "Fan OFF" fan' % self.cur_button)