本文整理汇总了Python中mceutils.showProgress函数的典型用法代码示例。如果您正苦于以下问题:Python showProgress函数的具体用法?Python showProgress怎么用?Python showProgress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showProgress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extractUndoChunks
def extractUndoChunks(self, level, chunks, chunkCount = None):
if not isinstance(level, pymclevel.MCInfdevOldLevel):
chunks = numpy.array(list(chunks))
mincx, mincz = numpy.min(chunks, 0)
maxcx, maxcz = numpy.max(chunks, 0)
box = BoundingBox((mincx << 4, 0, mincz << 4), (maxcx << 4, level.Height, maxcz << 4))
return self.extractUndoSchematic(level, box)
undoLevel = pymclevel.MCInfdevOldLevel(mkundotemp(), create=True)
if not chunkCount:
try:
chunkCount = len(chunks)
except TypeError:
chunkCount = -1
def _extractUndo():
yield 0, 0, "Recording undo..."
for i, (cx, cz) in enumerate(chunks):
undoLevel.copyChunkFrom(level, cx, cz)
yield i, chunkCount, "Copying chunk %s..." % ((cx, cz),)
undoLevel.saveInPlace()
if chunkCount > 25 or chunkCount < 1:
showProgress("Recording undo...", _extractUndo())
else:
exhaust(_extractUndo())
return undoLevel
示例2: undo
def undo(self):
""" Undo the operation. Ought to leave the Operation in a state where it can be performed again.
Default implementation copies all chunks in undoLevel back into level. Non-chunk-based operations
should override this."""
if self.undoLevel:
self.redoLevel = self.extractUndo(self.level, self.dirtyBox())
def _undo():
yield 0, 0, "Undoing..."
if hasattr(self.level, 'copyChunkFrom'):
for i, (cx, cz) in enumerate(self.undoLevel.allChunks):
self.level.copyChunkFrom(self.undoLevel, cx, cz)
yield i, self.undoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
else:
for i in self.level.copyBlocksFromIter(self.undoLevel, self.undoLevel.bounds,
self.undoLevel.sourcePoint, biomes=True):
yield i, self.undoLevel.chunkCount, "Copying..."
if self.undoLevel.chunkCount > 25:
showProgress("Undoing...", _undo())
else:
exhaust(_undo())
self.editor.invalidateChunks(self.undoLevel.allChunks)
示例3: checkForUpdates
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
示例4: perform
def perform(self, recordUndo=True):
if recordUndo:
self.undoLevel = self.extractUndo(self.level, self.destBox)
destBox = self.destBox
if self.level.bounds == self.destBox:
destBox = None
fill = self.level.fillBlocksIter(destBox, self.blockInfo, blocksToReplace=self.blocksToReplace)
showProgress("Replacing blocks...", fill, cancel=True)
示例5: relightChunks
def relightChunks(self):
def _relightChunks():
for i in self.editor.level.generateLightsIter(self.selectedChunks()):
yield i
with setWindowCaption("RELIGHTING - "):
showProgress(_("Lighting {0} chunks...").format(len(self.selectedChunks())),
_relightChunks(), cancel=True)
self.editor.invalidateChunks(self.selectedChunks())
self.editor.addUnsavedEdit()
示例6: perform
def perform(self, recordUndo=True):
if self.level.saving:
alert(_("Cannot perform action while saving is taking place"))
return
if recordUndo:
self.undoLevel = self.extractUndo(self.level, self.destBox)
destBox = self.destBox
if self.level.bounds == self.destBox:
destBox = None
fill = self.level.fillBlocksIter(destBox, self.blockInfo, blocksToReplace=self.blocksToReplace)
showProgress("Replacing blocks...", fill, cancel=True)
示例7: redo
def redo(self):
if self.redoLevel:
def _redo():
yield 0, 0, "Redoing..."
if hasattr(self.level, 'copyChunkFrom'):
for i, (cx, cz) in enumerate(self.redoLevel.allChunks):
self.level.copyChunkFrom(self.redoLevel, cx, cz)
yield i, self.redoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
else:
for i in self.level.copyBlocksFromIter(self.redoLevel, self.redoLevel.bounds,
self.redoLevel.sourcePoint, biomes=True):
yield i, self.undoLevel.chunkCount, "Copying..."
if self.redoLevel.chunkCount > 25:
showProgress("Redoing...", _redo())
else:
exhaust(_redo())
示例8: undo
def undo(self):
""" Undo the operation. Ought to leave the Operation in a state where it can be performed again.
Default implementation copies all chunks in undoLevel back into level. Non-chunk-based operations
should override this."""
if self.undoLevel:
def _undo():
yield 0, 0, "Undoing..."
for i, (cx, cz) in enumerate(self.undoLevel.allChunks):
self.level.copyChunkFrom(self.undoLevel, cx, cz)
yield i, self.undoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
if self.undoLevel.chunkCount > 25:
showProgress("Undoing...", _undo())
else:
exhaust(_undo())
self.editor.invalidateChunks(self.undoLevel.allChunks)
示例9: createChunks
def createChunks(self):
panel = GeneratorPanel()
col = [panel]
label = Label("Create chunks using the settings above? This cannot be undone.")
col.append(Row([Label("")]))
col.append(label)
col = Column(col)
if Dialog(client=col, responses=["OK", "Cancel"]).present() == "Cancel":
return
chunks = self.selectedChunks()
createChunks = panel.generate(self.editor.level, chunks)
try:
with setWindowCaption("CREATING - "):
showProgress("Creating {0} chunks...".format(len(chunks)), createChunks, cancel=True)
except Exception, e:
traceback.print_exc()
alert(_("Failed to start the chunk generator. {0!r}").format(e))
示例10: perform
def perform(level, box, options):
global GlobalLevel
GlobalLevel = level
filePath = options["Convert"]
if filePath == "n/a":
try:
filePath = askOpenFile("Select *.txt or *.docx file to convert to Book...", defaults=False, suffixes=["txt", "docx"])
except:
try:
openFile = win32ui.CreateFileDialog(1, None, None, 0, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Word Files (*.docx)|*.docx|")
openFile.DoModal()
filePath = openFile.GetPathName()
except:
raise Exception("win32ui could not be imported! Please enter the file path manually.")
fileName = filePath
while "/" in fileName:
fileName = fileName[fileName.find("/")+1:]
fileExtension = fileName[fileName.find(".")+1:]
if options["as the book title"]:
bookTitle = options["Use"]
else:
bookTitle = fileName
if options["Use the file name"] == "with extension":
bookTitle += "." + fileExtension
if filePath is None or fileName == "":
raise Exception("Please select a file!")
mceutils.showProgress("Generating Book", progressIter())
totalText = decodeFile(filePath, fileExtension, options)
makeBook(level, box, options, totalText, bookTitle)
示例11: extractUndoSchematic
def extractUndoSchematic(self, level, box):
if box.volume > 131072:
sch = showProgress("Recording undo...", level.extractZipSchematicIter(box), cancel=True)
else:
sch = level.extractZipSchematic(box)
if sch == "Cancel":
raise Cancel
if sch:
sch.sourcePoint = box.origin
return sch
示例12: perform
def perform(self, recordUndo=True):
sourceBox = self.sourceBox
if recordUndo:
self.undoLevel = self.extractUndo(self.level, BoundingBox(self.destPoint, self.sourceBox.size))
blocksToCopy = None
if not (self.copyAir and self.copyWater):
blocksToCopy = range(pymclevel.materials.id_limit)
if not self.copyAir:
blocksToCopy.remove(0)
if not self.copyWater:
blocksToCopy.remove(8)
if not self.copyWater:
blocksToCopy.remove(9)
with setWindowCaption("Copying - "):
i = self.level.copyBlocksFromIter(self.sourceLevel, self.sourceBox, self.destPoint, blocksToCopy,
create=True, biomes=self.copyBiomes, staticCommands=self.staticCommands, first=False)
showProgress(_("Copying {0:n} blocks...").format(self.sourceBox.volume), i)
示例13: perform
def perform(self, recordUndo=True):
sourceBox = self.sourceBox
if recordUndo:
self.undoLevel = self.extractUndo(self.level, BoundingBox(self.destPoint, self.sourceBox.size))
blocksToCopy = None
if not (self.copyAir and self.copyWater):
blocksToCopy = range(256)
if not self.copyAir:
blocksToCopy.remove(0)
if not self.copyWater:
blocksToCopy.remove(8)
if not self.copyWater:
blocksToCopy.remove(9)
with setWindowCaption("Copying - "):
i = self.level.copyBlocksFromIter(self.sourceLevel, self.sourceBox, self.destPoint, blocksToCopy, create=True)
showProgress("Copying {0:n} blocks...".format(self.sourceBox.volume), i)
示例14: extractUndoChunks
def extractUndoChunks(self, level, chunks, chunkCount = None):
undoLevel = pymclevel.MCInfdevOldLevel(mkundotemp(), create=True)
if not chunkCount:
try:
chunkCount = len(chunks)
except TypeError:
chunkCount = -1
def _extractUndo():
yield 0, 0, "Recording undo..."
for i, (cx, cz) in enumerate(chunks):
undoLevel.copyChunkFrom(level, cx, cz)
yield i, chunkCount, "Copying chunk %s..." % ((cx, cz),)
undoLevel.saveInPlace()
if chunkCount > 25 or chunkCount < 1:
showProgress("Recording undo...", _extractUndo())
else:
exhaust(_extractUndo())
return undoLevel
示例15: deleteFromWorld
def deleteFromWorld():
i = chestWidget.selectedItemIndex
item = tileEntityTag["Items"][i]
id = item["id"].value
Damage = item["Damage"].value
deleteSameDamage = mceutils.CheckBoxLabel("Only delete items with the same damage value")
deleteBlocksToo = mceutils.CheckBoxLabel("Also delete blocks placed in the world")
if id not in (8, 9, 10, 11): # fluid blocks
deleteBlocksToo.value = True
w = wrapped_label(
"WARNING: You are about to modify the entire world. This cannot be undone. Really delete all copies of this item from all land, chests, furnaces, dispensers, dropped items, item-containing tiles, and player inventories in this world?",
60)
col = (w, deleteSameDamage)
if id < 256:
col += (deleteBlocksToo,)
d = Dialog(Column(col), ["OK", "Cancel"])
if d.present() == "OK":
def deleteItemsIter():
i = 0
if deleteSameDamage.value:
def matches(t):
return t["id"].value == id and t["Damage"].value == Damage
else:
def matches(t):
return t["id"].value == id
def matches_itementity(e):
if e["id"].value != "Item":
return False
if "Item" not in e:
return False
t = e["Item"]
return matches(t)
for player in self.editor.level.players:
tag = self.editor.level.getPlayerTag(player)
l = len(tag["Inventory"])
tag["Inventory"].value = [t for t in tag["Inventory"].value if not matches(t)]
for chunk in self.editor.level.getChunks():
if id < 256 and deleteBlocksToo.value:
matchingBlocks = chunk.Blocks == id
if deleteSameDamage.value:
matchingBlocks &= chunk.Data == Damage
if any(matchingBlocks):
chunk.Blocks[matchingBlocks] = 0
chunk.Data[matchingBlocks] = 0
chunk.chunkChanged()
self.editor.invalidateChunks([chunk.chunkPosition])
for te in chunk.TileEntities:
if "Items" in te:
l = len(te["Items"])
te["Items"].value = [t for t in te["Items"].value if not matches(t)]
if l != len(te["Items"]):
chunk.dirty = True
entities = [e for e in chunk.Entities if matches_itementity(e)]
if len(entities) != len(chunk.Entities):
chunk.Entities.value = entities
chunk.dirty = True
yield (i, self.editor.level.chunkCount)
i += 1
progressInfo = _("Deleting the item {0} from the entire world ({1} chunks)").format(
itemName(chestWidget.id, 0), self.editor.level.chunkCount)
mceutils.showProgress(progressInfo, deleteItemsIter(), cancel=True)
self.editor.addUnsavedEdit()
chestWidget.selectedItemIndex = min(chestWidget.selectedItemIndex, len(tileEntityTag["Items"]) - 1)