FileManager extensions

More
20 Nov 2020 07:37 #189875 by hottabich
Replied by hottabich on topic FileManager extensions
Hello! Editor file does not work. Linuxcnc from 11/18/20. Is it mine or a general question? Prompt
you are welcome.
Attachments:

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

More
20 Nov 2020 21:45 #189928 by cmorley
Replied by cmorley on topic FileManager extensions
I see this problem too. probably do to recent changes to processed_key_event__()
when I added WRITER code.

I'll look into it soon.

Chris

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

More
21 Nov 2020 05:38 #189952 by cmorley
Replied by cmorley on topic FileManager extensions
try in handlerfile
            if flag:
                if isinstance(receiver2, GCODE):
                    # if in manual or in readonly mode do our keybindings - otherwise
                    # send events to gcode widget
                    if STATUS.is_man_mode() == False or not receiver2.editor.isReadOnly():
                        if is_pressed:
                            receiver.keyPressEvent(event)

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

More
21 Nov 2020 07:03 #189960 by hottabich
Replied by hottabich on topic FileManager extensions
Thanks, it works! Another question before the attached file loaded well, and now the code is loading
and the picture remains the same.
Attachments:

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

More
22 Nov 2020 06:56 - 22 Nov 2020 07:04 #190025 by hottabich
Replied by hottabich on topic FileManager extensions
If you write in the handler like this
#####################
    # GENERAL FUNCTIONS #
    #####################
    def load_code(self, fname):
        if fname is None: return
        if fname.endswith(".ngc") or fname.endswith(".py") or fname.endswith(".tap"):
then when selected, all files will be loaded ngc, tap. In the interface phillc54 must be removed USB copy file.
Attachments:
Last edit: 22 Nov 2020 07:04 by hottabich.

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

More
22 Nov 2020 07:13 #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
[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:
    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))

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

More
22 Nov 2020 07:20 #190028 by cmorley
Replied by cmorley on topic FileManager extensions

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

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

More
22 Nov 2020 07:27 #190030 by cmorley
Replied by cmorley on topic FileManager extensions
this is in the next release of 2.8
    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")

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

More
22 Nov 2020 08:32 #190031 by hottabich
Replied by hottabich on topic FileManager extensions

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

Thanks! But it worked before. But that's not a problem. I'll put all your corrections into my interfaces. Thank you very much!

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

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