本文整理匯總了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