本文整理汇总了Python中albow.TableView.dispatch_key方法的典型用法代码示例。如果您正苦于以下问题:Python TableView.dispatch_key方法的具体用法?Python TableView.dispatch_key怎么用?Python TableView.dispatch_key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类albow.TableView
的用法示例。
在下文中一共展示了TableView.dispatch_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_inventory
# 需要导入模块: from albow import TableView [as 别名]
# 或者: from albow.TableView import dispatch_key [as 别名]
#.........这里部分代码省略.........
def click_row(n, e):
table.focus()
table.selected_row = n
if e.num_clicks > 1:
SlotEditor(table, row_data(n)).present()
table.click_row = click_row
def row_is_selected(n):
return n == table.selected_row
table.row_is_selected = row_is_selected
def change_value(data):
s, i, c, d = data
s = int(s)
s_idx = 0
#&# Prototype for blocks/items names
name, state = map_items.get(mclangres.untranslate(i), (i, '0'))
if ':' not in name:
name = 'minecraft:%s'%name
#&#
if s in slots_set:
for slot in inventory:
ok1 = False
if player:
ok1 = slot['Slot'].value == s
else:
ok1 = inventory.index(slot) == s
if ok1:
if not i or int(c) < 1:
del inventory[s_idx]
i = ""
c = u'0'
d = u'0'
else:
#&# Prototype for blocks/items names
#slot['id'].value = 'minecraft:%s'%i
slot['id'].value = name
#&#
slot['Count'].value = int(c)
slot['Damage'].value = int(state)
break
s_idx += 1
else:
new_slot = TAG_Compound()
if player:
new_slot['Slot'] = TAG_Byte(s)
#&# Prototype for blocka/items names
#new_slot['id'] = TAG_String('minecraft:%s'%i)
new_slot['id'] = TAG_String(name)
#&#
new_slot['Count'] = TAG_Byte(int(c))
new_slot['Damage'] = TAG_Short(int(state))
idx = s
for slot in inventory:
ok2 = False
if player:
ok2 = slot['Slot'].value >= s
else:
ok2 = inventory.index(slot) >= s
if ok2:
idx = slot['Slot'].value
break
inventory.insert(s, new_slot)
slots_set.append(s)
#&# Prototype for blocks/items names
# if i == name:
# i = name
#&#
if s >= 100:
n = s - 100 + 36
else:
n = s
table.slots[n] = slots[n] = s, i, c, state
table.change_value = change_value
def dispatch_key(name, evt):
keyname = self.root.getKey(evt)
if keyname == 'Return':
SlotEditor(table, row_data(table.selected_row)).present()
elif keyname == "Up" and table.selected_row > 0:
table.selected_row -= 1
table.rows.scroll_to_item(table.selected_row)
elif keyname == "Down" and table.selected_row < len(slots) - 1:
table.selected_row += 1
table.rows.scroll_to_item(table.selected_row)
elif keyname == 'Page down':
table.selected_row = min(len(slots) - 1, table.selected_row + table.rows.num_rows())
elif keyname == 'Page up':
table.selected_row = max(0, table.selected_row - table.rows.num_rows())
if table.rows.cell_to_item_no(0, 0) != None and (table.rows.cell_to_item_no(0, 0) + table.rows.num_rows() -1 > table.selected_row or table.rows.cell_to_item_no(0, 0) + table.rows.num_rows() -1 < table.selected_row):
table.rows.scroll_to_item(table.selected_row)
table.dispatch_key = dispatch_key
rows.append(table)
return rows