本文整理汇总了Python中albow.Column类的典型用法代码示例。如果您正苦于以下问题:Python Column类的具体用法?Python Column怎么用?Python Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Column类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, items, keysColumn=None, buttonsColumn=None):
if keysColumn is None:
keysColumn = []
if buttonsColumn is None:
buttonsColumn = []
Widget.__init__(self)
for (hotkey, title, action) in items:
if isinstance(title, (str, unicode)):
button = Button(title, action=action)
else:
button = ValueButton(ref=title, action=action, width=200)
button.anchor = self.anchor
label = Label(hotkey, width=75, margin=button.margin)
label.anchor = "wh"
label.height = button.height
keysColumn.append(label)
buttonsColumn.append(button)
self.buttons = list(buttonsColumn)
buttonsColumn = Column(buttonsColumn)
buttonsColumn.anchor = self.anchor
keysColumn = Column(keysColumn)
commandRow = Row((keysColumn, buttonsColumn))
self.add(commandRow)
self.shrink_wrap()
示例2: __init__
def __init__(self, tool):
Panel.__init__(self)
self.tool = tool
self.player_UUID = {}
self.level = tool.editor.level
if hasattr(self.level, 'players'):
players = self.level.players or ["[No players]"]
if not self.level.oldPlayerFolderFormat:
for player in players:
if player != "Player" and player != "[No players]":
self.player_UUID[version_utils.getPlayerNameFromUUID(player)] = player
if "Player" in players:
self.player_UUID["Player"] = "Player"
if "[No players]" not in players:
players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player" else x.lower())
else:
players = ["Player"]
self.players = players
max_height = self.tool.editor.mainViewport.height - self.tool.editor.netherPanel.height - self.tool.editor.subwidgets[0].height - self.margin - 2
addButton = Button("Add Player", action=self.tool.addPlayer)
removeButton = Button("Remove Player", action=self.tool.removePlayer)
gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
gotoCameraButton = Button("Goto Player's View", action=self.tool.gotoPlayerCamera)
moveButton = Button("Move Player", action=self.tool.movePlayer)
moveToCameraButton = Button("Align Player to Camera", action=self.tool.movePlayerToCamera)
reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")
print max_height
max_height -= sum((a.height for a in (addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin)))
print max_height
tableview = TableView(columns=[
TableColumn("Player Name(s):", 200),
], height=max_height)
tableview.index = 0
tableview.num_rows = lambda: len(players)
tableview.row_data = lambda i: (players[i],)
tableview.row_is_selected = lambda x: x == tableview.index
tableview.zebra_color = (0, 0, 0, 48)
def selectTableRow(i, evt):
tableview.index = i
tableview.click_row = selectTableRow
self.table = tableview
col = [self.table]
col.extend([addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin])
col = Column(col, margin=0, spacing=2)
col.shrink_wrap()
self.add(col)
self.shrink_wrap()
示例3: __init__
def __init__(self, items, keysColumn=None, buttonsColumn=None, item_spacing=None):
warn(self)
if keysColumn is None:
keysColumn = []
if buttonsColumn is None:
buttonsColumn = []
labels = []
Widget.__init__(self)
for t in items:
if len(t) == 3:
(hotkey, title, action) = t
tooltipText = None
else:
(hotkey, title, action, tooltipText) = t
if isinstance(title, (str, unicode)):
button = Button(title, action=action)
else:
button = ValueButton(ref=title, action=action, width=200)
button.anchor = self.anchor
label = Label(hotkey, width=100, margin=button.margin)
label.anchor = "wh"
label.height = button.height
labels.append(label)
if tooltipText:
button.tooltipText = tooltipText
keysColumn.append(label)
buttonsColumn.append(button)
self.buttons = list(buttonsColumn)
#.#
if item_spacing == None:
buttonsColumn = Column(buttonsColumn)
else:
buttonsColumn = Column(buttonsColumn, spacing=item_spacing)
#.#
buttonsColumn.anchor = self.anchor
#.#
if item_spacing == None:
keysColumn = Column(keysColumn)
else:
keysColumn = Column(keysColumn, spacing=item_spacing)
commandRow = Row((keysColumn, buttonsColumn))
self.labels = labels
self.add(commandRow)
self.shrink_wrap()
示例4: editNBTData
def editNBTData(self):
player = self.selectedPlayer
if player == 'Player (Single Player)':
alert("Not yet implemented.\nUse the NBT Explorer to edit this player.")
elif player == '[No players]':
return
else:
player = self.level.getPlayerTag(self.selectedPlayer)
if player is not None:
self.pages.remove_page(self.nbtpage)
def close():
self.pages.show_page(self.col)
self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject=player, fileName=None,
savePolicy=-1, dataKeyName=None,
height=self.max_height, no_header=True, close_text="Go Back",
close_action=close, load_text=None,
copy_data=False)
self.nbtpage = Column([self.nbttree,])
self.nbtpage.shrink_wrap()
self.pages.add_page("NBT Data", self.nbtpage)
self.pages.show_page(self.nbtpage)
else:
alert(_("Unable to load player %s" % self.selectedPlayer()))
示例5: editNBTData
def editNBTData(self):
player = self.selectedPlayer
if player == 'Player (Single Player)':
alert("Not yet implemented.\nUse the NBT Explorer to edit this player.")
elif player == '[No players]':
return
else:
path = os.path.join(os.path.split(self.level.filename)[0], 'playerdata')
if not os.path.exists(path):
path = os.path.join(os.path.split(self.level.filename)[0], 'players')
if player + '.dat' in os.listdir(path):
fName = os.path.join(path, player + '.dat')
nbtObject, dataKeyName, dontSaveRootTag, fn = loadFile(fName)
self.pages.remove_page(self.nbtpage)
def close():
self.pages.show_page(self.col)
self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject=nbtObject, fileName=fName,
dontSaveRootTag=dontSaveRootTag, dataKeyName=dataKeyName,
height=self.max_height, no_header=True, close_text="Go Back",
close_action=close, load_text=None)
self.nbtpage = Column([self.nbttree,])
self.nbtpage.shrink_wrap()
self.pages.add_page("NBT Data", self.nbtpage)
self.pages.show_page(self.nbtpage)
#elif self.selectedPlayer.isNew:
else:
alert(_("Error while getting player file.\n%s not found.")%(player + '.dat'), doNotTranslate=True)
示例6: update_side_panel
def update_side_panel(self, item):
if item == self.displayed_item:
return
self.displayed_item = item
if self.side_panel:
self.side_panel.set_parent(None)
items = [a for a in item[1]]
rows = []
if config.nbtTreeSettings.showAllTags.get():
meth = None
else:
meth = getattr(self, "build_%s" % item[3].lower(), None)
col = True
if meth and len(items) == 1:
rows = meth(items)
else:
height = 0
for itm in items:
t = itm.__class__.__name__
rows.append(Row([Label("Data Type:"), Label(t)], margin=1))
fields = self.build_field(itm)
for field in fields:
if type(field) == TextFieldWrapped:
field.set_size_for_text(self.side_panel_width)
row = Row([field], margin=1)
rows.append(row)
height += row.height
if height > self.displayRow.height:
col = False
if rows:
if col:
col = Column(rows, align="l", spacing=0, height=self.displayRow.height)
else:
col = ScrollPanel(
rows=rows,
align="l",
spacing=0,
height=self.displayRow.height,
draw_zebra=False,
inner_width=self.side_panel_width - scroll_button_size,
)
col.set_parent(self.displayRow)
col.top = self.displayRow.top
col.left = self.displayRow.subwidgets[0].right
col.bottom = self.displayRow.subwidgets[0].bottom
col.shrink_wrap()
self.side_panel = col
示例7: __init__
def __init__(self, tool):
Panel.__init__(self, name='Panel.PlayerPositionPanel')
self.tool = tool
self.player_UUID = {"UUID": [], "Name": []}
self.level = tool.editor.level
self.playercache = PlayerCache()
# Add this instance to PlayerCache 'targets'. PlayerCache generated processes will call
# this instance 'update_player' method when they have finished their execution.
self.playercache.add_target(self.update_player)
if hasattr(self.level, 'players'):
players = self.level.players or ["[No players]"]
if not self.level.oldPlayerFolderFormat:
for player in players:
if player != "Player" and player != "[No players]":
if len(player) > 4 and player[4] == "-":
os.rename(os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player+".dat"), os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player.replace("-", "", 1)+".dat"))
player = player.replace("-", "", 1)
# print 5
data = self.playercache.getPlayerInfo(player, use_old_data=True)
#self.player_UUID[data[0]] = data[1]
self.player_UUID["UUID"].append(data[0])
self.player_UUID["Name"].append(data[1])
#self.player_UUID[player] = data
if "Player" in players:
#self.player_UUID["Player (Single Player)"] = "Player"
self.player_UUID["UUID"].append("Player")
self.player_UUID["Name"].append("Player (Single Player)")
if "[No players]" not in players:
self.player_names = sorted(self.player_UUID.values(), key=lambda x: False if x == "Player (Single Player)" else x)
else:
self.player_UUID["UUID"].append("[No players]")
self.player_UUID["Name"].append("[No players]")
else:
players = ["Player (Single Player)"]
self.players = players
if 'Player' in self.player_UUID['UUID'] and 'Player (Single Player)' in self.player_UUID['Name']:
self.player_UUID['UUID'].insert(0, self.player_UUID['UUID'].pop(self.player_UUID['UUID'].index('Player')))
self.player_UUID['Name'].insert(0, self.player_UUID['Name'].pop(self.player_UUID['Name'].index('Player (Single Player)')))
self.pages = TabPanel()
tab_height = self.pages.tab_height
max_height = tab_height + self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[0].height - self.pages.margin * 2
#-# Uncomment the following line to have a maximum height for this panel.
# max_height = min(max_height, 500)
self.editNBTDataButton = Button("Edit NBT", action=self.editNBTData, tooltipText="Open the NBT Explorer to edit player's attributes and inventory")
addButton = Button("Add", action=self.tool.addPlayer)
removeButton = Button("Remove", action=self.tool.removePlayer)
gotoButton = Button("Goto", action=self.tool.gotoPlayer)
gotoCameraButton = Button("Goto View", action=self.tool.gotoPlayerCamera)
moveButton = Button("Move", action=self.tool.movePlayer)
moveToCameraButton = Button("Align to Camera", action=self.tool.movePlayerToCamera)
reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")
btns = [self.editNBTDataButton]
if not isinstance(self.level, pymclevel.leveldbpocket.PocketLeveldbWorld):
btns.extend([addButton, removeButton])
btns.extend([gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin])
btns = Column(btns, margin=0, spacing=2)
h = max_height - btns.height - self.pages.margin * 2 - 2 - self.font.get_linesize() * 2
col = Label('')
def close():
self.pages.show_page(col)
self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject={}, height=max_height, \
close_text="Go Back", no_header=True, close_action=close,
load_text=None)
self.nbttree.shrink_wrap()
self.nbtpage = Column([self.nbttree])
self.nbtpage.shrink_wrap()
self.pages.add_page("NBT Data", self.nbtpage)
self.pages.set_rect(map(lambda x:x+self.margin, self.nbttree._rect))
tableview = TableView(nrows=(h - (self.font.get_linesize() * 2.5)) / self.font.get_linesize(),
header_height=self.font.get_linesize(),
columns=[TableColumn("Player Name(s):", (self.nbttree.width - (self.margin * 3)) / 3),
TableColumn("Player UUID(s):", (self.nbttree.width - (self.margin * 3)))],
)
tableview.index = 0
tableview.num_rows = lambda: len(self.player_UUID["UUID"])
tableview.row_data = lambda i: (self.player_UUID["Name"][i],self.player_UUID["UUID"][i])
tableview.row_is_selected = lambda x: x == tableview.index
tableview.zebra_color = (0, 0, 0, 48)
def selectTableRow(i, evt):
tableview.index = i
tableview.click_row = selectTableRow
def mouse_down(e):
if e.button == 1 and e.num_clicks > 1:
self.editNBTData()
TableRowView.mouse_down(tableview.rows, e)
#.........这里部分代码省略.........
示例8: GeneratorPanel
def GeneratorPanel():
panel = Widget()
panel.chunkHeight = 64
panel.grass = True
panel.simulate = False
panel.snapshot = False
jarStorage = MCServerChunkGenerator.getDefaultJarStorage()
if jarStorage:
jarStorage.reloadVersions()
generatorChoice = ChoiceButton(["Minecraft Server", "Flatland"])
panel.generatorChoice = generatorChoice
col = [Row((Label("Generator:"), generatorChoice))]
noVersionsRow = Label("Will automatically download and use the latest version")
versionContainer = Widget()
heightinput = IntInputRow("Height: ", ref=AttrRef(panel, "chunkHeight"), min=0, max=255)
grassinput = CheckBoxLabel("Grass", ref=AttrRef(panel, "grass"))
flatPanel = Column([heightinput, grassinput], align="l")
def generatorChoiceChanged():
serverPanel.visible = generatorChoice.selectedChoice == "Minecraft Server"
flatPanel.visible = not serverPanel.visible
generatorChoice.choose = generatorChoiceChanged
versionChoice = None
if len(jarStorage.versions):
def checkForUpdates():
def _check():
yield
jarStorage.downloadCurrentServer(panel.snapshot)
yield
showProgress("Checking for server updates...", _check())
versionChoice.choices = sorted(jarStorage.versions, reverse=True)
versionChoice.choiceIndex = 0
versionChoice = ChoiceButton(sorted(jarStorage.versions, reverse=True))
versionChoice.set_size_for_text(200)
versionChoiceRow = (Row((
Label("Server version:"),
versionChoice,
Label("or"),
Button("Check for Updates", action=checkForUpdates))))
panel.versionChoice = versionChoice
versionContainer.add(versionChoiceRow)
else:
versionContainer.add(noVersionsRow)
versionContainer.shrink_wrap()
menu = Menu("Advanced", [
("Open Server Storage", "revealStorage"),
("Reveal World Cache", "revealCache"),
("Delete World Cache", "clearCache")
])
def presentMenu():
i = menu.present(advancedButton.parent, advancedButton.topleft)
if i != -1:
(revealStorage, revealCache, clearCache)[i]()
advancedButton = Button("Advanced...", presentMenu)
@alertException
def revealStorage():
mcplatform.platform_open(jarStorage.cacheDir)
@alertException
def revealCache():
mcplatform.platform_open(MCServerChunkGenerator.worldCacheDir)
# revealCacheRow = Row((Label("Minecraft Server Storage: "), Button("Open Folder", action=revealCache, tooltipText="Click me to install your own minecraft_server.jar if you have any.")))
@alertException
def clearCache():
MCServerChunkGenerator.clearWorldCache()
simRow = CheckBoxLabel("Simulate world", ref=AttrRef(panel, "simulate"),
tooltipText="Simulate the world for a few seconds after generating it. Reduces the save file size by processing all of the TileTicks.")
useSnapshotServer = CheckBoxLabel("Use snapshot versions", ref=AttrRef(panel, "snapshot"),
tooltipText="Uses the Latest Snapshot Terrain Generation")
simRow = Row((simRow, advancedButton), anchor="lrh")
#deleteCacheRow = Row((Label("Delete Temporary World File Cache?"), Button("Delete Cache!", action=clearCache, tooltipText="Click me if you think your chunks are stale.")))
serverPanel = Column([useSnapshotServer, versionContainer, simRow], align="l")
col.append(serverPanel)
col = Column(col, align="l")
col.add(flatPanel)
flatPanel.topleft = serverPanel.topleft
flatPanel.visible = False
panel.add(col)
panel.shrink_wrap()
#.........这里部分代码省略.........
示例9: __init__
def __init__(self, tool):
Panel.__init__(self)
self.tool = tool
self.player_UUID = {}
self.level = tool.editor.level
if hasattr(self.level, 'players'):
players = self.level.players or ["[No players]"]
if not self.level.oldPlayerFolderFormat:
for player in players:
if player != "Player" and player != "[No players]":
if len(player) > 4 and player[4] == "-":
os.rename(os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player+".dat"), os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player.replace("-", "", 1)+".dat"))
player = player.replace("-", "", 1)
data = version_utils.playercache.getPlayerInfo(player)
if isinstance(data, tuple):
self.player_UUID[data[1]] = data[0]
else:
self.player_UUID[player] = data
if "Player" in players:
self.player_UUID["Player (Single Player)"] = "Player"
if "[No players]" not in players:
players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player (Single Player)" else x)
else:
players = ["Player (Single Player)"]
self.players = players
self.pages = TabPanel()
tab_height = self.pages.tab_height
max_height = tab_height + self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[0].height - self.pages.margin * 2
#-# Uncomment the following line to have a maximum height for this panel.
# max_height = min(max_height, 500)
self.editNBTDataButton = Button("Edit NBT", action=self.editNBTData, tooltipText="Open the NBT Explorer to edit player's attributes and inventory")
addButton = Button("Add", action=self.tool.addPlayer)
removeButton = Button("Remove", action=self.tool.removePlayer)
gotoButton = Button("Goto", action=self.tool.gotoPlayer)
gotoCameraButton = Button("Goto View", action=self.tool.gotoPlayerCamera)
moveButton = Button("Move", action=self.tool.movePlayer)
moveToCameraButton = Button("Align to Camera", action=self.tool.movePlayerToCamera)
reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")
btns = Column([self.editNBTDataButton, addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin], margin=0, spacing=2)
h = max_height - btns.height - self.pages.margin * 2 - 2 - self.font.get_linesize() * 2
col = Label('')
def close():
self.pages.show_page(col)
self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject={}, height=max_height, \
close_text="Go Back", no_header=True, close_action=close,
load_text=None)
self.nbttree.shrink_wrap()
self.nbtpage = Column([self.nbttree,])
self.nbtpage.shrink_wrap()
self.pages.add_page("NBT Data", self.nbtpage)
self.pages.set_rect(map(lambda x:x+self.margin, self.nbttree._rect))
tableview = TableView(nrows=(h - (self.font.get_linesize() * 2.5)) / self.font.get_linesize(),
header_height=self.font.get_linesize(),
columns=[TableColumn("Player Name(s):", self.nbttree.width - (self.margin * 3)),],
)
tableview.index = 0
tableview.num_rows = lambda: len(players)
tableview.row_data = lambda i: (players[i],)
tableview.row_is_selected = lambda x: x == tableview.index
tableview.zebra_color = (0, 0, 0, 48)
def selectTableRow(i, evt):
tableview.index = i
tableview.click_row = selectTableRow
def mouse_down(e):
if e.button == 1 and e.num_clicks > 1:
self.editNBTData()
TableRowView.mouse_down(tableview.rows, e)
tableview.rows.mouse_down = mouse_down
tableview.rows.tooltipText = "Double-click or use the button below to edit the NBT Data."
self.table = tableview
col.set_parent(None)
self.col = col = Column([tableview, btns], spacing=2)
self.pages.add_page("Players", col, 0)
self.pages.shrink_wrap()
self.pages.show_page(col)
self.add(self.pages)
self.shrink_wrap()
self.max_height = max_height
示例10: __init__old
def __init__old(self, blockInfo, materials, *a, **kw):
self.root = get_root()
self.allowWildcards = False
Dialog.__init__(self, *a, **kw)
panelWidth = 518
self.click_outside_response = 0
self.materials = materials
self.anySubtype = blockInfo.wildcard
self.matchingBlocks = materials.allBlocks
try:
self.selectedBlockIndex = self.matchingBlocks.index(blockInfo)
except ValueError:
self.selectedBlockIndex = 0
for i, b in enumerate(self.matchingBlocks):
if blockInfo.ID == b.ID and blockInfo.blockData == b.blockData:
self.selectedBlockIndex = i
break
lbl = Label("Search")
# lbl.rect.topleft = (0,0)
fld = TextFieldWrapped(300)
# fld.rect.topleft = (100, 10)
# fld.centery = lbl.centery
# fld.left = lbl.right
fld.change_action = self.textEntered
fld.enter_action = self.ok
fld.escape_action = self.cancel
self.awesomeField = fld
searchRow = Row((lbl, fld))
def formatBlockName(x):
block = self.matchingBlocks[x]
r = "{name}".format(name=block.name)
if block.aka:
r += " [{0}]".format(block.aka)
return r
def formatBlockID(x):
block = self.matchingBlocks[x]
ident = "({id}:{data})".format(id=block.ID, data=block.blockData)
return ident
tableview = TableView(columns=[TableColumn(" ", 24, "l", lambda x: ""),
TableColumn("Name", 415, "l", formatBlockName),
TableColumn("ID", 45, "l", formatBlockID)
])
tableicons = [blockview.BlockView(materials) for i in range(tableview.rows.num_rows())]
for t in tableicons:
t.size = (16, 16)
t.margin = 0
icons = Column(tableicons, spacing=2)
# tableview.margin = 5
tableview.num_rows = lambda: len(self.matchingBlocks)
tableview.row_data = lambda x: (self.matchingBlocks[x], x, x)
tableview.row_is_selected = lambda x: x == self.selectedBlockIndex
tableview.click_row = self.selectTableRow
draw_table_cell = tableview.draw_table_cell
def draw_block_table_cell(surf, i, data, cell_rect, column):
if isinstance(data, Block):
tableicons[i - tableview.rows.scroll].blockInfo = data
else:
draw_table_cell(surf, i, data, cell_rect, column)
tableview.draw_table_cell = draw_block_table_cell
tableview.width = panelWidth
tableview.anchor = "lrbt"
# self.add(tableview)
self.tableview = tableview
tableWidget = Widget()
tableWidget.add(tableview)
tableWidget.shrink_wrap()
def wdraw(*args):
for t in tableicons:
t.blockInfo = materials.Air
tableWidget.draw = wdraw
self.blockButton = blockView = thumbview.BlockThumbView(materials, self.blockInfo)
blockView.centerx = self.centerx
blockView.top = tableview.bottom
# self.add(blockview)
but = Button("OK")
but.action = self.ok
but.top = blockView.bottom
but.centerx = self.centerx
but.align = "c"
#.........这里部分代码省略.........
示例11: PlayerPositionPanel
class PlayerPositionPanel(Panel):
def __init__(self, tool):
Panel.__init__(self)
self.tool = tool
self.player_UUID = {}
self.level = tool.editor.level
if hasattr(self.level, 'players'):
players = self.level.players or ["[No players]"]
if not self.level.oldPlayerFolderFormat:
for player in players:
if player != "Player" and player != "[No players]":
if len(player) > 4 and player[4] == "-":
os.rename(os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player+".dat"), os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player.replace("-", "", 1)+".dat"))
player = player.replace("-", "", 1)
data = version_utils.playercache.getPlayerInfo(player)
if isinstance(data, tuple):
self.player_UUID[data[1]] = data[0]
else:
self.player_UUID[player] = data
if "Player" in players:
self.player_UUID["Player (Single Player)"] = "Player"
if "[No players]" not in players:
players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player (Single Player)" else x)
else:
players = ["Player (Single Player)"]
self.players = players
self.pages = TabPanel()
tab_height = self.pages.tab_height
max_height = tab_height + self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[0].height - self.pages.margin * 2
#-# Uncomment the following line to have a maximum height for this panel.
# max_height = min(max_height, 500)
self.editNBTDataButton = Button("Edit NBT", action=self.editNBTData, tooltipText="Open the NBT Explorer to edit player's attributes and inventory")
addButton = Button("Add", action=self.tool.addPlayer)
removeButton = Button("Remove", action=self.tool.removePlayer)
gotoButton = Button("Goto", action=self.tool.gotoPlayer)
gotoCameraButton = Button("Goto View", action=self.tool.gotoPlayerCamera)
moveButton = Button("Move", action=self.tool.movePlayer)
moveToCameraButton = Button("Align to Camera", action=self.tool.movePlayerToCamera)
reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")
btns = Column([self.editNBTDataButton, addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin], margin=0, spacing=2)
h = max_height - btns.height - self.pages.margin * 2 - 2 - self.font.get_linesize() * 2
col = Label('')
def close():
self.pages.show_page(col)
self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject={}, height=max_height, \
close_text="Go Back", no_header=True, close_action=close,
load_text=None)
self.nbttree.shrink_wrap()
self.nbtpage = Column([self.nbttree,])
self.nbtpage.shrink_wrap()
self.pages.add_page("NBT Data", self.nbtpage)
self.pages.set_rect(map(lambda x:x+self.margin, self.nbttree._rect))
tableview = TableView(nrows=(h - (self.font.get_linesize() * 2.5)) / self.font.get_linesize(),
header_height=self.font.get_linesize(),
columns=[TableColumn("Player Name(s):", self.nbttree.width - (self.margin * 3)),],
)
tableview.index = 0
tableview.num_rows = lambda: len(players)
tableview.row_data = lambda i: (players[i],)
tableview.row_is_selected = lambda x: x == tableview.index
tableview.zebra_color = (0, 0, 0, 48)
def selectTableRow(i, evt):
tableview.index = i
tableview.click_row = selectTableRow
def mouse_down(e):
if e.button == 1 and e.num_clicks > 1:
self.editNBTData()
TableRowView.mouse_down(tableview.rows, e)
tableview.rows.mouse_down = mouse_down
tableview.rows.tooltipText = "Double-click or use the button below to edit the NBT Data."
self.table = tableview
col.set_parent(None)
self.col = col = Column([tableview, btns], spacing=2)
self.pages.add_page("Players", col, 0)
self.pages.shrink_wrap()
self.pages.show_page(col)
self.add(self.pages)
self.shrink_wrap()
self.max_height = max_height
def editNBTData(self):
player = self.selectedPlayer
if player == 'Player (Single Player)':
#.........这里部分代码省略.........