omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Way to change font size for different lines in Cell?

    Pythonista
    ui.tableview
    4
    8
    6344
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • techteej
      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

      1 Reply Last reply Reply Quote 0
      • dgelessus
        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
        
        1 Reply Last reply Reply Quote 0
        • techteej
          techteej last edited by

          That's probably what I want, but I'm not sure how to call it because I use data_source.items to set everything

          Phuket2 1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by JonB

            http://omz-software.com/pythonista/docs/ios/ui.html#ui.ListDataSource.items

            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.

            1 Reply Last reply Reply Quote 0
            • Phuket2
              Phuket2 @techteej last edited by

              @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')
              
              1 Reply Last reply Reply Quote 0
              • Phuket2
                Phuket2 last edited by

                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...

                1 Reply Last reply Reply Quote 0
                • Phuket2
                  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)

                  1 Reply Last reply Reply Quote 0
                  • Phuket2
                    Phuket2 last edited by

                    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:)

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB Forums | Contributors