def __init__(self, parent=None): super(FileSystemTable, self).__init__(parent) self._table_type = TableType.Local # This prevents doing unneeded initialization # when QtDesginer loads the plugin. if parent is None: return self.parent = parent self.path_data = dict() self.doubleClicked.connect(self.changeRoot) self.selected_row = None self.clipboard = QApplication.clipboard() self.model = QFileSystemModel() self.model.setReadOnly(True) self.model.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot | QDir.AllEntries) self.setModel(self.model) self.verticalHeader().hide() self.horizontalHeader().setStretchLastSection(True) self.setAlternatingRowColors(True) self.setSelectionBehavior(QAbstractItemView.SelectRows) self.info = Info() self._nc_file_dir = self.info.getProgramPrefix() self.setRootPath(self._nc_file_dir)
def __init__(self, parent=None): super(OffsetsDialog, self).__init__(parent=parent, flags=Qt.Popup) self.info = Info() self.log = Log axis_list = self.info.getAxisList() self.axis_combo = QComboBox() for axis in axis_list: self.axis_combo.addItem(axis.upper(), axis) coords_msg = QLabel("Coordinate relative to workpiece:") system_msg = QLabel("Coordinate System:") self.coords_input = QLineEdit('0.0000') self.coords_input.setInputMask('000009.00000') self.system_combo = QComboBox() coord_systems = {"P0": "P0 Current", "P1": "P1 G54", "P2": "P2 G55", "P3": "P3 G56", "P4": "P4 G57", "P5": "P5 G58", "P6": "P6 G59", "P7": "P7 G59.1", "P8": "P8 G59.1", "P9": "P9 G59.3" } for key, value in OrderedDict(sorted(coord_systems.items(), key=lambda t: t[0])).items(): self.system_combo.addItem(value, key) close_button = QPushButton("Close") set_button = QPushButton("Set") main_layout = QVBoxLayout() button_layout = QHBoxLayout() button_layout.addWidget(close_button) button_layout.addWidget(set_button) main_layout.addWidget(self.axis_combo, alignment=Qt.AlignTop) main_layout.addWidget(coords_msg, alignment=Qt.AlignLeft | Qt.AlignTop) main_layout.addWidget(self.coords_input, alignment=Qt.AlignTop) main_layout.addWidget(system_msg, alignment=Qt.AlignLeft | Qt.AlignTop) main_layout.addWidget(self.system_combo, alignment=Qt.AlignBottom) main_layout.addLayout(button_layout) self.setLayout(main_layout) self.setWindowTitle("Regular Offsets") set_button.clicked.connect(self.set_method) close_button.clicked.connect(self.close_method)
# You should have received a copy of the GNU General Public License # along with QtPyVCP. If not, see <http://www.gnu.org/licenses/>. # Description: # LinuxCNC spindle related actions import sys import linuxcnc # Set up logging from QtPyVCP.utilities import logger LOG = logger.getLogger(__name__) from QtPyVCP.utilities.info import Info from QtPyVCP.utilities.status import Status INFO = Info() STATUS = Status() STAT = STATUS.stat CMD = linuxcnc.command() from QtPyVCP.actions.base_actions import setTaskMode def _spindle_ok(widget=None): if STAT.task_state != linuxcnc.STATE_ON: ok = False msg = "Can't run spindle until machine it ON" elif STAT.task_mode == linuxcnc.MODE_AUTO: ok = False msg = "Machine must be in Manuel mode"
class FileSystemTable(QTableView, TableType): Q_ENUMS(TableType) transferFileRequest = pyqtSignal(str) rootChanged = pyqtSignal(str) def __init__(self, parent=None): super(FileSystemTable, self).__init__(parent) self._table_type = TableType.Local # This prevents doing unneeded initialization # when QtDesginer loads the plugin. if parent is None: return self.parent = parent self.path_data = dict() self.doubleClicked.connect(self.changeRoot) self.selected_row = None self.clipboard = QApplication.clipboard() self.model = QFileSystemModel() self.model.setReadOnly(True) self.model.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot | QDir.AllEntries) self.setModel(self.model) self.verticalHeader().hide() self.horizontalHeader().setStretchLastSection(True) self.setAlternatingRowColors(True) self.setSelectionBehavior(QAbstractItemView.SelectRows) self.info = Info() self._nc_file_dir = self.info.getProgramPrefix() self.setRootPath(self._nc_file_dir) def showEvent(self, event=None): self.rootChanged.emit(self._nc_file_dir) def changeRoot(self, index): path = self.model.filePath(self.rootIndex()) new_path = self.model.filePath(index) absolute_path = os.path.join(path, new_path) file_info = QFileInfo(absolute_path) if file_info.isDir(): self.model.setRootPath(absolute_path) self.setRootIndex(self.model.index(absolute_path)) self.rootChanged.emit(absolute_path) @pyqtSlot() def newFile(self): path = self.model.filePath(self.rootIndex()) new_file = QFile(os.path.join(path, "New File")) new_file.open(QIODevice.ReadWrite) @pyqtSlot() def deleteFile(self): index = self.selectionModel().currentIndex() path = self.model.filePath(index) if path: fileInfo = QFileInfo(path) if fileInfo.isFile(): if not self.ask_dialog( "Do you wan't to delete the selected file?"): return file = QFile(path) file.remove() elif fileInfo.isDir(): if not self.ask_dialog( "Do you wan't to delete the selected directory?"): return directory = QDir(path) directory.removeRecursively() @pyqtSlot() def createDirectory(self): path = self.model.filePath(self.rootIndex()) directory = QDir() directory.setPath(path) directory.mkpath("New Folder") @pyqtSlot(str) def setRootPath(self, root_path): self.rootChanged.emit(root_path) self.model.setRootPath(root_path) self.setRootIndex(self.model.index(root_path)) return True @pyqtSlot() def goUP(self): path = self.model.filePath(self.rootIndex()) file_info = QFileInfo(path) directory = file_info.dir() new_path = directory.absolutePath() currentRoot = self.rootIndex() self.model.setRootPath(new_path) self.setRootIndex(currentRoot.parent()) self.rootChanged.emit(new_path) @pyqtSlot() def doFileTransfer(self): index = self.selectionModel().currentIndex() path = self.model.filePath(index) self.transferFileRequest.emit(path) @pyqtSlot(str) def transferFile(self, src_path): dest_path = self.model.filePath(self.rootIndex()) src_file = QFile() src_file.setFileName(src_path) src_file_info = QFileInfo(src_path) dst_path = os.path.join(dest_path, src_file_info.fileName()) src_file.copy(dst_path) @pyqtSlot() def getSelected(self): return self.selected_row @pyqtSlot() def getCurrentDirectory(self): return self.model.rootPath() @pyqtProperty(TableType) def tableType(self): return self._table_type @tableType.setter def tableType(self, table_type): self._table_type = table_type if table_type == TableType.Local: self.setRootPath(self._nc_file_dir) else: self.setRootPath('/media/') def ask_dialog(self, message): box = QMessageBox.question(self.parent, 'Are you sure?', message, QMessageBox.Yes, QMessageBox.No) if box == QMessageBox.Yes: return True else: return False
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with This program. If not, see <http://www.gnu.org/licenses/>. import os # For file path manipulation import linuxcnc # For commanding linuxcnc from QtPyVCP.lib.notify import Notification, Urgency, init from PyQt5 import uic, QtWidgets from QtPyVCP.utilities.info import Info PARENT_DIR = os.path.dirname(os.path.realpath(__file__)) INFO = Info() # Change this path to match [RS274NGC] SUBROUTINE_PATH given in the INI SUBROUTINE_PATH = INFO.getSubroutinePath() CMD = linuxcnc.command() STAT = linuxcnc.stat() class SubCaller(QtWidgets.QWidget): def __init__(self, parent=None): super(SubCaller, self).__init__(parent) # This prevents doing unneeded initialization # when QtDesginer loads the plugin. if parent is None: