Have just started to use pythonista and have been experimenting with a few things. Am new to python as well. If someone could tell me how to change the font type size and colour in the title and initial text of a tableview. I have been using and changing some of the examples I have found.
import ui
_days = ['Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday', 'Saturday','Sunday']
_colors = ['yellow', 'pink', 'green', 'orange', 'blue', 'purple', 'red']
class MyTableViewDataSource (object):
def tableview_number_of_sections(self, tableview):
# Return the number of sections (defaults to 1)
return 1
def tableview_number_of_rows(self, tableview, section):
# Return the number of rows in the section
return len(_days)
def tableview_cell_for_row(self, tableview, section, row):
# Create and return a cell for the given section/row
cell = ui.TableViewCell('subtitle')
cell.text_label.text = _days[row]
cell.detail_text_label.text = _colors[row]
cell.detail_text_label.text_color = _colors[row]
# create a label inside the cell
# the documentation says to add it to the
# content view
lb=ui.Label()
lb.x=160
lb.y=15
lb.width=100
lb.height=15
lb.text='test'
lg=ui.Label()
lg.x,lg.y = 260,15
lg.width=70
lg.height=15
lg.font='SFUIDisplay-Light',10
lg.text_color='red'
lg.text='second'
cell.content_view.add_subview(lg)
cell.content_view.add_subview(lb)
return cell
def tableview_title_for_header(self, tableview, section):
# Return a title for the given section.
# If this is not implemented, no section headers will be shown
if section == 0:
return 'Week Days'
def tableview_can_delete(self, tableview, section, row):
# Return True if the user should be able to delete the given row.
return True
def tableview_can_move(self, tableview, section, row):
# Return True if a reordering control should be shown for the given row (in editing mode).
return True
def tableview_delete(self, tableview, section, row):
# Called when the user confirms deletion of the given row.
pass
def tableview_move_row(self, tableview, from_section, from_row, to_section, to_row):
# Called when the user moves a row with the reordering control (in editing mode).
pass
if name == 'main':
frame = (0,0,540,576)
v = ui.View()
tb = ui.TableView()
tb.frame = frame
v.add_subview(tb)
tb.data_source = MyTableViewDataSource()
v.present('sheet')