[gen] Better rendering of buttons; added a new utility function for formatting elements like phone numbers.
This commit is contained in:
parent
cf946e3222
commit
3b18619624
|
@ -1365,11 +1365,7 @@ class ToolMixin(BaseMixin):
|
|||
def getButtonWidth(self, label):
|
||||
'''Determine button width, in pixels, corresponding to the button
|
||||
p_label.'''
|
||||
l = len(label)
|
||||
if l < 10:
|
||||
width = '130px'
|
||||
else:
|
||||
# Consider 1 char = 6 pixels wide.
|
||||
width = '%dpx' % (130 + ((l-10)*4))
|
||||
return 'width:%s' % width
|
||||
# Set a minimum width for small labels.
|
||||
if len(label) < 15: return 'width:130px'
|
||||
return 'padding-left: 26px; padding-right: 8px'
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -57,10 +57,10 @@ img { border: 0; vertical-align: middle }
|
|||
.userStrip a:visited { color: #e7e7e7 }
|
||||
.breadcrumb { font-size: 11pt; padding-bottom: 6px }
|
||||
.login { margin: 3px; color: black }
|
||||
input.button { color: #666666; height: 20px; width: 130px; margin-bottom: 5px;
|
||||
input.button { color: #666666; height: 20px; margin-bottom: 5px;
|
||||
cursor:pointer; font-size: 90%; padding-left: 10px;
|
||||
background-color: white; background-repeat: no-repeat;
|
||||
background-position: 5% 25%; box-shadow: 2px 2px 2px #888888}
|
||||
background-position: 8px 25%; box-shadow: 2px 2px 2px #888888}
|
||||
input.buttonSmall { width: 100px !important; font-size: 85%; height: 18px;
|
||||
margin-bottom: 3px}
|
||||
.fake { background-color: #e6e6e6 !important ; cursor:help !important }
|
||||
|
|
|
@ -269,6 +269,20 @@ def getStringDict(d):
|
|||
res.append(value)
|
||||
return '{%s}' % ','.join(res)
|
||||
|
||||
def stretchText(s, pattern, char=' '):
|
||||
'''Inserts occurrences of p_char within p_s according to p_pattern.
|
||||
Example: stretchText("475123456", (3,2,2,2)) returns '475 12 34 56'.'''
|
||||
res = ''
|
||||
i = 0
|
||||
for nb in pattern:
|
||||
j = 0
|
||||
while j < nb:
|
||||
res += s[i+j]
|
||||
j += 1
|
||||
res += char
|
||||
i += nb
|
||||
return res
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
def formatNumber(n, sep=',', precision=2, tsep=' '):
|
||||
'''Returns a string representation of number p_n, which can be a float
|
||||
|
|
Loading…
Reference in a new issue