from ipy_table import *
array = [[0, 1, 2], [3, 4]]
try:
t = IpyTable(array)
except ValueError:
print 'Pass'
else:
print 'Fail'
Pass
array = [[0, 1], [2, 3]]
t = IpyTable(array)
try:
t.set_cell_style(2, 0, color='red')
except ValueError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (Bad row (2). Expected row in range 0 to 1.)
array = [[0, 1], [2, 3]]
t = IpyTable(array)
try:
t.apply_theme("monty")
except ValueError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (Unknown theme "monty". Expected one of ['basic', 'basic_left', 'basic_both'].)
import random
import string
import ipy_table as ipt
width = randint(1,6)
height = randint(1,6)
array = [[None for column in range(width)] for row in range(height)]
for row in range(height):
for column in range(width):
array[row][column] = random.choice([
random.random()*1000000,
''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(randint(1,14))),
randint(1000000)])
make_table(array)
for i in range(20):
row = randint(height)
column = randint(width)
style = random.choice(['color', 'bold', 'thick_border', 'no_border'])
if style == 'color':
set_cell_style(row, column, color=random.choice(['red', 'blue', 'green']))
elif style == 'bold':
set_cell_style(row, column, bold=True)
elif style == 'thick_border':
set_cell_style(row, column, thick_border=random.choice(['left', 'right', 'top', 'bottom']))
elif style == 'no_border':
set_cell_style(row, column, no_border=random.choice(['left', 'right', 'top', 'bottom']))
ipt._TABLE.render() # Force a redraw
472523 | 529177 | Y | 494471.0204 |
O | 573968.9821 | NM | XBHKKUD3DO0 |
560447.7154 | 910446.0199 | 681877 | 82173.5150 |