How to increase Font Size a tableWidget?

2,551 views
Skip to first unread message

Jean Francois Leon

unread,
Jan 10, 2016, 12:56:01 PM1/10/16
to pyqtgraph
Hello
we have written a pyqtgraph gui that monitor one of our experiment.
It display  several realtime curves  and also number values( the  last acquired data points for each data channel ).
They are assembled in a TableWidget.

It works as it should but we stumbled on a practical issue: 
The font size  too small to read  if you stand a few feet away from the screens.

It will be very helpful for the experimenters  to display this table widget in large bold font, possibly  of various colors.

Looking at Pyqtgraph documentation and examples we could not find any obvious way to do this. ( did we miss something?)

is it possible?  ( we are not QT Ninjas just experimental physicist...) 

Could then someone be kind enough to post a small example?

Thanks a lot

JF

vas...@gmail.com

unread,
Jan 10, 2016, 9:11:27 PM1/10/16
to pyqt...@googlegroups.com
Type of a font that widget use could be generally changed with something like:
w = pg.TableWidget()
w.setFont(QtGui.QFont('Arial', 20))




--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/abb0e6e0-cfd0-4060-89f2-c3d47b8664f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vas...@gmail.com

unread,
Jan 10, 2016, 10:10:38 PM1/10/16
to pyqt...@googlegroups.com
About the color I hope that there is a simpler solution, but it looks (to me) like you can't change that type of color directly in the widget.
The next example is not a "native" pyqtgraph code, but could be use as an idea for changing colors in table that depends of results:
http://stackoverflow.com/questions/15622053/pyqt-change-rowcell-collor-in-tableview

P.S. I'd very like to someone show me I'm wrong.

Jean Francois Leon

unread,
Jan 11, 2016, 3:32:21 AM1/11/16
to pyqtgraph

Thanks!!!
the font size change work perfectly.
as for the color I will check what you suggest if nothing else simpler is suggested 
JF

Jean Francois Leon

unread,
Jan 24, 2016, 3:42:44 AM1/24/16
to pyqtgraph
Hello,
I would like to follow up on my previous question that was properly answered by Vasilije by another one:
When we increase the font size in a pyqtgraph table widget, the row height does not scale up automatically and large font cannot be used accordingly.

Does somebody knows how to either
- automatically adjust the height of the rows based on their content? 
-manually define the height of the rows of a tablewidget?

Both can be done in Qt but we dont understand how to use them in Pyqtgraph widget

Thanks a lot
JF

Vincent Le Saux

unread,
Jan 24, 2016, 1:40:07 PM1/24/16
to pyqtgraph
Hi Jean-François,

Since TableWidget inherits from QtGui.QTableWidget, you should be able to adjust the height of the rows using the resizeRowsToContents() method.

To specify a particular height of a row, you can use the setRowHeight() method.

Vincent

Jean Francois Leon

unread,
Jan 24, 2016, 2:19:48 PM1/24/16
to pyqtgraph
Hi Vincent
Thank you for your answer.

In fact we tried the following:

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore

w=pg.TableWidget(sortable=False)
w.setFont(QtGui.QFont('Helvetica', 50))
w.resizeRowsToContents()

..and nothing happens ( the rows height dont scale up...)
we are not sure what we are doing wrong....

Can you point what we are doing wrong in the example above?
Thanks again
JF

Vincent Le Saux

unread,
Jan 25, 2016, 2:16:09 AM1/25/16
to pyqtgraph
Hi JF,

I'll try to find some time this morning to figure it out what's wrong with your code.

Vincent

Vincent Le Saux

unread,
Jan 26, 2016, 12:19:39 AM1/26/16
to pyqtgraph
JF,

Can you give a complete minimal example highlighting your problem?

Vincent

Jean Francois Leon

unread,
Jan 26, 2016, 2:22:44 AM1/26/16
to pyqtgraph
Hello Vincent
The code below should run and show the problem ( it does on my computer)
Thanks for your interest in the matter
JF

import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore

QtGui.QApplication.setGraphicsSystem('raster')
app = QtGui.QApplication([])

pg.setConfigOptions(antialias=True)
T1= pg.TableWidget(sortable=False)
T1.setFont(QtGui.QFont('Helvetica', 50))
T1.resizeRowsToContents()
T1.show()
T1.resize(1000,300)
T1.setWindowTitle('test')


def update():
    data = np.array([
    ('Temps   ',0.,'   ','  '),
    ('TC1 Cu   ', 3.14,   'degC   ',12.75,'degC/min'),
    ])
    T1.setData(data)

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(1000)

if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()

Vincent Le Saux

unread,
Jan 26, 2016, 2:13:33 PM1/26/16
to pyqtgraph
Hi JF,

I tried your code on my machine (running Archlinux, pyqt5 and python 3.5). I also have the same problem. I solved it by changing your update function according to:


def update():
    data = np.array([
    ('Temps   ',0.,'   ','  '),
    ('TC1 Cu   ', 3.14,   'degC   ',12.75,'degC/min'),
    ])
    T1.setData(data)
    T1.resizeRowsToContents() # NEEDED EVERY TIME THE CONTENTS IS ENTIRELY CHANGED!!!

Apparently, you have to resize the TableWidget everytime the contents change. The explanation is that the setData of TableWidget first start to clear its content and I guess, the initial visualization parameters (width and height of each cells) are restored.

This approach could be problematic if you want to display many informations at high frequency. If the number of values to display is quite limited, it should be ok.

Vincent

Jean Francois Leon

unread,
Jan 26, 2016, 4:21:59 PM1/26/16
to pyqtgraph
Thanks Vincent

We would have never though of it even if In retrospect it make perfect sense.
It is perfectly acceptable for our application.
Jf

Vincent Le Saux

unread,
Jan 27, 2016, 12:17:46 AM1/27/16
to pyqtgraph
Glad it help!

Vincent
Reply all
Reply to author
Forward
0 new messages