Way to change font size for different lines in Cell?
techteej last edited by
Is there a way to change font size for the different lines in one UI.Tableview Cell? i.e, one line of text be like a header, and the second be a description
dgelessus last edited by
There's a built-in way of creating a cell with a "header" and a "description" row, maybe that will do what you want:
import ui cell = ui.TableViewCell("subtitle") # "subtitle" mode enables the secondary text label cell.text_label # ui.Label object for the main text cell.detail_text_label # ui.Label object for the subtitle text
techteej last edited by
That's probably what I want, but I'm not sure how to call it because I use
data_source.itemsto set everything
JonB last edited by JonB
you want to use the "list of dictionaries" approach for items, instead if a list of strings.
EDIT: ListDataSource does not currently allow setting of detail_text_label... just title, image, and accessory_type. Seems like that wiuld be a useful enhancement for those that don't want to roll their own data source.
@techteej, not sure if this helps. Not sure how you have set it up. This may give you some ideas.
# coding: utf-8 import ui def make_cell(data, celltype = None): # celltype can be None for default, subtitle, value1 or value2 cell = ui.TableViewCell(celltype) cell.text_label.text = data # if celltype is None/default, detail_text_label # does not exist. cell.detail_text_label.text = 'subtitle text' return cell # override this method def tableview_cell_for_row(self, tableview, section, row): return make_cell(self.data[row], 'subtitle')
Oh, for the data I am using a list of namedtruples. I don't think it really matters what you are using, as long as it's a list of something. truples, namedtruples, strings, class objects etc...
Phuket2 last edited by Phuket2
I am making up my cell like the pic below. Not finished yet. But the default text_label that is added when you call ui.TableCellView was getting in my way. I guess you don't have to assign it anything, but you can also do text_label.hidden = True.
The other thing I do is what the docs say. If you add a view to the TableCellView, then add it to then do TableCellView.content_view.add_subview(obj)
Well, I was a little hasty about my comment about the data does not matter. tuples can not be updated, well at least in place anyway. So my statement was wrong. It does matter. Depends on what you need to do with your data. Tail between my legs again:)