Klipper Screen and Python

Dear community,

I am running Klipper on my customized 3D printer and I need to implement an icon in KlipperScreen that, when clicked, can execute a Python script.

The Python script communicates with Moonraker to control the 3D printer and perform certain actions. However, I am facing an issue where KlipperScreen does not directly work with Python. Here’s what I have tried so far:

  1. Created an icon in KlipperScreen with the following configuration:

    [menu __main check_status]
    name: Check Ruso
    icon: status
    method: printer.gcode.script
    params: {"script":"SEND_MESSAGE Hello"}
    
  2. Created a macro in printer.cfg:

    [gcode_macro SEND_MESSAGE]
    gcode:
        SYSTEM /home/diego/testing_code.py "{rawparams}"
    

However, I receive the following error:

[screen.py:show_popup_message()] - error: Malformed command 'SEND_MESSAGE Hello, Klipper!'

Does anyone have any suggestions on how to properly configure this? Any help would be greatly appreciated.

Thank you in advance!

I recently developed DynamicMacros, which allows you to run Python from a macro (any many other features). Documentation is here.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.