chiark / gitweb /
Added Windows 7 progress in taskbar support.
authordaid303 <daid303@gmail.com>
Wed, 10 Oct 2012 10:23:53 +0000 (12:23 +0200)
committerdaid303 <daid303@gmail.com>
Wed, 10 Oct 2012 10:23:53 +0000 (12:23 +0200)
Cura/gui/printWindow.py
Cura/gui/taskbar.py [new file with mode: 0644]
Cura/gui/taskbarlib.tlb [new file with mode: 0644]
Cura/util/machineCom.py
package.sh

index 3ddc820c8f94f6712ea444d3e7853ac86227c382..8123e611b51296ffb7cb2b5c11a2196b65849aa6 100644 (file)
@@ -7,6 +7,7 @@ from wx.lib import buttons
 from gui import icon\r
 from gui import toolbarUtil\r
 from gui import webcam\r
+from gui import taskbar\r
 from util import machineCom\r
 from util import profile\r
 from util import gcodeInterpreter\r
@@ -367,6 +368,7 @@ class printWindow(wx.Frame):
                        else:\r
                                status += 'Print time left: %02d:%02d\n' % (int(printTimeLeft / 60), int(printTimeLeft % 60))\r
                        self.progress.SetValue(self.machineCom.getPrintPos())\r
+                       taskbar.setProgress(self, self.machineCom.getPrintPos(), len(self.gcodeList))\r
                if self.machineCom != None:\r
                        if self.machineCom.getTemp() > 0:\r
                                status += 'Temp: %d\n' % (self.machineCom.getTemp())\r
@@ -384,6 +386,7 @@ class printWindow(wx.Frame):
                        self.machineCom.close()\r
                self.machineCom = machineCom.MachineCom(callbackObject=self)\r
                self.UpdateButtonStates()\r
+               taskbar.setBusy(self, True)\r
        \r
        def OnLoad(self, e):\r
                pass\r
@@ -525,8 +528,15 @@ class printWindow(wx.Frame):
                        wx.CallAfter(self.bedTemperatureSelect.SetValue, bedTargetTemp)\r
        \r
        def mcStateChange(self, state):\r
-               if self.machineCom != None and state == self.machineCom.STATE_OPERATIONAL and self.cam != None:\r
-                       self.cam.endTimelaps()\r
+               if self.machineCom != None:\r
+                       if state == self.machineCom.STATE_OPERATIONAL and self.cam != None:\r
+                               self.cam.endTimelaps()\r
+                       if state == self.machineCom.STATE_OPERATIONAL:\r
+                               taskbar.setBusy(self, False)\r
+                       if self.machineCom.isClosedOrError():\r
+                               taskbar.setBusy(self, False)\r
+                       if self.machineCom.isPaused():\r
+                               taskbar.setPause(self, True)\r
                wx.CallAfter(self.UpdateButtonStates)\r
                wx.CallAfter(self.UpdateProgress)\r
        \r
diff --git a/Cura/gui/taskbar.py b/Cura/gui/taskbar.py
new file mode 100644 (file)
index 0000000..f22e721
--- /dev/null
@@ -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 (file)
index 0000000..93eb0ae
Binary files /dev/null and b/Cura/gui/taskbarlib.tlb differ
index c32e39c37a93489266ec8c2963e2521c21533fff..1dec1a132100c4c9340572a3457037f4bdd41f7f 100644 (file)
@@ -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:
index 16f2df64c0b97415353148e38e82bed1b2d3e084..29dc4581a0fb34f9adcc3bf76f872763dbac7090 100755 (executable)
@@ -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/