0

I want to build an app, using PySide, that creates a chart with the pyplot library.

I have one button:

qbutton1 = QtGui.QPushButton("Open File")

If the button is clicked, a CSV file is loaded with this function:

def openFile (self):

    path, _ = QtGui.QFileDialog.getOpenFileName(self,'Open file','','CSV(*.csv)')

    self.loadCsv(path);
    self.fileName=path

   #self.textlink.setText(str(path)) # this code have trouble , because when i clicked my button it talk that it not attribute in class.

I have a CSV file with 2 columns:

1,4 3,5 4,9

I'd want this chart to be drawn on a QtextEdit like the following:

textbox= QtGui.QTextEdit()
Ethaan
  • 11,291
  • 5
  • 35
  • 45
Huỳnh Tú
  • 115
  • 1
  • 7

1 Answers1

0

QTextEdit is made for editable text blocks, not for plotting graphs.

matplotlib provides custom Qt widgets to embed plots in a PyQt/PySide app. You can have a look at this similar question for more info on embedding matplolib in PyQt, or have a look at this example, taken from the matplotlib documentation.

Community
  • 1
  • 1
halflings
  • 1,540
  • 1
  • 13
  • 34
  • layout = QtGui.QVBoxLayout() t you're referring to this QT Widget? – Huỳnh Tú Apr 19 '15 at 09:08
  • No, `FigureCanvasQtAgg` (imported like this: `from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas`) is the one rendering the plot. Maybe you can copy the example given in that question and use it as a base. Don't forget to mark this answer if it solves your problem! – halflings Apr 19 '15 at 17:37