本文整理汇总了Python中albow.TableView.selectedIndex方法的典型用法代码示例。如果您正苦于以下问题:Python TableView.selectedIndex方法的具体用法?Python TableView.selectedIndex怎么用?Python TableView.selectedIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类albow.TableView
的用法示例。
在下文中一共展示了TableView.selectedIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: removePreset
# 需要导入模块: from albow import TableView [as 别名]
# 或者: from albow.TableView import selectedIndex [as 别名]
def removePreset(self):
"""
Brings up a panel to remove presets.
"""
panel = Dialog()
p = self.getBrushFileList()
if not p:
alert('No presets saved')
return
def okPressed():
panel.dismiss()
name = p[presetTable.selectedIndex] + ".preset"
os.remove(os.path.join(directories.brushesDir, name))
self.tool.showPanel()
def selectTableRow(i, evt):
presetTable.selectedIndex = i
if evt.num_clicks == 2:
okPressed()
presetTable = TableView(columns=(TableColumn("", 200),))
presetTable.num_rows = lambda: len(p)
presetTable.row_data = lambda i: (p[i],)
presetTable.row_is_selected = lambda x: x == presetTable.selectedIndex
presetTable.click_row = selectTableRow
presetTable.selectedIndex = 0
choiceCol = Column((ValueDisplay(width=200, get_value=lambda: "Select preset to delete"), presetTable))
okButton = Button("OK", action=okPressed)
cancelButton = Button("Cancel", action=panel.dismiss)
row = Row([okButton, cancelButton])
panel.add(Column((choiceCol, row)))
panel.shrink_wrap()
panel.present()
示例2: editMonsterSpawner
# 需要导入模块: from albow import TableView [as 别名]
# 或者: from albow.TableView import selectedIndex [as 别名]
def editMonsterSpawner(self, point):
mobs = self.mobs
tileEntity = self.editor.level.tileEntityAt(*point)
undoBackupEntityTag = copy.deepcopy(tileEntity)
if not tileEntity:
tileEntity = pymclevel.TAG_Compound()
tileEntity["id"] = pymclevel.TAG_String("MobSpawner")
tileEntity["x"] = pymclevel.TAG_Int(point[0])
tileEntity["y"] = pymclevel.TAG_Int(point[1])
tileEntity["z"] = pymclevel.TAG_Int(point[2])
tileEntity["Delay"] = pymclevel.TAG_Short(120)
tileEntity["EntityId"] = pymclevel.TAG_String(mobs[0])
self.editor.level.addTileEntity(tileEntity)
panel = Dialog()
def addMob(id):
if id not in mobs:
mobs.insert(0, id)
mobTable.selectedIndex = 0
def selectTableRow(i, evt):
if mobs[i] == "[Custom]":
id = input_text("Type in an EntityID for this spawner. Invalid IDs may crash Minecraft.", 150)
if id:
addMob(id)
else:
return
mobTable.selectedIndex = mobs.index(id)
else:
mobTable.selectedIndex = i
if evt.num_clicks == 2:
panel.dismiss()
mobTable = TableView(columns=(
TableColumn("", 200),
)
)
mobTable.num_rows = lambda: len(mobs)
mobTable.row_data = lambda i: (mobs[i],)
mobTable.row_is_selected = lambda x: x == mobTable.selectedIndex
mobTable.click_row = selectTableRow
mobTable.selectedIndex = 0
def selectedMob():
return mobs[mobTable.selectedIndex]
id = tileEntity["EntityId"].value
addMob(id)
mobTable.selectedIndex = mobs.index(id)
choiceCol = Column((ValueDisplay(width=200, get_value=lambda: selectedMob() + " spawner"), mobTable))
okButton = Button("OK", action=panel.dismiss)
panel.add(Column((choiceCol, okButton)))
panel.shrink_wrap()
panel.present()
class MonsterSpawnerEditOperation(Operation):
def __init__(self, tool, level):
self.tool = tool
self.level = level
self.undoBackupEntityTag = undoBackupEntityTag
self.canUndo = False
def perform(self, recordUndo=True):
if self.level.saving:
alert("Cannot perform action while saving is taking place")
return
self.level.addTileEntity(tileEntity)
self.canUndo = True
def undo(self):
self.redoBackupEntityTag = copy.deepcopy(tileEntity)
self.level.addTileEntity(self.undoBackupEntityTag)
return pymclevel.BoundingBox(pymclevel.TileEntity.pos(tileEntity), (1, 1, 1))
def redo(self):
self.level.addTileEntity(self.redoBackupEntityTag)
return pymclevel.BoundingBox(pymclevel.TileEntity.pos(tileEntity), (1, 1, 1))
if id != selectedMob():
tileEntity["EntityId"] = pymclevel.TAG_String(selectedMob())
op = MonsterSpawnerEditOperation(self.editor, self.editor.level)
self.editor.addOperation(op)
if op.canUndo:
self.editor.addUnsavedEdit()