[PyQt] Overcoming slow startup
Thorsten Kampe
thorsten at thorstenkampe.de
Sun Apr 11 21:27:04 BST 2010
Hi,
I wrote a simple application that displays output of an external CLI
tool in a QTreeWidget. In a normal setup, the external tool will take
less than one minute to terminate. Unfortunately - depending on the
setup of the external application - the external tool may also take
between thirty and sixty seconds to terminate - during which my
application seems to "do nothing" and is not even visible. So the user
may simply think that my appliatopm crashed.
One option I have would be to display a splash screen ("Please wait -
gathering data...") or a progress dialog. My optimum solution would be
that the application's main window appears after creating the top level
QTreeWidgetItem and refreshes after each QTreeWidgetItem() - and not
after the whole tree is populated.
Is this possible and if so, how?
Thorsten
###
treeWidget = QTreeWidget()
self.setCentralWidget(treeWidget)
toplevel_item = QTreeWidgetItem(treeWidget, ['[Scopes]'])
process = QProcess()
process.start('slptool', ['findscopes'])
process.waitForFinished()
for scope in str(process.readAllStandardOutput()).splitlines():
scope_item = QTreeWidgetItem(toplevel_item, [scope])
process.start('slptool', ['-s', scope, 'findsrvtypes'])
process.waitForFinished()
for srvtype in str(process.readAllStandardOutput()).splitlines():
srvtype_item = QTreeWidgetItem(scope_item, [srvtype])
process.start('slptool', ['-s', scope, 'findsrvs', srvtype])
process.waitForFinished()
for srvs in str(process.readAllStandardOutput()).splitlines():
srvs = srvs.split(',')[0]
###
More information about the PyQt
mailing list