本文整理汇总了Python中albow.Widget.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Widget.draw方法的具体用法?Python Widget.draw怎么用?Python Widget.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类albow.Widget
的用法示例。
在下文中一共展示了Widget.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from albow import Widget [as 别名]
# 或者: from albow.Widget import draw [as 别名]
def draw(self, surface):
if self.root is None:
self.root = self.get_root()
Widget.draw(self, surface)
frameStart = datetime.now()
frameInterval = timedelta(0, 1, 0) / 2
amount = None
try:
while datetime.now() < frameStart + frameInterval:
amount = progressIterator.next()
if self.firstDraw is False:
self.firstDraw = True
break
except StopIteration:
self.dismiss()
infoText = ""
if amount is not None:
if isinstance(amount, tuple):
if len(amount) > 2:
infoText = ": " + amount[2]
amount, max = amount[:2]
else:
max = amount
maxwidth = (self.width - self.margin * 2)
if amount is None:
self.progressBar.width = maxwidth
self.progressBar.bg_color = (255, 255, 25, 255)
elif isinstance(amount, basestring):
self.statusText = amount
else:
self.progressAmount = amount
if isinstance(amount, (int, float)):
self.progressFraction = float(amount) / (float(max) or 1)
self.progressBar.width = maxwidth * self.progressFraction
self.statusText = str("{0} / {1}".format(amount, max))
else:
self.statusText = str(amount)
if infoText:
self.statusText += infoText
示例2: __init__old
# 需要导入模块: from albow import Widget [as 别名]
# 或者: from albow.Widget import draw [as 别名]
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"
#.........这里部分代码省略.........