Hello,
I have a Bokeh app that I have written that display the contents of a text file using a ColumnDataSource that contains the text placed in a TableColumn, placed in a DataTable, placed in a Panel, placed on a Tabs tab. The app displays a lot of information in different tabs that allows us to browse an in-house database. The text file contains lines that use spaces to form columns of information. There are several sections of the file that use different columns and it is not really appropriate to try to display each section in a separate tab. The file display is more for quick inspection. Other parts of the app allow specification of different files to view as well as plots, other data tables, and images so the text is not fixed, hence the use of the ColumnDataSource.
I am able to display the file contents but it seems that the TableColumn uses a variable width font that makes the contents very hard to read.
If I display the text on a Panel using a PreText widget, the text shows properly but there is no scrollbar to allow scrolling through the file which is typically several hundred lines long.
I tried using a StringFormatter to attempt to specify a font_family but that option is not valid. It seems the StringFormatter only allows font_style, text_align, and text_color to be specified.
In the “Styling Visual Attributes” section of the Bokeh User Guide, text properties are listed that allow selection of the text_font, text_font_size, etc. but these properties do not seem to apply to the TableColumn widget.
This file display is the ugliest part of my app and I’m trying to improve it’s appearance. Here is the code used to demonstrate this issue:
from bokeh.io import output_notebook, show
from bokeh.layouts import widgetbox, column, row
from bokeh.models import ColumnDataSource,TableColumn, DataTable
from bokeh.models.widgets import Paragraph, PreText, Panel, Tabs, StringFormatter
output_notebook()
textfile = ‘MOD_Report.log’
with open(textfile,‘rt’) as f:
text = f.read()
w=900
qtext = ["%s" % t for t in text.split(’\n’)]
p=PreText(text=text,width=w,height=1000)
tab1=Panel(child=p,title=“PreText”)
cds = ColumnDataSource({‘contents’:qtext})
fmt = StringFormatter(text_color=‘red’); #font_style=“bold”,text_font=‘times’)
tc = TableColumn(field=‘contents’,formatter=fmt,title=‘CDS text’,width=w)
tab2 = Panel(child=DataTable(source=cds,columns=[tc],editable=False,width=w,height=800),title=‘CDS Text’)
tabs = Tabs(tabs=[tab1,tab2])
show(tabs)
Thanks in advance for any suggestions as to a solution, either to add scrollbars to the PreText Panel or change the font in the TableColumn.
Larry Byars