diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index 3ddc820..8123e61 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -7,6 +7,7 @@ from wx.lib import buttons from gui import icon from gui import toolbarUtil from gui import webcam +from gui import taskbar from util import machineCom from util import profile from util import gcodeInterpreter @@ -367,6 +368,7 @@ class printWindow(wx.Frame): else: status += 'Print time left: %02d:%02d\n' % (int(printTimeLeft / 60), int(printTimeLeft % 60)) self.progress.SetValue(self.machineCom.getPrintPos()) + taskbar.setProgress(self, self.machineCom.getPrintPos(), len(self.gcodeList)) if self.machineCom != None: if self.machineCom.getTemp() > 0: status += 'Temp: %d\n' % (self.machineCom.getTemp()) @@ -384,6 +386,7 @@ class printWindow(wx.Frame): self.machineCom.close() self.machineCom = machineCom.MachineCom(callbackObject=self) self.UpdateButtonStates() + taskbar.setBusy(self, True) def OnLoad(self, e): pass @@ -525,8 +528,15 @@ class printWindow(wx.Frame): wx.CallAfter(self.bedTemperatureSelect.SetValue, bedTargetTemp) def mcStateChange(self, state): - if self.machineCom != None and state == self.machineCom.STATE_OPERATIONAL and self.cam != None: - self.cam.endTimelaps() + if self.machineCom != None: + if state == self.machineCom.STATE_OPERATIONAL and self.cam != None: + self.cam.endTimelaps() + if state == self.machineCom.STATE_OPERATIONAL: + taskbar.setBusy(self, False) + if self.machineCom.isClosedOrError(): + taskbar.setBusy(self, False) + if self.machineCom.isPaused(): + taskbar.setPause(self, True) wx.CallAfter(self.UpdateButtonStates) wx.CallAfter(self.UpdateProgress) diff --git a/Cura/gui/taskbar.py b/Cura/gui/taskbar.py new file mode 100644 index 0000000..f22e721 --- /dev/null +++ b/Cura/gui/taskbar.py @@ -0,0 +1,40 @@ +try: + import comtypes.client as cc + cc.GetModule('taskbarlib.tlb') + import comtypes.gen.TaskbarLib as tbl + + ITaskbarList3 = cc.CreateObject("{56FDF344-FD6D-11d0-958A-006097C9A090}", interface=tbl.ITaskbarList3) + ITaskbarList3.HrInit() + + #Stops displaying progress and returns the button to its normal state. Call this method with this flag to dismiss the progress bar when the operation is complete or canceled. + TBPF_NOPROGRESS = 0x00000000 + #The progress indicator does not grow in size, but cycles repeatedly along the length of the taskbar button. This indicates activity without specifying what proportion of the progress is complete. Progress is taking place, but there is no prediction as to how long the operation will take. + TBPF_INDETERMINATE = 0x00000001 + #The progress indicator grows in size from left to right in proportion to the estimated amount of the operation completed. This is a determinate progress indicator; a prediction is being made as to the duration of the operation. + TBPF_NORMAL = 0x00000002 + #The progress indicator turns red to show that an error has occurred in one of the windows that is broadcasting progress. This is a determinate state. If the progress indicator is in the indeterminate state, it switches to a red determinate display of a generic percentage not indicative of actual progress. + TBPF_ERROR = 0x00000004 + #The progress indicator turns yellow to show that progress is currently stopped in one of the windows but can be resumed by the user. No error condition exists and nothing is preventing the progress from continuing. This is a determinate state. If the progress indicator is in the indeterminate state, it switches to a yellow determinate display of a generic percentage not indicative of actual progress. + TBPF_PAUSED = 0x00000008 +except: + #The taskbar API is only available for Windows7, on lower windows versions, linux or Mac it will cause an exception. Ignore the exception and don't use the API + ITaskbarList3 = None + +def setBusy(frame, busy): + if ITaskbarList3 != None: + if busy: + ITaskbarList3.SetProgressState(frame.GetHandle(), TBPF_INDETERMINATE) + else: + ITaskbarList3.SetProgressState(frame.GetHandle(), TBPF_NOPROGRESS) + +def setPause(frame, pause): + if ITaskbarList3 != None: + if pause: + ITaskbarList3.SetProgressState(frame.GetHandle(), TBPF_PAUSED) + else: + ITaskbarList3.SetProgressState(frame.GetHandle(), TBPF_NORMAL) + +def setProgress(frame, done, total): + if ITaskbarList3 != None: + ITaskbarList3.SetProgressState(frame.GetHandle(), TBPF_NORMAL) + ITaskbarList3.SetProgressValue(frame.GetHandle(), done, total) diff --git a/Cura/gui/taskbarlib.tlb b/Cura/gui/taskbarlib.tlb new file mode 100644 index 0000000..93eb0ae Binary files /dev/null and b/Cura/gui/taskbarlib.tlb differ diff --git a/Cura/util/machineCom.py b/Cura/util/machineCom.py index c32e39c..1dec1a1 100644 --- a/Cura/util/machineCom.py +++ b/Cura/util/machineCom.py @@ -408,7 +408,10 @@ class MachineCom(object): except: #If the log queue is full, remove the first message and append the new message again self._logQueue.get() - self._logQueue.put(message, False) + try: + self._logQueue.put(message, False) + except: + pass def _readline(self): if self._serial == None: diff --git a/package.sh b/package.sh index 16f2df6..29dc458 100755 --- a/package.sh +++ b/package.sh @@ -96,6 +96,7 @@ if [ $BUILD_TARGET = "win32" ]; then downloadURL http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/numpy-1.6.2-win32-superpack-python2.7.exe downloadURL http://videocapture.sourceforge.net/VideoCapture-0.9-5.zip downloadURL http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20120927-git-13f0cd6-win32-static.7z + downloadURL http://sourceforge.net/projects/comtypes/files/comtypes/0.6.2/comtypes-0.6.2.win32.exe #Get pypy downloadURL https://bitbucket.org/pypy/pypy/downloads/pypy-${PYPY_VERSION}-win32.zip else @@ -130,6 +131,7 @@ if [ $BUILD_TARGET = "win32" ]; then extract VideoCapture-0.9-5.zip VideoCapture-0.9-5/Python27/DLLs/vidcap.pyd extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/licenses + extract comtypes-0.6.2.win32.exe mkdir -p ${TARGET_DIR}/python mkdir -p ${TARGET_DIR}/Cura/ @@ -137,6 +139,7 @@ if [ $BUILD_TARGET = "win32" ]; then mv \$_OUTDIR/Lib/site-packages/wx* ${TARGET_DIR}/python/Lib/site-packages/ mv PURELIB/serial ${TARGET_DIR}/python/Lib mv PURELIB/OpenGL ${TARGET_DIR}/python/Lib + mv PURELIB/comtypes ${TARGET_DIR}/python/Lib mv PLATLIB/numpy ${TARGET_DIR}/python/Lib mv VideoCapture-0.9-5/Python27/DLLs/vidcap.pyd ${TARGET_DIR}/python/DLLs mv ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe ${TARGET_DIR}/Cura/