Skip to content

Instantly share code, notes, and snippets.

@kaotika
Last active November 12, 2022 10:10
Show Gist options
  • Save kaotika/e8ca5c340ec94f599fb2 to your computer and use it in GitHub Desktop.
Save kaotika/e8ca5c340ec94f599fb2 to your computer and use it in GitHub Desktop.

Revisions

  1. kaotika revised this gist Feb 23, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions qprogressbar_thread.py
    Original file line number Diff line number Diff line change
    @@ -26,10 +26,13 @@ def __init__(self, parent=None):
    super(progress, self).__init__(parent)
    # Set up the user interface from Designer.
    self.setValue(0)

    self.thread = mythread(self, 3)

    self.thread.total.connect(self.setMaximum)
    self.thread.update.connect(self.update)
    self.thread.finished.connect(self.close)

    self.n = 0
    self.thread.start()

  2. kaotika revised this gist Feb 23, 2015. 1 changed file with 3 additions and 8 deletions.
    11 changes: 3 additions & 8 deletions qprogressbar_thread.py
    Original file line number Diff line number Diff line change
    @@ -6,24 +6,19 @@ class mythread(QtCore.QThread):
    total = QtCore.pyqtSignal(object)
    update = QtCore.pyqtSignal()

    def __init__(self,parent,n):
    QtCore.QThread.__init__(self,parent)
    def __init__(self, parent, n):
    super(mythread, self).__init__(parent)
    self.n = n

    def run(self):
    self.total.emit(self.n)
    i=0
    i = 0
    while (i<self.n):
    if (time.time() % 1==0):
    i+=1
    #print str(i)
    self.update.emit()

    class Ui_Dialog(QtGui.QProgressBar):

    def __init__(self, parent=None):
    super(Ui_Dialog, self).__init__(parent)

    # create the dialog for zoom to point
    class progress(QtGui.QProgressBar):

  3. kaotika created this gist Feb 23, 2015.
    51 changes: 51 additions & 0 deletions qprogressbar_thread.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    from PyQt4 import QtCore, QtGui
    import sys, time

    class mythread(QtCore.QThread):

    total = QtCore.pyqtSignal(object)
    update = QtCore.pyqtSignal()

    def __init__(self,parent,n):
    QtCore.QThread.__init__(self,parent)
    self.n = n

    def run(self):
    self.total.emit(self.n)
    i=0
    while (i<self.n):
    if (time.time() % 1==0):
    i+=1
    #print str(i)
    self.update.emit()

    class Ui_Dialog(QtGui.QProgressBar):

    def __init__(self, parent=None):
    super(Ui_Dialog, self).__init__(parent)

    # create the dialog for zoom to point
    class progress(QtGui.QProgressBar):

    def __init__(self, parent=None):
    super(progress, self).__init__(parent)
    # Set up the user interface from Designer.
    self.setValue(0)
    self.thread = mythread(self, 3)

    self.thread.total.connect(self.setMaximum)
    self.thread.update.connect(self.update)
    self.n = 0
    self.thread.start()

    def update(self):
    self.n += 1
    print self.n
    self.setValue(self.n)

    if __name__=="__main__":
    app = QtGui.QApplication([])
    progressWidget = progress()
    progressWidget.move(300, 300)
    progressWidget.show()
    sys.exit(app.exec_())