Best way to show interactive table with python (columns adjustably by user) Best way to show interactive table with python (columns adjustably by user) pandas pandas

Best way to show interactive table with python (columns adjustably by user)


Using a table widget as described at pythonspot above, requires individually adding each row of data, via the creation and insertion of individual QTableWidgetItems. eg

  self.tableWidget.setItem(0, 0, QTableWidgetItem("Cell (1,1)"))

This may be sufficient in some cases but it doesnt generalize so well.

PandasTableView is a more MVC orientated approach that instead uses a a QTableView and an associated Model (QAbstractTableModel) class (to supply the data at runtime eg after reading a cvs file). Its mentioned atstackoverflow and the complete code can be found at github

Though requiring more code and being somewhat more difficult to understand, its the most flexible, and pretty much what I as looking for. Not least of all because it shows how to incoroporate data from a pandas dataframe.

There are various solutions (eg QGrid) that only work exclusively in Jupyter notebooks (presumably behind the scenes they make use of html tables etc, which is why they require the browser/notebook environment).


You can use plotly or if you are interested in more interactivity, go for Dash DataTable:

The DataTable is interactive. This chapter demonstrates the interactive features of the table and how to wire up these interations to Python callbacks. These actions include:

  • Paging
  • Selecting Rows
  • Sorting Columns
  • Filtering Data