本文整理汇总了Python中page.Page.script方法的典型用法代码示例。如果您正苦于以下问题:Python Page.script方法的具体用法?Python Page.script怎么用?Python Page.script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类page.Page
的用法示例。
在下文中一共展示了Page.script方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Storage
# 需要导入模块: from page import Page [as 别名]
# 或者: from page.Page import script [as 别名]
def Storage(params=None):
handle_params(params)
data = []
with pg_connection(*current_user.get_config()) as (con, cur, err):
with pg_log_err('list storage query'):
cur.execute(query('list-storage'))
data = cur.fetchall()
display_schemas = params.getlist('schema')
schemas = set()
treemap_data = {'name': 'root', 'children': []}
for (schema_name, table_name, t_size, t_tuples) in data:
schemas.add(schema_name)
if schema_name in display_schemas or len(display_schemas) == 0:
treemap_data['children'].append({'schema_name': schema_name, 'name': table_name,
'size': int(t_size), 'rows': int(t_tuples)})
p = Page()
# Header
p.add_page(Header(title='Storage',
js=['static/pages/storage.js',
'static/lib/d3/d3.js',
'static/lib/d3/lib/colorbrewer/colorbrewer.js'],
css=['static/pages/storage.css']))
p.add_page(Navigation(page='storage'))
with p.div({'class': 'container-fluid'}):
with p.div({'class': 'row form-row'}):
with p.div({'class': 'col-md-10'}):
with p.form({'id': 'schema-form', 'class': 'form-inline'}):
for schema in schemas:
with p.label({'class': 'checkbox-inline'}):
checked = (schema in display_schemas or len(display_schemas) == 0) and 'checked' or ''
with p.input({'type': 'checkbox', 'name': 'schema', 'value': '%s' % schema}, args=[checked]):
p.content(schema)
with p.div({'class': 'col-md-2'}):
with p.form({'id': 'mode-form', 'class': 'form-inline'}):
with p.label({'class': 'radio-inline'}):
with p.input({'type': 'radio', 'name': 'mode', 'value': 'size'}, args=['checked']):
p.content('Size')
with p.label({'class': 'radio-inline'}):
with p.input({'type': 'radio', 'name': 'mode', 'value': 'rows'}):
p.content('Rows (est.)')
with p.div({'class': 'row'}):
with p.div({'class': 'col-md-12'}):
with p.div({'id': 'treemap-chart'}): pass
with p.script():
p.content('PGUI.STORAGE.mk_treemap_chart(%s);' % json.dumps(treemap_data))
p.add_page(Footer())
return p
示例2: Query
# 需要导入模块: from page import Page [as 别名]
# 或者: from page.Page import script [as 别名]
def Query(params=None):
handle_params(params)
p = Page()
# Header
p.add_page(Header(title='Query',
js=['static/pages/query.js',
'static/pages/query_completion.js',
'static/pages/keywords.js',
'static/lib/springy/springy.js',
'static/lib/springy/springyui.js'],
css=['static/pages/query.css']))
with p.script():
p.content('PGUI.QUERY.keymap = "%s";' % current_user.keymap)
p.add_page(Navigation(page='query'))
with p.div({'class': 'container-fluid'}):
# Modal dialog for displaying previous queries
with p.div({'class': 'modal fade', 'id': 'query-history-dialog', 'tabindex': '-1', 'role': 'dialog', 'aria-labelledby': 'Query History'}):
with p.div({'class': 'modal-dialog', 'role': 'document'}):
with p.div({'class': 'modal-content'}):
with p.div({'class': 'modal-header'}):
with p.button({'type': 'button', 'class': 'close', 'data-dismiss': 'modal', 'aria-label': 'Close'}):
with p.span({'aria-hidden': 'true'}):
p.content('×')
with p.h4({'class': 'modal-title', 'id': 'query-history-label'}):
p.content('Query history')
with p.div({'clas': 'modal-body'}):
with p.div({'id': 'query-history'}): pass
# Tab bar controls
with p.div({'id': 'query-panel', 'role': 'tabpanel'}):
with p.ul({'id': 'query-nav-tabs', 'class': 'nav nav-tabs', 'role': 'tablist'}):
with p.li({'role': 'presentation'}):
with p.a({'id': 'show-query-history', 'href': 'javascript:void(0);'}):
with p.span({'class': 'add-tab glyphicon glyphicon-camera', 'aria-hidden': 'true'}): pass
with p.li({'role': 'presentation'}):
with p.a({'id': 'add-tab', 'href': 'javascript:void(0);'}):
with p.span({'class': 'add-tab glyphicon glyphicon-plus', 'aria-hidden': 'true'}): pass
# Tab bar contents
with p.div({'id': 'query-tab-panes', 'class': 'tab-content'}): pass
# Footer
p.add_page(Footer())
return p
示例3: Header
# 需要导入模块: from page import Page [as 别名]
# 或者: from page.Page import script [as 别名]
def Header(params=None, title=None, css=None, js=None):
p = Page()
p.content('<!DOCTYPE html>')
with p.html(close=False):
with p.head():
with p.title():
p.content('pgui - %s/%s' % (cu.database, title))
with p.meta({'charset': 'utf-8'}): pass
with p.script({'src': 'static/lib/jquery/jquery-2.1.3.js'}): pass
with p.script({'src': 'static/pgui.js'}): pass
with p.link({'href': 'static/pgui.css', 'rel': 'stylesheet'}): pass
with p.link({'href': 'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css', 'rel': 'stylesheet'}): pass
with p.link({'href': 'static/lib/codemirror/codemirror-5.1/lib/codemirror.css', 'rel': 'stylesheet'}): pass
with p.link({'href': 'static/lib/codemirror/codemirror-5.1/theme/neo.css', 'rel': 'stylesheet'}): pass
with p.link({'href': 'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.css', 'rel': 'stylesheet'}): pass
if css:
for c in css:
with p.link({'href': c, 'rel': 'stylesheet'}): pass
with p.script({'src': 'static/lib/bootstrap/bootstrap-3.3.4-dist/js/bootstrap.js'}): pass
with p.script({'src': 'static/lib/codemirror/codemirror-5.1/lib/codemirror.js'}): pass
with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/emacs.js'}): pass
with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/vim.js'}): pass
with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/sublime.js'}): pass
with p.script({'src': 'static/lib/codemirror/codemirror-5.1/mode/sql/sql.js'}): pass
with p.script({'src': 'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.js'}): pass
if js:
for j in js:
with p.script({'src': j}): pass
with p.body(close=False):
config = 'PGUI.user = "%s"; PGUI.db = "%s"; PGUI.host = "%s";' % (cu.name, cu.database, cu.host)
with p.script():
p.content(config)
return p