[QtDragon] Run macros with "INSTANCE.mditouchy.run_command()"

More
23 Feb 2022 01:50 #235576 by RomeReactor
Hi all. I've tried to run a macro (already added to the ini file) in QtDragon using the method described here , but without success. Can anyone help please?

Please Log in or Create an account to join the conversation.

More
23 Feb 2022 02:02 #235577 by cmorley
Qtdragon does not have the MDItouchy widget included.
What version of linuxcnc are you using?

Please Log in or Create an account to join the conversation.

More
23 Feb 2022 19:23 - 23 Feb 2022 19:27 #235638 by RomeReactor
Just upgraded to master (2.9).

I added this section to qtdragon_handler.py:
from qtvcp.widgets.mdi_touchy import MDITouchy as MT
And:
def on_btn_macro_pressed(self, data = None):
    if STATUS.is_mdi_mode():
        self.w.MT.run_command()
        return
But it complains with:

AttributeError: 'VCPWindow' object has no attribute 'MT'

Last edit: 23 Feb 2022 19:27 by RomeReactor.

Please Log in or Create an account to join the conversation.

More
24 Feb 2022 06:34 #235676 by cmorley
Unfortunately it's more involved then this.
While you have loaded the widget library, you have not made an 'instance' of the widget.
After doing that you must add it to a container widget that is already in qtdragon - usually a stacked widget.
Then you must have a way to select that widget from the stack.
And finally a way to invoke the action of the code.
I tried adding the MDI_touchy widget to a custom qtdragon.ui file but the color scheme hid the text. I haven't the time tonight to figure that problem out yet.

Do you want the MDI_touchy widget or just want the macro button utility?

Qtdragon_hd has ten optional 'macro' buttons added recently bit qtdragon didn't get them.

Please Log in or Create an account to join the conversation.

More
24 Feb 2022 20:23 - 24 Feb 2022 20:30 #235740 by RomeReactor
I think we just need the ability to run macros from a button. Ideally we should be able to dynamically create the buttons based on the number of macro entries in the ini file, but for the moment we managed to run a macro from a button created in the qtdragon.ui file in designer (adding "INSTANCE.on_btn_macro_1_pressed()" to the "true_python_cmd_string" of the button):
INSTANCE.on_btn_macro_1_pressed()
And adding this to the handler file:
    def on_btn_macro_1_pressed(self, data = None):
        file = open('/home/numtek/linuxcnc/configs/sim.qtvcp_screens.qtdragon/qtdragon.ini')
        content = file.readlines()
        m1 = content[266]
        a_string = m1
        sliced = a_string[8:]
        sliced = sliced.rstrip("\n")
        file = open(f"/home/numtek/linuxcnc/nc_files/{sliced}.ngc", 'r')
        for i in file.readlines():
            ACTION.CALL_MDI(i)
            file.close()

Although the macro file is just a collection of gcodes without anything else).
Last edit: 24 Feb 2022 20:30 by RomeReactor.

Please Log in or Create an account to join the conversation.

Moderators: cmorley
Time to create page: 0.074 seconds
Powered by Kunena Forum