- Posts: 574
- Thank you received: 96
FileManager extensions
- hottabich
- Offline
- Platinum Member
-
Less
More
5 years 11 months ago - 5 years 11 months ago #190025
by hottabich
Replied by hottabich on topic FileManager extensions
If you write in the handler like this
then when selected, all files will be loaded ngc, tap. In the interface phillc54 must be removed USB copy file.
Code:
#####################
# GENERAL FUNCTIONS #
#####################
def load_code(self, fname):
if fname is None: return
if fname.endswith(".ngc") or fname.endswith(".py") or fname.endswith(".tap"):
Last edit: 5 years 11 months ago by hottabich.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
5 years 11 months ago #190026
by cmorley
Replied by cmorley on topic FileManager extensions
that function has changed quite a bit recently.
It now checks for extension type in INI
In master the function looks like this:
It now checks for extension type in INI
Code:
[FILTER]
PROGRAM_EXTENSION = .ngc,.nc,.tap G-Code File (*.ngc,*.nc,*.tap)
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
In master the function looks like this:
Code:
def load_code(self, fname):
if fname is None: return
filename, file_extension = os.path.splitext(fname)
if not fname.endswith(".html"):
if not (INFO.program_extension_valid(fname)):
self.add_status("Unknown or invalid filename extension {}".format(file_extension))
return
self.w.cmb_gcode_history.addItem(fname)
self.w.cmb_gcode_history.setCurrentIndex(self.w.cmb_gcode_history.count() - 1)
ACTION.OPEN_PROGRAM(fname)
self.add_status("Loaded program file : {}".format(fname))
self.w.main_tab_widget.setCurrentIndex(TAB_MAIN)
self.w.filemanager.recordBookKeeping()
# adjust ending to check for related setup files
fname = filename+'.html'
if os.path.exists(fname):
self.w.web_view.load(QtCore.QUrl.fromLocalFile(fname))
self.add_status("Loaded HTML file : {}".format(fname))
else:
self.w.web_view.setHtml(self.html)
return
else:
try:
self.w.web_view.load(QtCore.QUrl.fromLocalFile(fname))
self.add_status("Loaded HTML file : {}".format(fname))
self.w.main_tab_widget.setCurrentIndex(TAB_SETUP)
self.w.stackedWidget.setCurrentIndex(0)
self.w.btn_setup.setChecked(True)
self.w.jogging_frame.hide()
except Exception as e:
print("Error loading HTML file : {}".format(e))
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
5 years 11 months ago #190028
by cmorley
The very first line
'Q Linuxcnc.ngc'
is not legal code
Chris
Replied by cmorley on topic FileManager extensions
hottabich wrote: Thanks, it works! Another question before the attached file loaded well, and now the code is loading
and the picture remains the same.
The very first line
'Q Linuxcnc.ngc'
is not legal code
Chris
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
5 years 11 months ago #190030
by cmorley
Replied by cmorley on topic FileManager extensions
this is in the next release of 2.8
Code:
def load_code(self, fname):
if fname is None: return
filename, file_extension = os.path.splitext(fname)
if not fname.endswith(".html"):
if not (INFO.program_extension_valid(fname)):
self.add_status("Unknown or invalid filename extension {}".format(file_extension))
return
self.w.cmb_gcode_history.addItem(fname)
self.w.cmb_gcode_history.setCurrentIndex(self.w.cmb_gcode_history.count() - 1)
ACTION.OPEN_PROGRAM(fname)
self.add_status("Loaded program file : {}".format(fname))
self.w.main_tab_widget.setCurrentIndex(TAB_MAIN)
elif fname.endswith(".html"):
self.web_view.load(QtCore.QUrl.fromLocalFile(fname))
self.add_status("Loaded HTML file : {}".format(fname))
self.w.main_tab_widget.setCurrentIndex(TAB_SETUP)
self.w.btn_setup.setChecked(True)
else:
self.add_status("Unknown or invalid filename")
- hottabich
- Offline
- Platinum Member
-
Less
More
- Posts: 574
- Thank you received: 96
5 years 11 months ago #190031
by hottabich
Replied by hottabich on topic FileManager extensions
Thanks! But it worked before. But that's not a problem. I'll put all your corrections into my interfaces. Thank you very much!cmorley wrote:
hottabich wrote: Thanks, it works! Another question before the attached file loaded well, and now the code is loading
and the picture remains the same.
The very first line
'Q Linuxcnc.ngc'
is not legal code
Chris
Moderators: cmorley
Time to create page: 3.223 seconds