G Code Syntax Check (Python + Qt Designer)

More
1 year 10 months ago #317083 by Hossein74Majidi
Hi
I'm going to use Qt Designer for my Display.
In my python handler I have a method as following:
Code:
def load_selected_gcode(self):         if self.modenumber_str != "Auto":              self.show_message("Invalid Mode", "Switch to Auto Mode.",0)              return         index = self.w.listGCodeFiles.currentIndex()         file_name = self.model.data(index, QtCore.Qt.DisplayRole)          file_path = os.path.join(self.gcode_directory, file_name)         self.loaded_gcod = file_path         with open(file_path, 'r') as file:              gcode_content = file.read()          self.w.showGCode.setText(gcode_content)         self.command.reset_interpreter()          self.command.program_open(file_path)         self.show_message("Success", "G Code is loaded successfully", 1)


this method loads the g code file content into a QTextEdit Widget named " showGCode" now before self.command.reset_interpreter() command and self.command.program_open(file_path) which load the G Code into linuxcnc, I want to check the gcode file syntax. How can I do it? How do I know if my G Code file is ok.

Please Log in to join the conversation.

More
1 year 10 months ago #317096 by cmorley
If you use a graphic display , the file is checked each time it is loaded.
Look here how that is actually done:
github.com/LinuxCNC/linuxcnc/blob/master...qt5_graphics.py#L350

Please Log in to join the conversation.

More
1 year 10 months ago #317139 by Hossein74Majidi

If you use a graphic display , the file is checked each time it is loaded.
Look here how that is actually done:
github.com/LinuxCNC/linuxcnc/blob/master...qt5_graphics.py#L350
 
Thanks for your reply, I dont wanna use graphic display. I simply just want to know if I select a file from a file browser for example, or even a list of gcode files, it returns me an error with some details about the gcode syntax error in that file
I studied the link you've provided but it was so complicated. I didnt get it well

Please Log in to join the conversation.

Time to create page: 0.096 seconds
Powered by Kunena Forum