瀏覽代碼

Added pause/resume and cancel buttons.

Thomas Buck 3 年之前
父節點
當前提交
64c7ff69c8
共有 1 個檔案被更改,包括 31 行新增0 行删除
  1. 31
    0
      src/octotray.py

+ 31
- 0
src/octotray.py 查看文件

@@ -393,9 +393,26 @@ class CamWindow(QWidget):
393 393
         self.ZMButton.clicked.connect(self.moveZM)
394 394
         controls_move.addWidget(self.ZMButton)
395 395
 
396
+        controls_job = QHBoxLayout()
397
+        box.addLayout(controls_job, 0)
398
+
399
+        self.PauseButton = QPushButton("Pause/Resume")
400
+        self.PauseButton.clicked.connect(self.pauseResume)
401
+        controls_job.addWidget(self.PauseButton)
402
+
403
+        self.CancelButton = QPushButton("Cancel Job")
404
+        self.CancelButton.clicked.connect(self.cancelJob)
405
+        controls_job.addWidget(self.CancelButton)
406
+
396 407
         self.loadImage()
397 408
         self.loadStatus()
398 409
 
410
+    def pauseResume(self):
411
+        self.parent.printerPauseResume(self.printer)
412
+
413
+    def cancelJob(self):
414
+        self.parent.printerJobCancel(self.printer)
415
+
399 416
     def moveXP(self):
400 417
         self.parent.printerMoveAction(self.printer, "x", int(self.parent.jogMoveLength), True)
401 418
 
@@ -1041,6 +1058,20 @@ class OctoTray():
1041 1058
 
1042 1059
         self.sendPostRequest(printer[0], printer[1], "printer/printhead", '{ "command": "jog", "' + str(axis) + '": ' + str(dist) + ', "speed": ' + str(self.jogMoveSpeed) + absolute + ' }')
1043 1060
 
1061
+    def printerPauseResume(self, printer):
1062
+        state = self.getState(printer[0], printer[1])
1063
+        if state in self.statesWithWarning:
1064
+            if self.showDialog("OctoTray Warning", "The printer seems to be running currently!", "Do you really want to pause/resume?", True, True) == False:
1065
+                return
1066
+        self.sendPostRequest(printer[0], printer[1], "job", '{ "command": "pause", "action": "toggle" }')
1067
+
1068
+    def printerJobCancel(self, printer):
1069
+        state = self.getState(printer[0], printer[1])
1070
+        if state in self.statesWithWarning:
1071
+            if self.showDialog("OctoTray Warning", "The printer seems to be running currently!", "Do you really want to cancel?", True, True) == False:
1072
+                return
1073
+        self.sendPostRequest(printer[0], printer[1], "job", '{ "command": "cancel" }')
1074
+
1044 1075
     def printerWebAction(self, item):
1045 1076
         self.openBrowser(item[0])
1046 1077
 

Loading…
取消
儲存