本文整理汇总了Python中matrix.Matrix.tableAttr方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.tableAttr方法的具体用法?Python Matrix.tableAttr怎么用?Python Matrix.tableAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix.Matrix
的用法示例。
在下文中一共展示了Matrix.tableAttr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: minpath
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import tableAttr [as 别名]
def minpath(nrows) :
mat = Matrix(1,2)
tri = Matrix(nrows,nrows)
org = Matrix(nrows,nrows)
for r in range(nrows) :
vals = [randint(1,9) for c in range(r+1)]
tri.setrowVals(r,vals)
org.setrowVals(r,vals)
org.title = "Original Values"
mat[0,0] = renderTriangle(org)
mat.tableAttr='border="1" cellspacing="0" cellpadding="4"'
tri.style.setrowVal(nrows-1,"background-color:lightgreen")
for row in range(nrows-2,-1,-1) :
for col in range(row+1) :
left = tri[row+1,col]
right= tri[row+1,col+1]
this = tri[row,col]
tri.style[row,col] = "background-color:pink"
tri.title = "Set to min(%s+%s, %s+%s)" % (this,left,this,right)
mat[0,1] = renderTriangle(tri)
htmlPage.item1 = mat.renderHtml()
htmlPage.makeFrame() #break
tri[row,col] = best = min(this+left,this+right)
tri.style[row,col] = "background-color:lightgreen"
mat[0,1] = renderTriangle(tri)
htmlPage.item1 = mat.renderHtml()
htmlPage.banner = "Miniumum cost is %s" % best
htmlPage.makeFrame() #break
示例2: HtmlFrame
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import tableAttr [as 别名]
# o p t F i b . p y
#
# Chris Meyers. 10/26/2013
#
from htmlFrame import HtmlFrame
from matrix import Matrix
htmlPage = HtmlFrame()
htmlPage.banner = "Animated Fibonacci Sequence"
BOLD = "color:red;font-weight:bold;"
fibs = Matrix(1,20)
fibs.tableAttr = 'cellspacing="0" cellpadding="10"'
fibs[0,0] = 1
fibs[0,1] = 1
for i in range(2,100) :
fibs.style[0,i-1] = BOLD
fibs.style[0,i-2] = BOLD
fibs[0,i] = fibs[0,i-1]+fibs[0,i-2]
fibs.title = "Last 2 elements add for new one"
htmlPage.item1 = fibs.renderHtml(wrap=10)
htmlPage.makeFrame() #break
fibs.style[0,i-2] = "" # uncolor behind
示例3: HtmlFrame
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import tableAttr [as 别名]
from htmlFrame import HtmlFrame
from matrix import Matrix
maxwgt = 10
vals = [0,10,40,30,50]
wgts = [0, 5, 4, 6, 3]
htmlPage = HtmlFrame()
htmlPage.banner = "Knapsack Problem"
headers=['wt'+str(i) for i in range(maxwgt+1)]
inp = Matrix(len(vals),3)
inp.title = "Sack holds weight %s" % maxwgt
inp.dftFormat = "<pre>%03s</pre>"
inp.tableAttr = 'border="1" cellspacing="0" cellpadding="4"',
inp.tableHeaders=['Item #','Weight','Value']
for i in range(len(vals)) :
inp.setrowVals(i, [i, wgts[i], vals[i]])
frame = Matrix(1,2)
frame[0,0] = inp.renderHtml()
nItems = len(vals)
best = Matrix(nItems,maxwgt+1)
best.dftFormat = "<pre>%03s</pre>"
for i in range(1,nItems) :
best.setrowVal(i,0)
for i in range(1,nItems) :
for w in range(0,maxwgt+1) :
remBest = best[i-1,w-wgts[i]]