本文整理汇总了Python中gluon.DIV类的典型用法代码示例。如果您正苦于以下问题:Python DIV类的具体用法?Python DIV怎么用?Python DIV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DIV类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_row
def render_row(row_id, label, widget, comment, hidden=False):
if hasattr(widget, "element"):
submit = widget.element("input", _type="submit")
if submit:
submit.add_class("small primary button")
controls_width = "medium-12" if label is False else "medium-10"
controls_col = DIV(widget, _class="%s columns controls" % controls_width)
if label:
if isinstance(label, LABEL):
label.add_class("left inline")
label_col = DIV(label, _class="medium-2 columns")
else:
if label is not False:
controls_col.add_class("medium-offset-2")
label_col = ""
if comment:
comment = render_tooltip(label,
comment,
_class="inline-tooltip tooltip",
)
if hasattr(comment, "add_class"):
comment.add_class("inline-tooltip")
controls_col.append(comment)
_class = "form-row row hide" if hidden else "form-row row"
return DIV(label_col, controls_col, _class=_class, _id=row_id)
示例2: selector
def selector(rules):
"""
Generate the rule selector for anonymize-form
@param rules: the list of configured rules
@return: the selector (DIV)
"""
T = current.T
selector = DIV(_class="anonymize-select")
for rule in rules:
name = rule.get("name")
if not name:
continue
title = T(rule.get("title", name))
selector.append(DIV(INPUT(value = "on",
_name = s3_str(name),
_type = "checkbox",
_class = "anonymize-rule",
),
LABEL(title),
_class = "anonymize-option",
))
return selector
示例3: Leyenda
class Leyenda(DIV):
def __init__(self, *components, **attributes):
out_body = DIV(components, _class="panel-body")
self.my_body = DIV(_class="btn-group", _role="group")
out_body.append(self.my_body)
out_body.append(XML('''
<script>
$(function () {
$('[data-toggle="popover"]').popover()
})
</script>'''))
attributes['_class'] = 'panel panel-default'
super(Leyenda, self).__init__(out_body, **attributes)
def append(self, titulo, valores, direccion="bottom"):
co = CAT(titulo,
SPAN(**{'_class': 'glyphicon glyphicon-question-sign',
'_aria-hidden': 'true'}))
item = A(co,
**{'_type': 'button',
'_role': 'button',
'_tabindex': '0',
'_class': 'btn btn-default btn-xs',
'_data-container': 'body',
'_data-toggle': 'popover',
'_data-placement': direccion,
'_data-trigger': 'focus',
'_data-content': reduce(
lambda x, y: x + ' ({0}){1}'.format(y[0], y[1]),
valores.iteritems(), '')})
self.my_body.append(item)
示例4: serialize
def serialize(self, data):
div = DIV(**self.attributes)
for item in data[:-1]:
(link, name) = item
a = A(name, _href=link, _class=self['a_class'])
div.append(a)
div.append(data[-1][1])
return div
示例5: mavc_rheader
def mavc_rheader(r, tabs=None):
""" Custom rheaders """
if r.representation != "html":
return None
from s3 import s3_rheader_resource, s3_rheader_tabs
from gluon import A, DIV, H1, H2, TAG
tablename, record = s3_rheader_resource(r)
if record is None:
return None
T = current.T
s3db = current.s3db
if tablename != r.tablename:
resource = s3db.resource(tablename, id=record.id if record else None)
else:
resource = r.resource
rheader = ""
if tablename == "org_organisation":
# Tabs
if not tabs:
INDIVIDUALS = current.deployment_settings.get_hrm_staff_label()
tabs = [
(T("About"), None),
(INDIVIDUALS, "human_resource"),
(T("Service Locations"), "service_location"),
# @todo: activities
]
# Use OrganisationRepresent for title to get L10n name if available
represent = s3db.org_OrganisationRepresent(acronym=False, parent=False)
title = represent(record.id)
# Retrieve other details for the rheader
data = resource.select(["organisation_organisation_type.organisation_type_id", "website"], represent=True)
row = data.rows[0]
subtitle = row["org_organisation_organisation_type.organisation_type_id"]
website = row["org_organisation.website"]
# Compile the rheader
rheader = DIV(DIV(H1(title), H2(subtitle), website if record.website else "", _class="rheader-details"))
if tabs:
rheader_tabs = s3_rheader_tabs(r, tabs)
rheader.append(rheader_tabs)
return rheader
示例6: widget
def widget(self,field, value):
self.tablename = self.tablename or field._tablename
_name=field.name,
_id="%s_%s" % (self.tablename, field.name)
self.kwargs.update({
'_type': "text",
'_name': "%s_text" %field.name,
'_id': "%s_%s_text" % (self.tablename, field.name),
'_value': '' if self.show_result else self.format(value),
'_class': "bt_autocomplete form-control",
'_data-url': self.url,
'_data-resume': 'true' if self.show_result else 'false'})
kwargs = self.kwargs
element = DIV(INPUT(_type="hidden",_name=field.name,_id="%s_%s" %(self.tablename, field.name),_value=value,_class="typeahead"),
INPUT(**kwargs),
_class="input-group" )
if not self.show_result:
element.append(
SPAN(BUTTON("Adicionar!",_class="btn btn-sm disabled",
_type="button",_id="id_add_%s" %field.name,
_title="Clique para adicionar",_disabled="disabled"),
_class="input-group-btn" )
)
# else:
# widget +=INPUT(_type="text",_name="%s_text" %field.name,
# _id="%s_%s_text" % (self.tablename, field.name),
# _value=value,
# _class="bt_autocomplete") # {{ extra_attrs }} />
# widget = element
if self.add_link:
element.append(
SPAN( A(I(_class="icon-plus"),_href="",_class="btn btn-sm add-another addlink",
_id="add_%s_%s_text" % (self.tablename, field.name),
_onclick="return showAddAnotherPopup(this);"),
_class="input-group-btn" ) )
if self.show_result:
element+=DIV(
A(I(_class="icon-trash")," ",self.format(value) if callable(self.format) else self.format %value,
_id="%s_%s_trash" %(self.tablename, field.name),
_class="btn btn-sm",
_title="Clique para remover") if value else "",
_id="%s_%s_on_deck" %(self.tablename, field.name),
_class="resume",
_style="margin-top:5px;"
)
# element +=
return element
示例7: formstyle
def formstyle(self, xfields):
"""
Use new Web2Py formstyle to generate form using DIVs & CSS
CSS can then be used to create MUCH more flexible form designs:
- Labels above vs. labels to left
- Multiple Columns
@ToDo: Requires further changes to code to use
"""
form = DIV()
for id, a, b, c, in xfields:
form.append(formstyle_row(id, a, b, c))
return form
示例8: __init__
def __init__(self, *components, **attributes):
out_body = DIV(components, _class="panel-body")
self.my_body = DIV(_class="btn-group", _role="group")
out_body.append(self.my_body)
out_body.append(XML('''
<script>
$(function () {
$('[data-toggle="popover"]').popover()
})
</script>'''))
attributes['_class'] = 'panel panel-default'
super(Leyenda, self).__init__(out_body, **attributes)
示例9: monthcal
def monthcal(self, year=None, month=None):
'''
Assemble and return an html calendar displaying the number of
attempts per day in the month 'month' for the user represented
by self.user_id.
The calendar is returned as a web2py DIV helper.
The calendar html structure is:
<table border="0" cellpadding="0" cellspacing="0" class="month">\n
<tr>
<th class="month" colspan="7">December 2013</th>
</tr>\n
<tr>
<th class="sun">Sun</th>
<th class="mon">Mon</th>
<th>class="tue">Tue</th>
<th>class="wed">Wed</th>
<th>class="thu">Thu</th>
<th>class="fri">Fri</th>
<th>class="sat">Sat</th>
</tr>\n
<tr>
<td class="sun">1</td>
<td class="mon">2</td>
<td class="tue">3</td>
<td class="wed">4</td>
<td class="thu">5</td>
<td class="fri">6</td>
<td class="sat">7</td>
</tr>\n
...
<tr>
<td class="sun">29</td>
<td class="mon">30</td>
<td class="tue">31</td>
<td class="noday">\xc2\xa0</td>
<td class="noday">\xc2\xa0</td>
<td class="noday">\xc2\xa0</td>
<td class="noday">\xc2\xa0</td>
</tr>\n
</table>\n
'''
# TODO: get settings for this user's class requirements
month = datetime.date.today().month if not month else int(month)
year = datetime.date.today().year if not year else int(year)
monthend = calendar.monthrange(year, month)[1]
monthname = calendar.month_name[month]
rangelogs = self._get_logs_for_range(datetime.datetime(year, month, 1, 0, 0),
datetime.datetime(year, month, monthend, 23, 59))
newmcal = calendar.HTMLCalendar(6).formatmonth(year, month)
mycal = TAG(newmcal)
try:
try:
daycounts = {parse(k): len(v)
for week in rangelogs[year].values()
for k, v in week[0].iteritems()}
except (TypeError, AttributeError):
daycounts = {k: len(v)
for week in rangelogs[year].values()
for k, v in week[0].iteritems()}
# Create html calendar and add daily count numbers
for week in mycal.elements('tr'):
weekcount = 0
for day in week.elements('td[class!="noday"]'):
try:
mycount = [v for k, v in daycounts.iteritems()
if k.day == int(day[0])][0]
countspan = SPAN(mycount, _class='daycount')
if mycount >= self.targetcount:
countspan['_class'] = 'daycount full'
weekcount += 1
day.append(countspan)
except (ValueError, IndexError):
pass
day[0] = SPAN(day[0], _class='cal_num')
if weekcount >= 5:
week[-1].append(SPAN(_class='icon-ok success'))
except KeyError: # if no logs for this month
pass
dropdown = self._monthpicker(calendar, year, month, monthname)
mycal.elements('th.month')[0][0] = dropdown
for link in self._navlinks(year, month):
mycal.elements('th.month')[0].insert(0, link)
wrap = DIV(_class='paideia_monthcal')
wrap.append(SPAN('Questions answered each day in',
_class='monthcal_intro_line'))
wrap.append(mycal)
# TODO: Add weekly summary counts to the end of each table
return wrap
示例10: summary
def summary(self, r, **attr):
"""
Render the summary page
@param r: the S3Request
@param attr: controller attributes
"""
output = {}
response = current.response
resource = self.resource
get_config = resource.get_config
# Get Summary Page Configuration
config = self._get_config(resource)
# Page title
crud_string = self.crud_string
title = crud_string(self.tablename, "title_list")
output["title"] = title
# Tabs
tablist = UL()
sections = []
commons = []
# Active tab
if "t" in r.get_vars:
active_tab = int(r.get_vars["t"])
else:
active_tab = 0
active_map = None
show_filter_form = False
filter_widgets = get_config("filter_widgets")
if filter_widgets and not self.hide_filter:
# Apply filter defaults (before rendering the data!)
show_filter_form = True
S3FilterForm.apply_filter_defaults(r, resource)
# Render sections
tab_idx = 0
widget_idx = 0
targets = []
pending = []
# Dynamic filtering (e.g. plot-click in report widget)
attr["filter_form"] = form_id = "summary-filter-form"
for section in config:
common = section.get("common")
# Section container
section_id = section["name"]
s = DIV(_class="section-container", _id=section_id)
if not common:
# Label
label = section["label"]
translate = section.get("translate", True)
if isinstance(label, basestring) and translate:
label = current.T(label)
# Add tab
tablist.append(LI(A(label, _href="#%s" % section_id)))
if common or active_tab == tab_idx:
visible = True
else:
visible = False
# Widgets
widgets = section.get("widgets", [])
for widget in widgets:
# Widget ID
widget_id = "summary-%s" % widget_idx
# Make sure widgets include the widget ID when
# generating Ajax URLs:
r.get_vars["w"] = r.vars["w"] = widget_id
# Append to filter targets
filterable = widget.get("filterable", True)
if filterable:
targets.append(widget_id)
if not visible and widget.get("ajax_init"):
pending.append(widget_id)
# Apply method
method = widget.get("method")
if callable(method):
content = method(r,
widget_id=widget_id,
visible=visible,
**attr)
else:
handler = r.get_widget_handler(method)
if handler is None:
#.........这里部分代码省略.........
示例11: materialize_form
def materialize_form(form, fields):
"""
Change layout of SQLFORM forms
"""
form.add_class("form-horizontal center")
main_div = DIV(_class="center")
for field_id, label, controls, field_help in fields:
curr_div = DIV(_class="row")
input_field = None
_controls = controls
try:
_name = controls.attributes["_name"]
except:
_name = ""
try:
_type = controls.attributes["_type"]
except:
_type = "string"
try:
_id = controls.attributes["_id"]
except:
_id = ""
if isinstance(controls, INPUT):
if _type == "file":
# Layout for file type inputs
input_field = DIV(DIV(SPAN("Upload"),
INPUT(_type=_type,
_id=_id),
_class="btn"),
DIV(INPUT(_type="text",
_class="file-path",
_placeholder=label.components[0]),
_class="file-path-wrapper"),
_class="col input-field file-field offset-s3 s6")
if isinstance(controls, SPAN):
# Mostly for ids which cannot be edited by user
_controls = INPUT(_value=controls.components[0],
_id=_id,
_name=_name,
_disabled="disabled")
elif isinstance(controls, TEXTAREA):
# Textarea inputs
try:
_controls = TEXTAREA(controls.components[0],
_name=_name,
_id=_id,
_class="materialize-textarea text")
except IndexError:
_controls = TEXTAREA(_name=_name,
_id=_id,
_class="materialize-textarea text")
elif isinstance(controls, SELECT):
# Select inputs
_controls = SELECT(OPTION(label, _value=""),
_name=_name,
_class="browser-default",
*controls.components[1:])
# Note now label will be the first element
# of Select input whose value would be ""
label = ""
elif isinstance(controls, A):
# For the links in the bottom while updating tables like auth_user
label = ""
elif isinstance(controls, INPUT) is False:
# If the values are readonly
_controls = INPUT(_value=controls,
_name=_name,
_disabled="")
if input_field is None:
input_field = DIV(_controls, label,
_class="input-field col offset-s3 s6")
curr_div.append(input_field)
main_div.append(curr_div)
return main_div
示例12: customfield
def customfield(form, field):
tablefield = (form.table, field)
maindiv = DIV(_id="%s_%s__row" % tablefield, _class="row")
labeldiv = DIV(_class="w2p_fl")
commentdiv = DIV(_class="w2p_fc")
widgetdiv = DIV(_class="w2p_fw")
label = LABEL(form.custom.label[field], _for="%s_%s" % tablefield, _id="%s_%s__label" % tablefield)
comment = form.custom.comment[field]
widget = form.custom.widget[field]
labeldiv.append(label)
commentdiv.append(comment)
widgetdiv.append(widget)
maindiv.append(labeldiv)
maindiv.append(commentdiv)
maindiv.append(widgetdiv)
return maindiv
示例13: customfield
def customfield(form, field, css={"main": "row", "label": "", "comment": "", "widget": "", "input": "", "error": ""}):
tablefield = (form.table, field)
maindiv = DIV(_id="%s_%s__row" % tablefield, _class=css.get("main", ""))
if field in form.errors:
maindiv["_class"] += css.get("error", "")
labeldiv = DIV(_class="w2p_fl %s" % css.get("label", ""))
commentdiv = DIV(_class="w2p_fc %s" % css.get("comment", ""))
widgetdiv = DIV(_class="w2p_fw %s" % css.get("widget", ""))
label = LABEL(form.custom.label[field], _for="%s_%s" % tablefield, _id="%s_%s__label" % tablefield)
comment = form.custom.comment[field]
widget = form.custom.widget[field]
widget_class = widget.attributes.get("_class", "")
widget_class += css.get("input", "")
widget["_class"] = widget_class
labeldiv.append(label)
commentdiv.append(comment)
widgetdiv.append(widget)
maindiv.append(labeldiv)
maindiv.append(commentdiv)
maindiv.append(widgetdiv)
return maindiv