Code: Alles auswählen
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>147</x>
<y>190</y>
<width>491</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>150</x>
<y>130</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
unbekannten Gründen ab. Wenn ich die for Schleifen auf 100*100 und
bar.setMaximum(100*100), dann funktioniert es. Was genau passiert da und
was mache ich falsch? Mein Code:
Code: Alles auswählen
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.uic import *
import sys
import numpy as np
import time
def main():
application = QApplication(sys.argv)
frame=loadUi('progress_bar.ui')
bar=frame.progressBar
bar.setMinimum(0)
bar.setMaximum(1000*1000)
def start():
z=0
i=0
for xi in range(0,1000):
for yi in range(0,1000):
i+=1
bar.setValue(i)
z=xi+yi #some random processing task
print 'done'
frame.pushButton.clicked.connect(start)
frame.show()
sys.exit(application.exec_())
if __name__ == '__main__':
main()