本文整理汇总了Python中albow.Widget.present方法的典型用法代码示例。如果您正苦于以下问题:Python Widget.present方法的具体用法?Python Widget.present怎么用?Python Widget.present使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类albow.Widget
的用法示例。
在下文中一共展示了Widget.present方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateFilters
# 需要导入模块: from albow import Widget [as 别名]
# 或者: from albow.Widget import present [as 别名]
def updateFilters(self):
totalFilters = 0
updatedFilters = 0
filtersDir = directories.getFiltersDir()
try:
os.mkdir(os.path.join(filtersDir, "updates"))
except OSError:
pass
for module in self.filterModules.values():
totalFilters += 1
if hasattr(module, "UPDATE_URL") and hasattr(module, "VERSION"):
if isinstance(module.UPDATE_URL, (str, unicode)) and isinstance(module.VERSION, (str, unicode)):
versionJSON = json.loads(urllib2.urlopen(module.UPDATE_URL).read())
if module.VERSION != versionJSON["Version"]:
urllib.urlretrieve(versionJSON["Download-URL"],
os.path.join(filtersDir, "updates", versionJSON["Name"]))
updatedFilters += 1
for f in os.listdir(os.path.join(filtersDir, "updates")):
shutil.copy(os.path.join(filtersDir, "updates", f), filtersDir)
shutil.rmtree(os.path.join(filtersDir, "updates"))
finishedUpdatingWidget = Widget()
lbl = Label("Updated %s filter(s) out of %s" % (updatedFilters, totalFilters))
closeBTN = Button("Close this message", action=finishedUpdatingWidget.dismiss)
col = Column((lbl, closeBTN))
finishedUpdatingWidget.bg_color = (0.0, 0.0, 0.6)
finishedUpdatingWidget.add(col)
finishedUpdatingWidget.shrink_wrap()
finishedUpdatingWidget.present()
示例2: FilterTool
# 需要导入模块: from albow import Widget [as 别名]
# 或者: from albow.Widget import present [as 别名]
class FilterTool(EditorTool):
tooltipText = "Filter"
toolIconName = "filter"
def __init__(self, editor):
EditorTool.__init__(self, editor)
self.filterModules = {}
self.panel = FilterToolPanel(self)
@property
def statusText(self):
return "Choose a filter, then click Filter or press ENTER to apply it."
def toolEnabled(self):
return not (self.selectionBox() is None)
def toolSelected(self):
self.showPanel()
@alertException
def showPanel(self):
if self.panel.parent:
self.editor.remove(self.panel)
self.reloadFilters()
# self.panel = FilterToolPanel(self)
self.panel.reload()
self.panel.midleft = self.editor.midleft
self.editor.add(self.panel)
self.updatePanel = Panel()
updateButton = Button("Update Filters", action=self.updateFilters)
self.updatePanel.add(updateButton)
self.updatePanel.shrink_wrap()
self.updatePanel.bottomleft = self.editor.viewportContainer.bottomleft
self.editor.add(self.updatePanel)
def hidePanel(self):
self.panel.saveOptions()
if self.panel.parent:
self.panel.parent.remove(self.panel)
self.updatePanel.parent.remove(self.updatePanel)
def updateFilters(self):
totalFilters = 0
updatedFilters = 0
try:
os.mkdir(mcplatform.filtersDir + "/updates")
except OSError:
pass
for module in self.filterModules.values():
totalFilters = totalFilters + 1
if hasattr(module, "UPDATE_URL") and hasattr(module, "VERSION"):
if isinstance(module.UPDATE_URL, (str, unicode)) and isinstance(module.VERSION, (str, unicode)):
versionJSON = json.loads(urllib2.urlopen(module.UPDATE_URL).read())
if module.VERSION != versionJSON["Version"]:
urllib.urlretrieve(versionJSON["Download-URL"],
mcplatform.filtersDir + "/updates/" + versionJSON["Name"])
updatedFilters = updatedFilters + 1
for f in os.listdir(mcplatform.filtersDir + "/updates"):
shutil.copy(mcplatform.filtersDir + "/updates/" + f, mcplatform.filtersDir)
shutil.rmtree(mcplatform.filtersDir + "/updates/")
self.finishedUpdatingWidget = Widget()
lbl = Label("Updated " + str(updatedFilters) + " filter(s) out of " + str(totalFilters))
closeBTN = Button("Close this message", action=self.closeFinishedUpdatingWidget)
col = Column((lbl, closeBTN))
self.finishedUpdatingWidget.bg_color = (0.0, 0.0, 0.6)
self.finishedUpdatingWidget.add(col)
self.finishedUpdatingWidget.shrink_wrap()
self.finishedUpdatingWidget.present()
def closeFinishedUpdatingWidget(self):
self.finishedUpdatingWidget.dismiss()
def reloadFilters(self):
filterDir = mcplatform.filtersDir
filterFiles = os.listdir(filterDir)
filterPyfiles = filter(lambda x: x.endswith(".py"), filterFiles)
def tryImport(name):
try:
return __import__(name)
except Exception, e:
print traceback.format_exc()
alert(_(u"Exception while importing filter module {}. See console for details.\n\n{}").format(name, e))
return object()
filterModules = (tryImport(x[:-3]) for x in filterPyfiles)
filterModules = filter(lambda module: hasattr(module, "perform"), filterModules)
self.filterModules = collections.OrderedDict(sorted((self.moduleDisplayName(x), x) for x in filterModules))
for m in self.filterModules.itervalues():
try:
reload(m)
#.........这里部分代码省略.........