Python源码示例:ui.TableView()
示例1
def __init__(self, app, category_name, category_url):
self.app = app
self.category_name = category_name
self.category_url = category_url
self.view = ui.TableView(frame=(0, 0, 640, 640))
self.view.name = category_name
self.tools_dict = self.app.repo.get_tools_from_md(category_url)
self.tool_names = sorted(self.tools_dict.keys())
self.view.data_source = self
self.view.delegate = self
示例2
def __init__(self):
ui.View.__init__(self)
self.background_color = "#ffffff"
self.table = ui.TableView()
self.table.delegate = self.table.data_source = self
self.table.flex = "WH"
self.add_subview(self.table)
self.ai = ui.ActivityIndicator()
self.ai.style = ui.ACTIVITY_INDICATOR_STYLE_WHITE_LARGE
self.ai.hides_when_stopped = True
self.ai.x = self.width / 2.0 - (self.ai.width / 2.0)
self.ai.y = self.height / 2.0 - (self.ai.height / 2.0)
self.ai.flex = "LRTB"
self.ai.background_color = "#000000"
self.ai.alpha = 0.7
self.ai.corner_radius = 5
self.add_subview(self.ai)
self.subview_open = False
self.cur_tf = None
self.hide_kb_button = ui.ButtonItem(
"Hide Keyboard",
action=self.hide_keyboard,
enabled=False,
)
self.right_button_items = (self.hide_kb_button, )
示例3
def history_present(self, history):
"""
Present a history popover.
:param history: history to present
:type history: ShHistory
"""
listsource = ui.ListDataSource(history.getlist())
listsource.action = self.history_popover_tapped
table = ui.TableView()
listsource.font = self.BUTTON_FONT
table.data_source = listsource
table.delegate = listsource
table.width = 300
table.height = 300
table.row_height = self.BUTTON_FONT[1] + 4
table.present('popover')
table.wait_modal()
示例4
def __init__(self):
self.dirs = []
self.files = []
self.select_color = 'lightgrey'
self.unselect_color = 'white'
self.active_button = None
self.button_height = 50
self.btn_name = self.make_buttons('Name')
self.btn_size = self.make_buttons('Size')
self.btn_date = self.make_buttons('Date')
self.tv = ui.TableView()
self.tv.row_height = 30
self.tv.data_source = MyTableViewDataSource(self.tv.row_height)
self.get_dir()
self.all_items = self.dirs + self.files
self.tv.data_source.items = self.all_items
self.name = 'TableView-Test'
#self.tv.delegate = MyTableViewDelegate()
self.tv.allows_selection = False
self.add_subview(self.tv)
self.present('full_screen')
示例5
def open_finder(self,sender):
# expand out a view/dialog from sender
root=self.find_root()
overlay=ui.Button(frame=(0,0)+tuple(root.frame)[2:],bg_color=(0,0,0,0.25),name='overlay')
dialog=ui.View(frame=sender.frame,bg_color='white',name='dialog')
self.tbl=ui.TableView()
self.tbl.width=dialog.width
self.tbl.height=dialog.height
self.listsource=ui.ListDataSource(items=[])
self.tbl.data_source=self.listsource
self.tbl.delegate=self.listsource
self.listsource.action=self.stop_populating
self.tbl.flex='wh'
dialog.add_subview(self.tbl)
overlay.add_subview(dialog)
overlay.action=self.stop_populating
root.add_subview(overlay)
self.dialog=dialog
def ani():
dialog.x,dialog.y=ui.convert_point((self.textfield.x,self.textfield.y+self.textfield.height),self,root)
dialog.width=self.textfield.width
dialog.height=min(400,root.height-ui.convert_point((0,dialog.y),self,root)[1])
ui.delay(self.start_populating,0.16)
ui.animate(ani,0.15)
示例6
def open_finder(self,sender):
# expand out a view/dialog from sender
root=self.find_root()
overlay=ui.Button(frame=(0,0)+tuple(root.frame)[2:],bg_color=(0,0,0,0.25),name='overlay')
dialog=ui.View(frame=sender.frame,bg_color='white',name='dialog')
self.tbl=ui.TableView()
self.tbl.width=dialog.width
self.tbl.height=dialog.height
self.listsource=ui.ListDataSource(items=[])
self.tbl.data_source=self.listsource
self.tbl.delegate=self.listsource
self.listsource.action=self.stop_populating
self.tbl.flex='wh'
dialog.add_subview(self.tbl)
overlay.add_subview(dialog)
overlay.action=self.stop_populating
root.add_subview(overlay)
self.dialog=dialog
def ani():
dialog.x,dialog.y=ui.convert_point((self.textfield.x,self.textfield.y+self.textfield.height),self,root)
dialog.width=self.textfield.width
dialog.height=min(400,root.height-ui.convert_point((0,dialog.y),self,root)[1])
ui.delay(self.start_populating,0.16)
ui.animate(ani,0.15)
示例7
def __init__(self, app):
self.app = app
self.view = ui.TableView(frame=(0, 0, 640, 640))
self.view.name = 'Categories'
self.categories_dict = {}
self.load()
示例8
def __init__(self):
self.tv = ui.TableView()
self.tv.flex = 'WH'
self.tv.data_source = self
self.tv.delegate = self
self.add_subview(self.tv)
self.name = 'Nearby'
self.right_button_items = [ui.ButtonItem(image=ui.Image.named('refresh'), title="refresh", action=lambda x: self.load_stations())]
self.load_stations()
示例9
def __init__(self, station):
self.station = station
self.departures = []
self.tv = ui.TableView()
self.tv.flex = "WH"
self.tv.data_source = self
self.tv.delegate = self # TODO use an objc delegate instead to spport custom swipe actions? (notifications!!!)
self.add_subview(self.tv)
self.load_departures()
示例10
def history_popover_tapped(self, sender):
"""
Called when a row in the history popover was tapped.
:param sender: sender of the event
:type sender: ui.TableView
"""
if sender.selected_row >= 0:
self.history_selected(sender.items[sender.selected_row], sender.selected_row)
示例11
def __init__(self, root_node, allow_multi=False, async_mode=False):
self.async_mode = async_mode
self.allow_multi = allow_multi
self.selected_entries = None
self.table_view = ui.TableView()
self.table_view.frame = (0, 0, 500, 500)
self.table_view.data_source = self
self.table_view.delegate = self
self.table_view.flex = 'WH'
self.table_view.allows_multiple_selection = True
self.table_view.tint_color = 'gray'
self.view = ui.View(frame=self.table_view.frame)
self.view.add_subview(self.table_view)
self.view.name = root_node.title
self.busy_view = ui.View(frame=self.view.bounds, flex='WH', background_color=(0, 0, 0, 0.35))
hud = ui.View(frame=(self.view.center.x - 50, self.view.center.y - 50, 100, 100))
hud.background_color = (0, 0, 0, 0.7)
hud.corner_radius = 8.0
hud.flex = 'TLRB'
spinner = ui.ActivityIndicator()
spinner.style = ui.ACTIVITY_INDICATOR_STYLE_WHITE_LARGE
spinner.center = (50, 50)
spinner.start_animating()
hud.add_subview(spinner)
self.busy_view.add_subview(hud)
self.busy_view.alpha = 0.0
self.view.add_subview(self.busy_view)
self.done_btn = ui.ButtonItem(title="Done", action=self.done_action)
if self.allow_multi:
self.view.right_button_items = [self.done_btn]
self.done_btn.enabled = False
self.root_node = root_node
self.entries = []
self.flat_entries = []
if self.async_mode:
self.set_busy(True)
t = threading.Thread(target=self.expand_root)
t.start()
else:
self.expand_root()
示例12
def get_view(elements, cb, thememanager):
dbo = ElementListView(elements = elements, selectedCallBack = cb, thememanager = thememanager)
table_view = ui.TableView()
table_view.name = 'Elements'
table_view.data_source = dbo
table_view.delegate = dbo
table_view.background_color = thememanager.main_background_colour
return table_view
示例13
def create_table_view(self):
table_view = ui.TableView()
table_view.name = 'tableview'
table_view.flex = 'WH'
table_view.width = self.width
table_view.height = self.height
table_view.delegate = self
table_view.data_source = self
self.add_subview(table_view)
示例14
def get_view(elements, thememanager):
dbo = ElementManagementView(elements = elements, thememanager = thememanager)
table_view = ui.TableView()
table_view.name = 'Elements'
table_view.data_source = dbo
table_view.delegate = dbo
table_view.background_color = thememanager.main_background_colour
return table_view
示例15
def __init__(self):
self.schema_v = ui.TableView('grouped')
self.data_v = ui.TableView()
self.nbutton = ui.Button(title="Next")
self.pbutton = ui.Button(title="Prev")
示例16
def get_view(dir, cb, filetypes):
test = FilebrowserController(dir=dir, cb=cb, filetypes=filetypes)
table_view = ui.TableView()
table_view.name = 'Files'
table_view.data_source = test
table_view.delegate = test
return table_view
示例17
def get_view(dbpath, navview):
dbo = dbobjectsview(dbpath, navview)
table_view = ui.TableView()
table_view.name = dbpath
table_view.data_source = dbo
table_view.delegate = dbo
return table_view
示例18
def __init__(self, app, category_name, category_url):
self.app = app
self.category_name = category_name
self.category_url = category_url
self.view = ui.TableView(frame=(0, 0, 640, 640))
self.view.name = category_name
self.tools_dict = self.app.repo.get_tools_from_md(category_url)
self.tool_names = sorted(self.tools_dict.keys())
self.view.data_source = self
self.view.delegate = self
示例19
def __init__(self, app):
self.app = app
self.view = ui.TableView(frame=(0, 0, 640, 640))
self.view.name = 'Categories'
self.categories_dict = {}
self.load()
示例20
def __init__(self,setter, base_dir = '.', *args, **kargs):
self.table = ui.TableView(*args, **kargs)
self.name=os.path.split(os.path.abspath(base_dir))[1]
self.src = MyTableViewDataSource(setter, base_dir)
self.table.data_source = self.src
self.table.delegate = self.src
self.table.flex = 'WHTBLR'
self.setter=setter
#self.view = ui.View(name = base_dir)
self.background_color = 'white'
self.add_subview(self.table)
示例21
def __init__(self, high_scores=high_scores):
self.name = 'Cloud Jump 2 - Leaderboard'
self.frame=(0, 0, 500, 500)
tv = ui.TableView()
tv.frame=(0, 0, 500, 500)
tv.data_source = Data(items=self.scores_list(high_scores))
tv.allows_selection = tv.data_source.delete_enabled = False
self.add_subview(tv)
示例22
def main(r):
L=log_table(r)
t=ui.TableView()
t.row_height=75
t.data_source=L
t.delegate=L
t.frame=(44.0, 44.0, 540.0, 576.0)
t.present('sheet')
示例23
def __init__(self):
global _datasource
self.name = 'Drag & Drop'
self.width = min(ui.get_window_size()[0] * 0.8, 700)
self.height = ui.get_window_size()[1] * 0.8
path = editor.get_path()
if path:
expanded_folder = os.path.dirname(path)
files = tab.get_paths()
else:
expanded_folder = None
files = None
root_node = FileNode(os.path.expanduser('~/Documents'), ignore=ignore)
_datasource = FolderPickerDataSource(root_node, expanded_folder, files)
tv = ui.TableView(frame=self.bounds, flex='WH')
tv.delegate = _datasource
tv.data_source = _datasource
tv.allows_multiple_selection = False
tv.allows_selection = True
tv.allows_multiple_selection_during_editing = False
tv.allows_selection_during_editing = False
tv.separator_color = 'clear'
self.add_subview(tv)
methods = [tableView_itemsForBeginningDragSession_atIndexPath_]
protocols = ['UITableViewDragDelegate']
DragDelegate = create_objc_class('DragDelegate', methods=methods, protocols=protocols)
self._drag_delegate = DragDelegate.alloc().init()
methods = [
tableView_canHandleDropSession_,
tableView_dropSessionDidUpdate_withDestinationIndexPath_,
tableView_performDropWithCoordinator_
]
protocols = ['UITableViewDropDelegate']
DropDelegate = create_objc_class('DropDelegate', methods=methods, protocols=protocols)
self._drop_delegate = DropDelegate.alloc().init()
tv_objc = ObjCInstance(tv)
tv_objc.setDragDelegate_(self._drag_delegate)
tv_objc.setDropDelegate_(self._drop_delegate)
def handle_escape():
self.close()
self._handlers = [
register_key_event_handler(UIEventKeyCode.ESCAPE, handle_escape),
register_key_event_handler(UIEventKeyCode.DOT, handle_escape,
modifier=UIKeyModifier.COMMAND)
]
示例24
def __init__(self, **kwargs):
super().__init__(**kwargs)
if 'background_color' not in kwargs:
self.background_color = 'white'
if 'frame' not in kwargs:
self.width = min(ui.get_window_size()[0] * 0.8, 700)
self.height = ui.get_window_size()[1] * 0.8
self._tableview = ui.TableView()
self._textfield = ui.TextField()
self._help_label = ui.Label()
self._datasource = None
self._handlers = None
self.shift_enter_enabled = True
self.did_select_item_action = None
tf = LayoutProxy(self._textfield)
self.add_subview(tf)
tf.layout.align_left_with_superview.equal = 8
tf.layout.align_top_with_superview.equal = 8
tf.layout.align_right_with_superview.equal = -8
tf.layout.height.equal = 31
tf.delegate = self
tv = LayoutProxy(self._tableview)
self.add_subview(tv)
tv.layout.align_left_to(tf).equal = 0
tv.layout.align_right_to(tf).equal = 0
tv.layout.top_offset_to(tf).equal = 8
tv.allows_selection = True
tv.allows_multiple_selection = False
hl = LayoutProxy(self._help_label)
self.add_subview(hl)
hl.layout.align_left_to(tv).equal = 0
hl.layout.align_right_to(tv).equal = 0
hl.layout.top_offset_to(tv).equal = 8
hl.layout.align_bottom_with_superview.equal = -8
hl.layout.height.max = 66
hl.font = ('<system>', 13.0)
hl.alignment = ui.ALIGN_CENTER
hl.text_color = (0, 0, 0, 0.5)
hl.number_of_lines = 2
if is_in_hardware_keyboard_mode:
tf.view.begin_editing()
self._register_key_event_handlers()