Custom M-Code (Python)

More
23 Mar 2022 01:20 #238066 by andypugh
Replied by andypugh on topic Custom M-Code (Python)
At the moment, for reasons I don't fully understand, emcanon is only available in remaps.

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

More
23 Mar 2022 01:35 #238068 by cmorley
Replied by cmorley on topic Custom M-Code (Python)
emccanon is called from the internal python instance in remaps.
The internal instance is invoked from linuxcnc's c++ code, so has linuxcnc's internals in it's context.

Any other instance of python will be in a different context.

That's the high level explanation.
The following user(s) said Thank You: Thom

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

More
04 Aug 2022 17:54 #249052 by cncbeagle
Replied by cncbeagle on topic Custom M-Code (Python)
Andy, Todd,

Thank You!
Prompting for a parameter entry seemed like such a simple thing but that was not the case. I would never have figured out how to do this myself. You're solution was relatively easy to implement and works great.

Thanks again.

John
The following user(s) said Thank You: tommylight

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

  • Todd Zuercher
  • Todd Zuercher's Avatar Topic Author
  • Away
  • Platinum Member
  • Platinum Member
More
29 Jun 2026 16:19 - 29 Jun 2026 16:22 #347392 by Todd Zuercher
Replied by Todd Zuercher on topic Custom M-Code (Python)
I was wanting to revisit this, and tried to make it work with the current version of linuxcnc, but it seems that the switch from Python2 to Python3 has rendered the python remap script non functional.

At first Linuxcnc wouldn't even start. But with clues from error messages I changed the 4th line from:
from Tkinter import *
to:
from tkinter import *

And that got the config running again.  But it still doesn't work right and now there are no error messages.  The input window opens, but it is completely empty except for the OK button and the title doesn't show in the title bar.  So at least a little of the Tkinter is working, but not most of it.
Last edit: 29 Jun 2026 16:22 by Todd Zuercher.

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

More
29 Jun 2026 17:28 #347394 by MaHa
Replied by MaHa on topic Custom M-Code (Python)
I don't know if this helps, as i am usually wrong. In a project with tkinter yesnobox, thats the first lines of the python file


#! /usr/bin/python3

import tkinter as tk
import tkinter.messagebox
import sys
import linuxcnc
import time

root = tk.Tk()
root.withdraw()
The following user(s) said Thank You: rodw

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

Time to create page: 0.166 seconds
Powered by Kunena Forum