[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Large Table Example in PyQt4
From:       Brian Kelley <kelley () eyesopen ! com>
Date:       2007-12-22 19:38:18
Message-ID: 72221588-0D32-4AF1-833D-DAEF9C07299E () eyesopen ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


You have two large culprits here:

tv.resizeColumnsToContents()

and

for row in xrange(nrows):
             tv.setRowHeight(row, 18)


Both can take a very long period of time.

resizeColumnsToContents is the worst offender as it has to scan every  
piece of data in your column, determine its size and populate the  
internal arrays.  It is better to have a heuristic for this and set  
the sizes yourself (look at horizontalHeader() for instance)

For row height, see the QTableView::sizeHintForRow()


On Dec 20, 2007, at 7:20 PM, B Clowers wrote:

> I am fairly new to python and programming as a whole and would like  
> to develop a small application capable of plotting simple 2D graphs  
> and also display such data in a table.  In my initial assessment of  
> PyQt4 I have been able to load my data into a table but it is  
> terribly slow.  I am using a QAbstractTableModel example that I  
> found on the web:
>
> http://iwiwdsmi.blogspot.com/2007/12/pyqt-43-qtableview-qabstracttable-model.html
>
> This has been useful but if I load a large numpy array (5 x 250,000)  
> into this example it is insanely slow.  It seems as though there was  
> a "bigtable.py" example for PyQt3 but I cannot seem to port this to  
> version 4.  The Qt website also discusses the use of large tables  
> when programming C++ but this is out of my league.  Does anyone have  
> a simple solution to this problem or perhaps a quick example that I  
> can insert a numpy array into?  Again, I'm pretty new to python but  
> am eager to learn.
>
> Cheers,
>
> Brian
>
> Never miss a thing. Make Yahoo your homepage.  
> _______________________________________________
> PyQt mailing list    PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

======
Brian Kelley
OpenEye Scientific Software Inc.
American Twine Office Park
222 3rd Street Suite 3120
Cambdridge, MA 02142
+1 617 374-8844
kelley@eyesopen.com



[Attachment #5 (text/html)]

<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; ">You have two large culprits here:<div><br \
class="webkit-block-placeholder"></div><div>tv.resizeColumnsToContents()</div><div><br \
class="webkit-block-placeholder"></div><div>and</div><div><br \
class="webkit-block-placeholder"></div><div><div>for row in \
xrange(nrows):</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;tv.setRowHeight(row, 18)</div><div><br \
class="webkit-block-placeholder"></div><div><br \
class="webkit-block-placeholder"></div><div>Both can take a very long period of \
time.</div><div><br class="webkit-block-placeholder"></div><div>resizeColumnsToContents \
is the worst offender as it has to scan every piece of data in your column, determine \
its size and populate the internal arrays. &nbsp;It is better to have a heuristic for \
this and set the sizes yourself (look at horizontalHeader() for \
instance)</div><div><br class="webkit-block-placeholder"></div><div>For row height, \
see the QTableView::sizeHintForRow()</div><div><br></div><div><br \
class="webkit-block-placeholder"></div><div><div>On Dec 20, 2007, at 7:20 PM, B \
Clowers wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I \
am fairly new to python and programming as a whole and would like to develop a small \
application capable of plotting simple 2D graphs and also display such data in a \
table.&nbsp; In my initial assessment of PyQt4 I have been able to load my data into \
a table but it is terribly slow.&nbsp; I am using a QAbstractTableModel example that \
I found on the web:<br><br><a \
href="http://iwiwdsmi.blogspot.com/2007/12/pyqt-43-qtableview-qabstracttable-model.htm \
l">http://iwiwdsmi.blogspot.com/2007/12/pyqt-43-qtableview-qabstracttable-model.html</a><br><br>This \
has been useful but if I load a large numpy array (5 x 250,000) into this example it \
is insanely slow.&nbsp; It seems as though there was a "bigtable.py" example for \
PyQt3 but I cannot seem to port this to version 4.&nbsp; The Qt website also \
discusses the use of large tables when programming C++ but this is out of my \
league.&nbsp; Does anyone have a simple solution to this problem or perhaps a quick \
example that I can insert a numpy array into?&nbsp; Again, I'm pretty new to python \
but am eager to learn.&nbsp; <br><br>Cheers,<br><br>Brian<br><div>        <br \
class="webkit-block-placeholder"></div><hr size="1">Never miss a thing.  <a \
href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your \
homepage.</a> _______________________________________________<br>PyQt mailing list \
&nbsp;&nbsp;&nbsp;PyQt@riverbankcomputing.com<br>http://www.riverbankcomputing.com/mailman/listinfo/pyqt</blockquote></div><br><div> \
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px \
0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: \
normal; font-variant: normal; font-weight: normal; letter-spacing: normal; \
line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; \
text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; \
white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: \
break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><div \
style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \
">======</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; \
margin-left: 0px; ">Brian Kelley</div><div style="margin-top: 0px; margin-right: 0px; \
margin-bottom: 0px; margin-left: 0px; ">OpenEye Scientific Software Inc.</div><div \
style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \
">American Twine Office Park</div><div style="margin-top: 0px; margin-right: 0px; \
margin-bottom: 0px; margin-left: 0px; ">222 3rd Street Suite 3120</div><div \
style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \
">Cambdridge, MA 02142</div><div style="margin-top: 0px; margin-right: 0px; \
margin-bottom: 0px; margin-left: 0px; ">+1 617 374-8844</div><div style="margin-top: \
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a \
href="mailto:kelley@eyesopen.com"><span class="Apple-style-span" style="color: rgb(0, \
0, 238); -khtml-text-decorations-in-effect: underline; \
">kelley@eyesopen.com</span></a></div></div><br \
class="Apple-interchange-newline"></span> </div><br></div></body></html>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic