Advertisement
Guest User

jdm

a guest
Nov 16th, 2009
1,882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. from PyQt4 import QtCore, QtGui
  2. from PyQt4.QtCore import SIGNAL
  3.  
  4. TBPF_NOPROGRESS = 0
  5. TBPF_INDETERMINATE = 0x1
  6. TBPF_NORMAL = 0x2
  7. TBPF_ERROR = 0x4
  8. TBPF_PAUSED = 0x8
  9.  
  10. class MyMainWindow(QtGui.QMainWindow):
  11.     def __init__(self, parent=None):
  12.         QtGui.QMainWindow.__init__(self, parent)
  13.         self.setWindowTitle("Windows 7 Taskbar Test")
  14.  
  15.         self.progressbar = QtGui.QProgressBar(self)
  16.         self.setCentralWidget(self.progressbar)
  17.         self.progressbar.setRange(0,100)
  18.         self.timer = QtCore.QTimer(self)
  19.         self.timer.setInterval(100)
  20.         self.connect(self.timer, SIGNAL("timeout()"), self.timer_timeout)
  21.         self.progress = 0
  22.         self.timer.start()
  23.  
  24.     def timer_timeout(self):
  25.         import comtypes.client as cc
  26.         cc.GetModule("TaskbarLib.tlb")
  27.         import comtypes.gen.TaskbarLib as tbl
  28.         taskbar = cc.CreateObject(
  29.             "{56FDF344-FD6D-11d0-958A-006097C9A090}",
  30.             interface=tbl.ITaskbarList3)
  31.         taskbar.HrInit()
  32.         hWnd = self.winId()
  33.         self.progress += 2
  34.         if self.progress > 100:
  35.             self.progress = 0
  36.         self.progressbar.setValue(self.progress)
  37.         taskbar.SetProgressValue(hWnd,self.progress,100)
  38.         taskbar.SetProgressState(hWnd, TBPF_NORMAL)
  39.  
  40. if __name__ == "__main__":
  41.     import sys
  42.     app = QtGui.QApplication(sys.argv)
  43.     ui = MyMainWindow()
  44.     ui.show()
  45.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement