# -*- coding: utf-8 -*- from translucent import Server, App, BootstrapUI ui = BootstrapUI('bootstrap-sidebar', 'My App') ui.set('top')(ui.header('Translucent', 'UI Demo')[ 'Lorem ipsum dolor sit amet, consectetur adipisicing.']) ui.set('left')(ui.navlist) spinner = ui.icon('fa-spinner', spin=True, fixed=True) ui.set('right')( ui.h4(nav=[spinner, 'Panel'])[spinner, 'Panel'], ui.panel('Reactive Test', style='primary')[ ui.select('object', "obj.id as obj.name for obj in env.objects", label='Select an object:'), ui.p['Selected object: {{ env.object }}'] ], ui.panel('Panel (style: {{ env.style }})', style='env.style', title='env.title')[ ui.p['Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis, modi!'], ui.panel[ ui.select('style', ['default', 'primary', 'success', 'info', 'warning', 'danger'], label='Choose heading style', init='primary'), ui.checkbox('title', 'Large title', init=False) ] ], ui.panel('Select values are not passed as strings!', style='primary')[ ui.select('a', [1, 2, 3], label='a', init=1), ui.select('b', [4, 5, 6], label='b', init=4),
# -*- coding: utf-8 -*- import numpy as np import pandas as pd import json from translucent import Server, App, BootstrapUI ui = BootstrapUI('bootstrap-sidebar', 'DataFrame Test App') ui.set('top')(ui.header('Translucent', 'Reactive Demo: LoL Champions')) ui.set('left')(ui.form[ ui.select('tag1', 't for t in env.tags1', placeholder='(all)', label='First tag:'), ui.select('tag2', 't for t in env.tags2', placeholder='(all)', label='Second tag:')]) ui.set('right')(ui.panel[ui.dataframe('table')]) class DataframeApp(App): @classmethod def on_start(cls): with open('dataframe.json') as f: cls.df = pd.DataFrame.from_dict(json.load(f)) cls.df.id = cls.df.id.astype(int).apply(lambda x: '#%03d' % x) cls.df = cls.df.set_index('id')[['name', 'tags']] cls.tags = cls.df.tags.copy() cls.df.tags = cls.df.tags.apply(lambda tags: ', '.join(tags)) def table(self, env): match = self.df.tags.str.contains return self.df[match(env.tag1 or '') & match(env.tag2 or '')] def get_tags(self, env, other):