tags:

views:

91

answers:

1

I'd like to add some TeX text to my Qt form, like label - just text, no graph, no lines, no borders, just TeX. I thought something like this: render TeX to bitmap and then place that bitmap on form, e.g. into QLabel. Or even better - use some backend, add it to form and use something tex_label.print_tex(<tex code>). Seems matplotplot has TeX parsers, but I can't figure out how to use them...

Thanks.

A: 

As a variant:

    # Get window background color
    bg = self.palette().window().color()
    cl = (bg.redF(), bg.greenF(), bg.blueF())

    # Create figure, using window bg color
    self.fig = Figure(edgecolor=cl, facecolor=cl)

    # Add FigureCanvasQTAgg widget to form
    self.canvas = FigureCanvasQTAgg(self.fig)        
    self.tex_label_placeholder.layout().addWidget(self.canvas)

    # Clear figure
    self.fig.clear()

    # Set figure title
    self.fig.suptitle('$TeX$',
                      x=0.0, y=0.5, 
                      horizontalalignment='left',
                      verticalalignment='center')
    self.canvas.draw()
race1