From f6b472cc3b76c3efb85a3eea5478e9a15b57a439 Mon Sep 17 00:00:00 2001 From: daid303 Date: Wed, 10 Oct 2012 12:23:53 +0200 Subject: [PATCH] Added Windows 7 progress in taskbar support. --- Cura/gui/printWindow.py | 14 ++++++++++++-- Cura/gui/taskbar.py | 40 ++++++++++++++++++++++++++++++++++++++++ Cura/gui/taskbarlib.tlb | Bin 0 -> 6832 bytes Cura/util/machineCom.py | 5 ++++- package.sh | 3 +++ 5 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 Cura/gui/taskbar.py create mode 100644 Cura/gui/taskbarlib.tlb 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 0000000000000000000000000000000000000000..93eb0ae0669eb831bbd3b4f37959956ebb16d747 GIT binary patch literal 6832 zcmb7IeQaCR6+cd#*!gI1n*`df47<&s5*@g00GDNxlQ?O-J6{(vTDllnfAnmJvFoq^HZBp1YQE9BJ#-RKC?t9mM zagvQ)>AZXIxxe#q&pr3Pci+gwV7yLT!qVhcmGq*rI3jImUqP`(L`KorTW|Hq-;Aao zR0cV5Y4p#7c0ti&p!Y#{)``3b@>cpB2F@ZpXyuXGG5hQO-(K`LeSr*-Q zwzt{&tN=D<$M!}!+o?I#^=PfKDy>s?>-0J{T*z?FgL}AMniQIT_yZn!Q70p~)iqz8 zz1r^%8>IVGrrWfk+nRrUz$?iu>{+F1LvyONmVNtw*cgY1&MnFW0!{1Kume&xQStBM zf3ZQ`+82tleM6vGo>_Aq>)Y_#$y2L~I@gMoKhPq}|EG;sd#OIIjXFGKHFfe;thevtx=0*KL~!`rO(X&;@z&^m-^=#@4orjiH~fc@sp)L9J%Ay z8^8CK$mOM;ceVV?I{frH{Jy_`cwphfUu``4h$NqU?IfqFd|}OUPCaEXjXDWB8vS(g z_8&dn_iS#tA-B_}Uj9d-ue59{J*XKjizH{78*{zPriiIAhMX zvn<0) zG2R23hy24fmS_BVPz3&J*=G6e(RiwK?{um-oS9A}I2Vq!hCch#Xl0;erft4Aboay2 z$=toU{8H|`&2xty{Kx*uXoTOBl)W)@>|aw;Bhkq4lwD=a*(uYqlFdv{1%ts``Pi)< z2`$&)3-6Ak%+&5g!ollRyge&;eTuht1+QQ6y1~=Fw#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