How to change the format of the Column and CellText of a table

I would like to change the format of the font (bold, size, family, etc) for both the title and the CellText of a TableNode. I would also like to fix the width of the Table (something like Column width). Using the lines below, I can define the text for the column and the rows. However, I haven’t been able to figure out how to adjust the format. Any suggestions?

slicer.vtkMRMLTableNode().AddColumn().SetName(“column text”)
slicer.vtkMRMLTableNode().SetCellText(0,0,“row text”)

Table nodes can store name, type, and additional metadata (description, unit, null value, any other custom field).

Table widget (slicer.qMRMLTableWidget) currently does not support any formatting, such as font type or size, but since you can store arbitrary column metadata, this would not be very hard to implement.

For cell-level custom formatting, probably the best approach would be to introduce a new html or markdown data type, which would be rendered using QTextDocument (see 1 or 2 for examples).

If you decide to work on implementing any of these then we can help you getting started and reviewing and integrating the end result. If you want to rich table display without any Slicer core development, then you can simple create a table in html and display it using slicer.qSlicerWebWidget.

1 Like

Thanks, Andras. I will look into these examples in more detail and get back if I need any help.

1 Like