diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index f009a33178..cc9463baec 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -172,7 +172,7 @@ class PrinterOutputModel(QObject): def getController(self): return self._controller - @pyqtProperty(str, notify=nameChanged) + @pyqtProperty(str, notify = nameChanged) def name(self): return self._name diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 769820d6d0..b61a62adc0 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -273,14 +273,18 @@ class USBPrinterOutputDevice(PrinterOutputDevice): except SerialException: Logger.log("w", "An exception occured while trying to create serial connection") return - container_stack = CuraApplication.getInstance().getGlobalContainerStack() - num_extruders = container_stack.getProperty("machine_extruder_count", "value") - # Ensure that a printer is created. - self._printers = [PrinterOutputModel(output_controller=GenericOutputController(self), number_of_extruders=num_extruders)] - self._printers[0].updateName(container_stack.getName()) + CuraApplication.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged) + self._onGlobalContainerStackChanged() self.setConnectionState(ConnectionState.connected) self._update_thread.start() + def _onGlobalContainerStackChanged(self): + container_stack = CuraApplication.getInstance().getGlobalContainerStack() + num_extruders = container_stack.getProperty("machine_extruder_count", "value") + #Ensure that a printer is created. + self._printers = [PrinterOutputModel(output_controller = GenericOutputController(self), number_of_extruders = num_extruders)] + self._printers[0].updateName(container_stack.getName()) + def close(self): super().close() if self._serial is not None: