Python源码示例:ui.TableViewCell()
示例1
def tableview_cell_for_row(self, tableview, section, row):
departure = self.departures[row]
product = departure['product']
destination = departure['destination']
label = departure['label']
time_remaining = (datetime.fromtimestamp(departure['departureTime']/1000.0) - datetime.now()).total_seconds()
if time_remaining > 60:
time_remaining = f'{int(time_remaining / 60)} min'
else:
time_remaining = f'{int(time_remaining)} sec'
cell = ui.TableViewCell('value1')
cell.text_label.text = f'{label} - {destination}'
cell.text_label.text_color = departure['lineBackgroundColor']
cell.detail_text_label.text = time_remaining
return cell
示例2
def tableview_cell_for_row(self, tableview, section, row):
section_key = self.elements.keys()[section]
try:
cell = ui.TableViewCell('subtitle')
cell.background_color = self.thememanager.main_background_colour
cell.text_label.text_color = self.thememanager.main_text_colour
cell.text_label.text = self.elements[section_key][row].get_title()
cell.detail_text_label.text = self.elements[section_key][row].get_description()
cell.detail_text_label.text_color = self.thememanager.main_text_colour
cell.image_view.image = ui.Image.named(self.elements[section_key][row].get_icon())
cell.selectable = True
return cell
except:
cell = ui.TableViewCell('subtitle')
cell.text_label.text = self.elements[section_key][row].get_title()
cell.detail_text_label.text = 'Is invalid please check file in elements folder'
cell.selectable = False
return cell
示例3
def tableview_cell_for_row(self, tableview, section, row):
section_key = self.elements.keys()[section]
try:
cell = ui.TableViewCell('subtitle')
cell.text_label.text = self.elements[section_key][row].get_title()
cell.detail_text_label.text = self.elements[section_key][row].get_description()
cell.image_view.image = ui.Image.named(self.elements[section_key][row].get_icon())
cell.selectable = False
cell.background_color = self.thememanager.main_background_colour
cell.text_label.text_color = self.thememanager.main_text_colour
cell.detail_text_label.text_color = self.thememanager.main_text_colour
return cell
except:
cell = ui.TableViewCell('subtitle')
cell.text_label.text = self.elements[section_key][row].get_title()
cell.detail_text_label.text = 'Is invalid please check file in elements folder'
cell.selectable = False
return cell
示例4
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell('subtitle')
tool_name = self.tool_names[row]
tool_url = self.tools_dict[tool_name]['url']
cell.text_label.text = tool_name
cell.detail_text_label.text = self.tools_dict[tool_name]['description']
# TODO: Cell does not increase its height when label has multi lines of text
# cell.detail_text_label.line_break_mode = ui.LB_WORD_WRAP
# cell.detail_text_label.number_of_lines = 0
InstallButton(self.app, cell, self.category_name, tool_name, tool_url)
return cell
示例5
def tableview_cell_for_row(self, tableview, section, row):
station = self.stations[row]
distance = station['distance']
cell = ui.TableViewCell('value1')
cell.text_label.text = station['name']
cell.detail_text_label.text = f'{distance} m'
return cell
# Delegate
示例6
def tableview_cell_for_row(self, tv, section, row):
item = self.filtered_items[row]
cell = TableViewCell(UITableViewCellStyle.subtitle.value)
cell.text_label.number_of_lines = 1
cell.text_label.text = item.title
cell.detail_text_label.text = item.subtitle
cell.detail_text_label.text_color = (0, 0, 0, 0.5)
return cell
示例7
def tableview_cell_for_row(self, tv, section, row):
item = self._filtered_items[row]
cell = ui.TableViewCell(UITableViewCellStyle.subtitle.value)
cell.text_label.number_of_lines = 1
cell.text_label.text = item.title
cell.detail_text_label.text = item.subtitle
cell.detail_text_label.text_color = (0, 0, 0, 0.5)
if item.image:
cell.image_view.image = item.image
return cell
示例8
def tableview_cell_for_row(self, tv, section, row):
cell = ui.TableViewCell()
entry = self.flat_entries[row]
level = entry.level - 1
image_view = ui.ImageView(frame=(44 + 20*level, 5, 34, 34))
label_x = 44+34+8+20*level
label_w = cell.content_view.bounds.w - label_x - 8
if entry.subtitle:
label_frame = (label_x, 0, label_w, 26)
sub_label = ui.Label(frame=(label_x, 26, label_w, 14))
sub_label.font = ('<System>', 12)
sub_label.text = entry.subtitle
sub_label.text_color = '#999'
cell.content_view.add_subview(sub_label)
else:
label_frame = (label_x, 0, label_w, 44)
label = ui.Label(frame=label_frame)
if entry.subtitle:
label.font = ('<System>', 15)
else:
label.font = ('<System>', 18)
label.text = entry.title
label.flex = 'W'
cell.content_view.add_subview(label)
if entry.leaf and not entry.enabled:
label.text_color = '#999'
cell.content_view.add_subview(image_view)
if not entry.leaf:
has_children = entry.expanded
btn = ui.Button(image=ui.Image.named('CollapseFolder' if has_children else 'ExpandFolder'))
btn.frame = (20*level, 0, 44, 44)
btn.action = self.expand_dir_action
cell.content_view.add_subview(btn)
if entry.icon_name:
image_view.image = ui.Image.named(entry.icon_name)
else:
image_view.image = None
cell.selectable = entry.enabled
return cell
示例9
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell('subtitle')
cell.accessory_type = 'disclosure_indicator'
if self.is_main():
text = self.source[row]['title']
cell.text_label.text = text
if 'copyright' in self.source[row]:
cell.detail_text_label.text = self.source[row]['copyright']
else:
cell.text_label.text = self.source[row]
tableview.row_height = 48
cell.image_view.image = ui.Image.named(self.source[row])
if self.dark_cells:
cell.image_view.background_color = 'black'
return cell
示例10
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell()
cell.text_label.text = self.flows[row]
cell.background_color = self.thememanager.main_background_colour
cell.text_label.text_color = self.thememanager.main_text_colour
cell.selectable = True
return cell
示例11
def tableview_cell_for_row(self, tableview, section, row):
param = self.params[row]
name = param.displayName
cell = None
if name == None or name == '':
name = param.name
if param.type == 'bool':
cell = ui.TableViewCell()
cell.selectable = False
switch = ui.Switch()
switch.name = param.name
switch.value = param.value
switch.y = cell.center.y - switch.height/2
switch.x = cell.width + switch.width/2
switch.action = self.switch_change
cell.add_subview(switch)
else:
cell = ui.TableViewCell('value1')
if not param.value == None:
cell.detail_text_label.text = str(param.value)
cell.detail_text_label.text_color = self.thememanager.main_text_colour
cell.text_label.text = name
cell.background_color = self.thememanager.main_background_colour
cell.text_label.text_color = self.thememanager.main_text_colour
return cell
示例12
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell('subtitle')
if section == 0:
nullable = self.tinfo[row][3] == 1
cell.text_label.text = self.tinfo[row][1]
fmt = 'Type: {} Nullable: {} Default: {}'
cell.detail_text_label.text = fmt.format(self.tinfo[row][2], nullable, self.tinfo[row][4])
elif section == 1:
cell.text_label.text = self.iinfo[row][1]
cell.selectable = False
return cell
示例13
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell('value1')
if section == 0:
if row == 0:
cell.text_label.text = 'Record'
cell.detail_text_label.text = self.return_count_label()
else:
cell.text_label.text = str(self.tkeys[row-1])
cell.detail_text_label.text = str(self.tdata[self.currentid-1][row-1])
cell.selectable = False
return cell
示例14
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell()
if section == 0:
cell.text_label.text = self.tables[row]
elif section == 1:
cell.text_label.text = self.views[row]
else:
cell.text_label.text = self.systemtables[row]
cell.selectable = True
return cell
示例15
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell('subtitle')
tool_name = self.tool_names[row]
tool_url = self.tools_dict[tool_name]['url']
cell.text_label.text = tool_name
cell.detail_text_label.text = self.tools_dict[tool_name]['description']
# TODO: Cell does not increase its height when label has multi lines of text
# cell.detail_text_label.line_break_mode = ui.LB_WORD_WRAP
# cell.detail_text_label.number_of_lines = 0
InstallButton(self.app, cell, self.category_name, tool_name, tool_url)
return cell
示例16
def tableview_cell_for_row(self, tableview, section, row):
self.width, height = ui.get_screen_size()
cell = ui.TableViewCell()
cell.bounds = (0,0,self.width,self.row_height)
for i in range(3):
self.make_labels(cell, tableview.data_source.items[row][i], i)
return cell
示例17
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell()
cell.accessory_type = ('disclosure_indicator', 'detail_button')[section]
cell.text_label.text = self.data[section][row]
if section==0:
cell.background_color='#eeffee'
return cell
示例18
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell()
cell.text_label.text = str(self.items[row])
cell.text_label.alignment = ui.ALIGN_CENTER
return cell
示例19
def tableview_cell_for_row(self, tv, section, row):
if section == self._folder_section:
item = self.items[row]
node = item['node']
else:
item = self._files[row]
node = None
cell = ui.TableViewCell()
cvb = cell.content_view.bounds
x = 15 + cvb.x + item['level'] * 15
if node and node.children_exists:
image_view = ui.ImageView()
image_view.frame = (x, 10, 24, 24)
image_view.image = ui.Image.named(
'iob:arrow_down_b_24' if node.path in self._expanded_node_paths else 'iob:arrow_right_b_24'
)
cell.content_view.add_subview(image_view)
x += 24 + 8
image_view = ui.ImageView()
image_view.frame = (x, 10, 24, 24)
image_view.image = ui.Image.named('iob:folder_24' if node else 'iob:document_24')
cell.content_view.add_subview(image_view)
x += 24 + 8
title_label = ui.Label(flex='W')
title_label.text = item['title']
title_label.size_to_fit()
title_label.frame = (
x, cvb.y + (cvb.height - title_label.height) / 2.0,
cvb.width - (x - cvb.x) - 8, title_label.height
)
cell.content_view.add_subview(title_label)
separator = ui.View(flex='W')
separator.background_color = (0, 0, 0, 0.05)
x = title_label.frame.x - 12 - 8
separator.frame = (
x, cvb.y + cvb.height - 1,
cvb.width - (x - cvb.x), 1
)
cell.content_view.add_subview(separator)
cell_objc = ObjCInstance(cell)
cell_objc.setSelectionStyle(0)
return cell
示例20
def tableview_cell_for_row(self, tableview, section, row):
if row >= self.extraRows:
element = self.elements[row-self.extraRows]
cell = ui.TableViewCell('subtitle')
cell.selectable = False
cell.text_label.text = element.get_title()
cell.detail_text_label.text = element.get_description()
cell.background_color=self.thememanager.main_background_colour
cell.image_view.image = ui.Image.named(element.get_icon())
params = element.get_params() or []
selectable = False
for p in params:
if p.display:
selectable = True
cell.accessory_type = 'disclosure_indicator'
cell.selectable = selectable
if self.currentElementNumber >= self.extraRows:
cell.selectable = False
if self.currentElementNumber+1 == row:
cell.background_color = self.thememanager.running_cell_background_colour
cell.text_label.text_color = self.thememanager.running_cell_text_colour
cell.detail_text_label.text_color = self.thememanager.running_cell_text_colour
else:
cell.background_color = self.thememanager.main_background_colour
cell.text_label.text_color = self.thememanager.main_text_colour
cell.detail_text_label.text_color = self.thememanager.main_text_colour
return cell
elif row == self.adminRow:
cell = ui.TableViewCell()
cell.background_color=self.thememanager.main_background_colour
cell.selectable = False
editButton = ui.Button(title="Done" if tableview.editing else 'Edit')
editButton.width *= 1.4
editButton.action = swap_edit
editButton.y = cell.height/2 - editButton.height/2
editButton.x = cell.width
cell.add_subview(editButton)
self.titleButton.y = cell.height/2 - editButton.height/2
self.titleButton.x = self.titleButton.width/2
self.titleButton.action = self.change_title
cell.add_subview(self.titleButton)
return cell
elif row == self.typeRow:
cell = ui.TableViewCell('value1')
cell.background_color=self.thememanager.main_background_colour
cell.selectable = True
cell.text_label.text_color = self.thememanager.main_text_colour
cell.detail_text_label.text_color = self.thememanager.main_text_colour
cell.text_label.text = 'Type of Flow'
cell.detail_text_label.text = self.flowType
return cell
示例21
def tableview_cell_for_row(self, tableview, section, row):
cell = ui.TableViewCell('value1')
if row == self.titleRow:
cell.text_label.text = 'Title'
if self.title.strip(' ') == '':
cell.detail_text_label.text = 'Please enter a title'
else:
cell.detail_text_label.text = self.title
elif row == self.inputTypeRow:
cell.text_label.text = 'Input Type'
if self.inputType == None:
cell.detail_text_label.text = 'None'
else:
cell.detail_text_label.text = self.inputType
elif row == self.outputTypeRow:
cell.text_label.text = 'Output Type'
if self.outputType == None:
cell.detail_text_label.text = 'None'
else:
cell.detail_text_label.text = self.outputType
elif row == self.descriptionRow:
cell.text_label.text = 'Description'
if self.description.strip(' ') == '':
cell.detail_text_label.text = 'Please enter a description'
else:
cell.detail_text_label.text = self.description
elif row == self.iconRow:
cell.text_label.text = 'Icon'
if self.icon.strip(' ') == '':
cell.detail_text_label.text = 'Please choose a icon'
else:
cell.detail_text_label.text = self.icon
elif row == self.categoryRow:
cell.text_label.text = 'Category'
if self.category.strip(' ') == '':
cell.detail_text_label.text = 'Please enter a category'
else:
cell.detail_text_label.text = self.category
elif row == self.canHandleListRow:
cell.text_label.text = 'Can Handle List'
cell.selectable = False
switch = ui.Switch()
switch.name = 'canHandleList'
switch.value = False
switch.y = cell.center.y - switch.height/2
switch.x = cell.width + switch.width/2
switch.action = self.canHandleListAction
cell.add_subview(switch)
cell.text_label.text_color = self.thememanager.main_text_colour
cell.detail_text_label.text_color = self.thememanager.main_text_colour
cell.background_color = self.thememanager.main_background_colour
return cell