I'd like to be able to find all of the TextItems in a PlotWidget 
automatically.

I'm trying to write some resize code that will automatically change the 
font size of TextItems as my app's MainWindows resizes.

For my other widgets and for the PlotWidget, I use  findChildren  a lot :
    def resizeEvent(self, event):
        # figure out scale factor
        sfh = float(self.centralWidget().height())/float(self.centralWidget
().minimumHeight())
        sfw = float(self.centralWidget().width())/float(self.centralWidget
().minimumWidth())
        sf = min(sfh,sfw)
 
        font = QFont("Tahoma", 10.)  # Tahoma seems to work well on old XP 
boxes
        font.setPointSizeF(sf*10.)
        
        for widget in self.findChildren((QtWidgets.QLineEdit, QtWidgets.
QTextEdit
                                         QtWidgets.QLabel )):
            widget.setFont(font)

        for widget in self.findChildren((PlotWidget)):
            fs = int(10.*sf)
            labelStyle = {'font-size': str(fs) + 'pt'}
            widget.setLabel('left',   **labelStyle)
            widget.setLabel('bottom', **labelStyle)
            widget.getAxis("left").tickFont = font
            widget.getAxis("left").setStyle(tickTextOffset = fs)
            widget.getAxis("bottom").tickFont = font
            widget.getAxis("bottom").setStyle(tickTextOffset = fs)
            widget.getAxis("left").setWidth(fs*10)

However, I cannot figure out how to find TextItems, I tried adding  
pyqtgraph.TextItem  and  QtWidgets.QGraphicsTextItem  to my tuple of 
widgets in self.findChildren, but neither worked.

I also tried search in self.plotMain (my PlotWidget):
    for widget in self.plotMain.findChildren((pyqtgraph.TextItem, QtWidgets.
QGraphicsTextItem )):
            widget.setFont(font)
but that didn't work either. 

I also tried playing with listDataItems, but no joy.






-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/99174ed8-bdb2-4fde-9edc-792d1a70101f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to