Esempio n. 1
0
    def libraryLoad(self, path):
        self.toolTableView.setUpdatesEnabled(False)
        self.model.clear()
        self.model.setHorizontalHeaderLabels(self.columnNames())

        if path:
            with open(path) as fp:
                PathPreferences.setLastPathToolTable(os.path.basename(path))
                library = json.load(fp)

            for toolBit in library['tools']:
                nr = toolBit['nr']
                bit = PathToolBit.findBit(toolBit['path'])
                if bit:
                    PathLog.track(bit)
                    tool = PathToolBit.Declaration(bit)
                    self._toolAdd(nr, tool, bit)
                else:
                    PathLog.error("Could not find tool #{}: {}".format(
                        nr, library['tools'][nr]))

            self.toolTableView.resizeColumnsToContents()

        self.toolTableView.setUpdatesEnabled(True)

        self.form.setWindowTitle("{} - {}".format(
            self.title,
            os.path.basename(path) if path else ''))
        self.path = path
        self.updateToolbar()
Esempio n. 2
0
    def librarySaveAs(self):
        TooltableTypeJSON = translate("PathToolLibraryManager",
                                      "Tooltable JSON (*.fctl)")
        TooltableTypeLinuxCNC = translate("PathToolLibraryManager",
                                          "LinuxCNC tooltable (*.tbl)")

        filename = PySide.QtGui.QFileDialog.getSaveFileName(
            self.form,
            translate("TooltableEditor", "Save toolbit library", None),
            PathPreferences.lastPathToolLibrary(),
            "{};;{}".format(TooltableTypeJSON, TooltableTypeLinuxCNC))
        # filename = PySide.QtGui.QFileDialog.getSaveFileName(self.form, \
        #        'Tool Library', PathPreferences.lastPathToolLibrary(), '*.fctl')
        if filename and filename[0]:
            if filename[1] == TooltableTypeLinuxCNC:
                path = filename[0] if filename[0].endswith(
                    '.tbl') else "{}.tbl".format(filename[0])
                self.libararySaveLinuxCNC(path)
            else:
                path = filename[0] if filename[0].endswith(
                    '.fctl') else "{}.fctl".format(filename[0])
                PathPreferences.setLastPathToolLibrary(os.path.dirname(path))
                self.path = path
                self.librarySave()
                self.updateToolbar()
                PathPreferences.setLastPathToolTable(os.path.basename(path))
                self.libraryOpen(None, False)
Esempio n. 3
0
 def libraryDelete(self):
     PathLog.track()
     reply = QtGui.QMessageBox.question(self.form, 'Warning', "Delete " + os.path.basename(self.path) + "?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel)
     if reply == QtGui.QMessageBox.Yes and len(self.path) > 0:
         os.remove(self.path)
         PathPreferences.setLastPathToolTable("")
         self.libraryOpen(filedialog=False)