Esempio n. 1
0
def update_graph_interactive_image(value):
    value, label, stock = int(value.split("$$$$$")[1]), value.split(
        "$$$$$")[0], value.split("$$$$$")[2]

    if value == 0:
        yahoo_financials = YahooFinancials(stock)
        input = yahoo_financials.get_financial_stmts('annual', 'income')
        htmls = json2html.convert(
            json=input,
            table_attributes="id=\"info-table\" class=\"table-inverse\"")
        uc = dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
            str(htmls))

    elif value == 1:
        yahoo_financials = YahooFinancials(stock)
        input = yahoo_financials.get_financial_stmts('annual', 'balance')
        htmls = json2html.convert(
            json=input,
            table_attributes="id=\"info-table\" class=\"table-inverse\"")
        uc = dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
            str(htmls))

    elif value == 2:
        yahoo_financials = YahooFinancials(stock)
        input = yahoo_financials.get_financial_stmts('quarterly', 'cash')
        htmls = json2html.convert(
            json=input,
            table_attributes="id=\"info-table\" class=\"table-inverse\"")
        uc = dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
            str(htmls))

    elif value == 3:
        yahoo_financials = YahooFinancials(stock)
        input = yahoo_financials.get_stock_quote_type_data()
        htmls = json2html.convert(
            json=input,
            table_attributes="id=\"info-table\" class=\"table-inverse\"")
        uc = dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
            str(htmls))

    print(uc)

    return [
        html.Div([
            html.Div(html.H5(label + " Report of " + stock),
                     style={"padding": "2%"}),
            html.Div([uc],
                     style={
                         "overflow-x": "auto",
                         "overflow-y": "auto",
                         "height": "750px"
                     })
        ])
    ]
Esempio n. 2
0
def titlebar_layout(demo=False):
    # load the logo
    MiCV_logo_filename = "/srv/www/MiCV/assets/img/MiCV_logo.png"
    MiCV_logo = base64.b64encode(open(MiCV_logo_filename, 'rb').read())

    if (demo == True):
        login_logout_link = ""
    elif (current_user and current_user.is_authenticated):
        login_logout_link = '<li class="nav-item" role="presentation"><a class="btn btn-dark text-light" role="button" href="/logout">Logout</a></li>'
    else:
        login_logout_link = '<li class="nav-item" role="presentation"><a class="btn btn-dark text-light" role="button" href="/login">Login</a></li>'

    ret = dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
		<nav class="navbar navbar-light navbar-expand-md bg-light" style="font-family: 'Open Sans', sans-serif;">
        <div class="container-fluid"><a href="/about"><img class="img-fluid" src="assets/img/MiCV_logo.png" width="200" height="200"></a><a class="navbar-brand" href="#"></a><button data-toggle="collapse" class="navbar-toggler" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
            <div
                class="collapse navbar-collapse" id="navcol-1">
                <ul class="nav navbar-nav">
                    <li class="nav-item" role="presentation"><a class="nav-link active" href="/about">About</a></li>
                    <li class="nav-item" role="presentation"></li>
                    <li class="nav-item" role="presentation"><a class="nav-link" href="/docs">Docs</a></li>
                    <li class="nav-item" role="presentation"><a class="nav-link" href="/code">Code</a></li>
                </ul>
                <ul class="nav navbar-nav ml-auto">''' + login_logout_link +
                                                                  '''    
                </ul>
        </div>
        </div>
    	</nav>
        ''')

    return ret
Esempio n. 3
0
def render_article_content(pathname):
    if pathname == '/':

        return [
            html.H2('博客列表:'),

            html.Div(
                id='article-links',
                style={
                    'width': '100%'
                }
            )
        ]

    elif pathname.startswith('/article-'):

        response = requests.get('https://www.cnblogs.com/feffery/p/%s.html' % re.findall('\d+', pathname)[0])

        tree = etree.HTML(response.text)

        return (
            html.H3(tree.xpath("//title/text()")[0].split(' - ')[0]),
            html.Em('作者:费弗里'),
            dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
                unescape(etree.tostring(tree.xpath('//div[@id="cnblogs_post_body"]')[0]).decode())
            )
        )

    return dash.no_update
def prediction(inputs,click,bchem,ichem,bdise,idise):
    string = ''
    if inputs and click:
        # token pass to ner transform function replace read
        global med_words
        med_words = predict.predict(inputs)
        med_words = get_medwords(med_words)

        paragraphs = inputs.split('/n')
        for paragraph in paragraphs:
            string = string + '''<br>'''
            # change color of the word if the word in med words
            words = nltk.word_tokenize(paragraph)
            for word in words:
                if word in med_words['B-Chemistry'] and 'B-Chemistry' in bchem:
                    string = string + ''' <span style="background-color:#00FEFE">''' + word+ '''</span>'''
                elif word in med_words['I-Chemistry'] and 'I-Chemistry' in ichem:
                    string = string + ''' <span style="background-color:#FF6347">''' + word + '''</span>'''
                elif word in med_words['B-Disease'] and 'B-Disease' in bdise:
                    string = string + ''' <span style="background-color:#FFD700">''' + word + '''</span>'''
                elif word in med_words['I-Disease'] and 'I-Disease' in idise:
                    string = string + ''' <span style="background-color:#8FBC8F">''' + word + '''</span>'''
                else:
                    string = string + ' ' + word
    return html.Div(
        inner_html.DangerouslySetInnerHTML(string)
    )
Esempio n. 5
0
def board_update_from_user(fig, clickData):
    # Does not use the clickData, but gets updated when it updates.

    # default starting board every time
    board = chess.Board()

    fig_data = fig['data'][0]
    move_seq = []
    last_move = None
    if 'level' in fig_data:
        # opening first
        chosen_opening = fig_data['level'].split('/')[0]
        end_seq = fig_data['level'].split('/')[1:]
        if chosen_opening == "All Games":
            move_seq = end_seq
        else:
            move_seq = opening_dict[chosen_opening].split(' ') + end_seq
    else:
        chosen_opening = fig['data'][0]['ids'][0].split('/')[0]
        if chosen_opening != "All Games":
            move_seq = opening_dict[chosen_opening].split(' ')

    for move in move_seq:
        last_move = board.push_san(move)
    chess_board = chess.svg.board(board=board, lastmove=last_move)
    svg_output = dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
        chess_board)

    lichess_url = f"https://lichess.org/analysis/{board.fen().replace(' ', '_')}"

    return svg_output, lichess_url
Esempio n. 6
0
def make_individual_figure(main_graph_hover):
    temp = ['NONE', 0, '20oz', 0.05, 'Notes', 'Roast', 'Address']
    if main_graph_hover is None:
        main_graph_hover = {
            "points": [{
                "curveNumber": 4,
                "pointNumber": 569,
                "customdata": temp
            }]
        }
    imgurl = ""
    if main_graph_hover is None:
        imgurl = app.get_asset_url("placeholder.png")
    else:
        chosen = [point["customdata"] for point in main_graph_hover["points"]]
        data = chosen[0]
        baseUrl = "https://maps.google.com/?q="
        #pdb.set_trace()
        if data[0] == 'NONE':
            html = (
                "<div id='infotext'><h4>Hover over a map point to see more</h4></div>"
            )
        else:
            lat = data[2]
            lon = data[3]
            url = baseUrl + str(lat) + "," + str(lon)
            html = ("<div id='infotext'><h4>" + data[4] + "</h4> <br>" +
                    "<b>Price:</b>" + str(data[6]) + " for " + data[9] + " (" +
                    str(data[7]) + " per oz)" +
                    "<br><b>Flavour profile:</b> " + data[5] + " -- " +
                    data[8] + "<br><b>Address:</b> <em><a href='" + url +
                    "'>" + data[0] + "</a></em></div>")

    return dash_dangerously_set_inner_html.DangerouslySetInnerHTML(html)
Esempio n. 7
0
    def __init__(self, **kwargs):
        super(DashNoPropsComponent, self).__init__(**kwargs)

        self.dash.layout = html.Div([
            dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
                <h1>No Props Component</h1>
            ''')
        ])
def generateNotFound(text):
    return dash_dangerously_set_inner_html.DangerouslySetInnerHTML(f'''
        <div class="error-page">
            <div>
                <h1 data-h1="404">404</h1>
                <p data-p="NOT FOUND">{text}</p>
            </div>
        </div>
''')
def display_content(href):
    return html.Div([
        dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
            '<h1>App</h1>'),
        dt.DataTable(rows=[{
            'a': 1,
            'b': 3
        }])
    ])
Esempio n. 10
0
 def task_display_data(self):
     """
     Display with dash.
     """
     self.config.compact()
     # This line makes a cannot find reference warning and i do not know why and how i can fix it
     self.configText = html.Div([
         ddsih.DangerouslySetInnerHTML(json2table.convert(self.config.data))
     ])
Esempio n. 11
0
def get_footer_links():
    footer = html.Div([
        dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''

    '<!--=== Footer Version 1 ===-->
    <div class="footer-v1">
        <div class="footer">
            <div class="container">
                <div class="row">
                    <!-- About -->

                    <div class="col-md-3 md-margin-bottom-40">
                        <a href="/">

<!-- img id="logo-footer" class="footer-logo" src="logo.png" alt="" width="200px" -->
<div id="footer-logo-svg">
  <img height="100%" id="logo-footer" class="footer-logo" src="dk-bkgrnd.svg" alt="">
</div>
</a>

                    </div><!--/col-md-3-->
                    <!-- End About -->

                    <!-- Link List -->
                    <div class="col-md-3 md-margin-bottom-40">
                        <div class="headline"><h2>Links</h2></div>
                        <ul class="list-unstyled link-list">
                            <li><a href="/about">About Us</a><i class="fa fa-angle-right"></i></li>
                            <!-- li><a href="/scope-and-sequence">Contribute</a><i class="fa fa-angle-right"></i></li -->
                            <li><a href="terms-of-service">Terms of Use</a><i class="fa fa-angle-right"></i></li>
                            <li><a href="privacy-policy">Privacy Policy</a><i class="fa fa-angle-right"></i></li>
                            <li><a href="/sitemap">Site Map</a><i class="fa fa-angle-right"></i></li>
                        </ul>
                    </div><!--/col-md-3-->
                    <!-- End Link List -->

                    <!-- Address -->
                    <div class="col-md-3 map-img md-margin-bottom-40">
                        <div class="headline"><h2>Contact</h2></div>
                        <address class="md-margin-bottom-40">
                            <a href="href="tel:3476887501" title="347-688-7501" class="">Phone</a><br />
                            <a href="mailto:[email protected]" class="">Email</a><br />
                            <a href="https://github.com/ForestMars/Coda.to" class="">Github</a><br />
                            <a href="http://twitter.com/codatatools" class="">Social</a>
                        </address>
                    </div><!--/col-md-3-->
                    <!-- End Address -->
                </div>
            </div>
        </div><!--/footer-->

    <!--=== Link Footer above /// TOS Footer below ===-->

        '''),
    ], )
    return footer
Esempio n. 12
0
 def test_no_props_component(self):
     app = Dash()
     app.layout = html.Div([
         dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
             <h1>No Props Component</h1>
         ''')
     ])
     self.startServer(app)
     assert_clean_console(self)
     self.percy_snapshot(name='no-props-component')
Esempio n. 13
0
class DashNoPropsComponent(DashView):
    dash_name = 'static_dash06'
    dash_components = {html.__name__, dash_dangerously_set_inner_html.__name__}

    dash = Dash()
    dash.layout = html.Div([
        dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
            <h1>No Props Component</h1>
        ''')
    ])
Esempio n. 14
0
def test_inin005_no_props_component(dash_duo):
    app = Dash()
    app.layout = html.Div([
        dash_dangerously_set_inner_html.DangerouslySetInnerHTML("""
            <h1>No Props Component</h1>
        """)
    ])

    dash_duo.start_server(app)

    assert not dash_duo.get_logs()
    dash_duo.percy_snapshot(name="no-props-component")
Esempio n. 15
0
def updateStationInfo(clickPt):
    if (clickPt):
        index = clickPt['points'][0]['pointIndex']
        print(stationInfo['name'][index] + ' clicked')

        info = [
            html.Img(src=stationLogo[index], className="station-logo"),
            dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
                stationInfo['html'][index]),
            html.Div(
                # style = {"display":"flex"},
                children=[
                    userComp.makeFlexTable(stationInfo['table'][index],
                                           'status-table'),
                    html.Div(
                        id="kpigraph-container",
                        # style = {"display":"flex", "flex-wrap": "wrap", "justify-content": "center"},
                        children=[
                            dcc.Graph(
                                id='graph-kpi1',
                                # style = {"width":"calc((100vw)/6  - 4rem)", "padding":"1rem", "height":"15rem"},
                                figure=go.Figure(
                                    data=[
                                        go.Scatter(x=[1, 2, 3], y=[4, 1, 2])
                                    ],
                                    layout=go.Layout(
                                        margin=dict(t=30, b=10, l=10, r=10),
                                        title="KPI 1",
                                        yaxis=dict(fixedrange=True),
                                        xaxis=dict(fixedrange=True),
                                    ),
                                )),
                            dcc.Graph(
                                id='graph-kpi2',
                                # style = {"width":"calc((100vw)/6 - 4rem)", "padding":"1rem", "height":"15rem"},
                                figure=go.Figure(
                                    data=[go.Bar(x=[1, 2, 3], y=[4, 1, 2])],
                                    layout=go.Layout(
                                        margin=dict(t=30, b=10, l=10, r=10),
                                        title="KPI 2",
                                        yaxis=dict(fixedrange=True),
                                        xaxis=dict(fixedrange=True),
                                    ),
                                )),
                        ],
                    ),
                ], )
        ]

    else:
        info = staticIntro
    return info
Esempio n. 16
0
def update_output(n_clicks):
    global IDX, names
    if n_clicks is None:
        IDX = 0
        return "Click Next to start", ""

    if IDX >= len(html_content):
        return "All done!", ""

    name = f"Student name: {names[IDX]}"
    content = html_content[IDX]
    IDX += 1
    return dash_dangerously_set_inner_html.DangerouslySetInnerHTML(content), name
Esempio n. 17
0
def NamedInput(name, style=None, raw_html=False, **kwargs):
    style = __get_style(style)
    if raw_html:
        return html.Div([
            html.P(dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
                '{}:'.format(name)),
                   style=style),
            dcc.Input(**kwargs, style=style)
        ])
    else:
        return html.Div([
            html.P('{}:'.format(name), style=style),
            dcc.Input(**kwargs, style=style)
        ])
Esempio n. 18
0
def update_info(picked_country):
    if not picked_country:
        return [dash_dangerously_set_inner_html.DangerouslySetInnerHTML("""<center><strong ><font color="white"  font-family="Source Sans Pro" size=2 font-weight='bold'>
        Currently showing countries with more than 10 connections <br>
        Pick a country on the map or on the bar for to show all connections of that country.
        </font></strong></center>""")]
    else:
        country = country_df.iloc[picked_country]['country']
        filtered_country_flow = flow_df[flow_df['country_from'] == country]
        n_country_to = len(filtered_country_flow)
        country_code_iso2 = pc.country_alpha3_to_country_alpha2(country)
        country_name = pc.country_alpha2_to_country_name(country_code_iso2)
        user_count = country_df.iloc[picked_country]['user_count']
        line_1 = f"""{country_name} has {user_count} active user(s)."""
        html_raw_1 = f'''<center><strong ><font color="white"  font-family="Source Sans Pro" size=2 font-weight="bold">{line_1}</font></strong></center>'''
        line_2 = f"""{country_name} has connections with {n_country_to} other countries"""
        html_raw_2 = f'''<center><strong ><font color="white"  font-family="Source Sans Pro" size=2 font-weight="bold">{line_2}</font></strong></center>'''
        line_3 = """To clear selections, refresh the webpage. """
        html_raw_3 = f'''<center><strong ><font color="gray"  font-family="Source Sans Pro" size=1 font-weight="100">{line_3}</font></strong></center>'''
        # todo: make it pretty if time allows...
        return [dash_dangerously_set_inner_html.DangerouslySetInnerHTML(html_raw_1),
                dash_dangerously_set_inner_html.DangerouslySetInnerHTML(html_raw_2),
                dash_dangerously_set_inner_html.DangerouslySetInnerHTML(html_raw_3)]
def generate_table(n, max_rows=30):

    # df_azq.to_csv("problem_list.txt", index=False)
    df_azq = pd.read_csv("problem_list.txt")
    last_edited = sorted(
        df_azq['edit_date'].astype('datetime64[s]').astype('str'))[-1]

    df_azq.insert(4, 'Betroffen',
                  df_azq['affected'] + ' / ' + df_azq['bonding_goods'])
    df_azq.drop(['affected', 'bonding_goods'], axis=1, inplace=True)

    df_azq['create_date'] = df_azq['create_date'].astype('datetime64[s]')
    df_azq['create_date'] = df_azq['create_date'].astype('str')
    df_azq['edit_date'] = df_azq['edit_date'].astype('datetime64[s]')
    df_azq['edit_date'] = df_azq['edit_date'].astype('str')
    df_azq['create_user'] = df_azq['create_user'].str[1:]
    df_azq['create_user'] = df_azq['create_user'].str.title()
    df_azq['edit_user'] = df_azq['edit_user'].str[1:]
    df_azq['edit_user'] = df_azq['edit_user'].str.title()

    df_azq.insert(6, 'Startdatum',
                  df_azq['create_date'] + '<br>' + df_azq['create_user'])
    df_azq.insert(9, 'Statusdatum',
                  df_azq['edit_date'] + '<br>' + df_azq['edit_user'])
    df_azq.drop(['create_date', 'create_user', 'edit_date', 'edit_user'],
                axis=1,
                inplace=True)

    print("###############################")
    print("###############################")
    print("###############################")
    print("###############################")
    print("           DASHBOARD (AZQ)     ")
    print("###############################")
    print("###############################")
    print("###############################")
    print("###############################")

    return html.Table(
        # Header
        [html.Tr([html.Th(col) for col in df_azq.columns])] +
        # Body
        [
            html.Tr([
                html.Td(
                    dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
                        '''{}'''.format(df_azq.iloc[i][col])))
                for col in df_azq.columns
            ]) for i in range(min(len(df_azq), max_rows))
        ]), 'zuletzt bearbeitet: {}'.format(last_edited)
Esempio n. 20
0
def update_output(n_clicks):
    """ Processes the various student files.
    There is certainly a more elogant way of doing it than a global IDX :)
    """
    global IDX, names
    if n_clicks is None:
        IDX = 0
        return "Click Next to start", ""

    if IDX >= len(html_content):
        return "All done!", ""

    name = f"Student name: {names[IDX]}"
    content = html_content[IDX]
    IDX += 1
    return dash_dangerously_set_inner_html.DangerouslySetInnerHTML(content), name
Esempio n. 21
0
def create_setTitleTab():

    style = {
        'border': '5px solid purple',
        'border-radius': '5px',
        'padding': '10px'
    }

    rawDiv = html.Div(
        [danger.DangerouslySetInnerHTML(''' <h1>Header</h1> ''')])

    locationComponent = dcc.Location(id='url', refresh=False)
    locationDisplay = dcc.Textarea(id="locationDisplay",
                                   placeholder='location display goes here',
                                   value="",
                                   style={
                                       'width': 600,
                                       'height': 100
                                   })

    setTitleInput = dcc.Input(
        id="setTitleTextInput",
        placeholder=
        'enter convenient, concise text title here, no spaces please!',
        value="",
        style={
            'width': '512px',
            'fontSize': 20
        })

    setTitleButton = html.Button(id='setTitleButton',
                                 type='submit',
                                 children='Submit')

    children = [
        html.Br(), locationComponent, locationDisplay,
        html.Br(), rawDiv,
        html.Br(), setTitleInput,
        html.Br(),
        html.Br(), setTitleButton
    ]

    div = html.Div(children=children, id='setTitleDiv')

    return div
Esempio n. 22
0
def update_output(ns1, nb1, input1):
    if input1 is None:
        return ''

    data = get_df_from_text(input1)
    df = data['df']
    return [
        inner_html.DangerouslySetInnerHTML(data['command']),
        dcc.Graph(id='life-exp-vs-gdp',
                  figure={
                      'data': [
                          go.Scatter(
                              x=df[df['continent'] == i]['gdp per capita'],
                              y=df[df['continent'] == i]['life expectancy'],
                              text=df[df['continent'] == i]['country'],
                              mode='markers',
                              opacity=0.7,
                              marker={
                                  'size': 15,
                                  'line': {
                                      'width': 0.5,
                                      'color': 'white'
                                  }
                              },
                              name=i) for i in df.continent.unique()
                      ],
                      'layout':
                      go.Layout(xaxis={
                          'type': 'log',
                          'title': 'GDP Per Capita'
                      },
                                yaxis={'title': 'Life Expectancy'},
                                margin={
                                    'l': 40,
                                    'b': 40,
                                    't': 10,
                                    'r': 10
                                },
                                legend={
                                    'x': 0,
                                    'y': 1
                                },
                                hovermode='closest')
                  })
    ]
Esempio n. 23
0
def displayJoke(jokes_history):

    if jokes_history is not None:

        jokes_list = json.loads(jokes_history)
        n_jokes = len(jokes_list[0])
        index = jokes_list[1]
        print(index)
        if index == n_jokes:
            return html.P("You have seen all the jokes")

        html_text = '''{}'''.format(
            open(jokes_list[0][index]).read().replace('\n', ' '))

        return dash_dangerously_set_inner_html.DangerouslySetInnerHTML(
            html_text)
    else:

        return html.P("Press next to start rating jokes")
Esempio n. 24
0
def test_inin004_no_props_component(dash_duo):
    app = Dash()
    app.layout = html.Div(
        [
            dash_dangerously_set_inner_html.DangerouslySetInnerHTML("""
            <h1>No Props Component</h1>
        """)
        ],
        id="app",
    )

    dash_duo.start_server(app)

    assert dash_duo.get_logs() == []
    assert dash_duo.find_element("h1").text == "No Props Component"

    inner = dash_duo.find_element("#app").get_property("innerHTML")
    expected = "<div> <h1>No Props Component</h1> </div>"
    assert re.sub("\\s+", " ", inner) == expected
Esempio n. 25
0
def test_inin005_no_props_component(dash_duo):
    app = Dash()
    app.layout = html.Div([
        dash_dangerously_set_inner_html.DangerouslySetInnerHTML("""
            <h1>No Props Component</h1>
        """)
    ])

    class DashView(BaseDashView):
        dash_components = {
            dcc.__name__, html.__name__,
            dash_dangerously_set_inner_html.__name__
        }
        dash = app

    dash_duo.start_server(DashView)

    assert not dash_duo.get_logs()
    dash_duo.percy_snapshot(name="no-props-component")
Esempio n. 26
0
def create_layout(app):
    return html.Div([
        html.H6('choose file to upload'),
        dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
			<form action="/uploader" method="POST" enctype="multipart/form-data">

				<div class="form-group">
				  <label>Select File</label>
				  <div class="custom-file">
					<input type="file" name="file" >
				  </div>
				</div>

				<button type="submit" class="btn btn-primary">Submit</button>

			</form>
			'''),
        dcc.Upload(id='upload-test',
                   children=html.Div(
                       ['Select Related Files to Upload'],
                       style={
                           "font-family": "NotoSans-Regular",
                           "font-size": "0.8rem",
                           "text-decoration": "underline",
                           "color": "#1357DD"
                       }),
                   style={
                       'height': '40px',
                       'lineHeight': '40px',
                       'borderWidth': '1px',
                       'borderStyle': 'dashed',
                       'borderRadius': '5px',
                       'textAlign': 'center'
                   }),
        html.Div(id='output-test-upload',
                 style={
                     "text-align": "center",
                     "padding": "0.5rem",
                     "font-family": "NotoSans-Regular",
                     "font-size": "0.6rem"
                 }),
    ])
def get_information(inputs, click, creatnew):
    string = ''
    if click and inputs:
        if int(inputs) in all_patient_df['Med_ID'].tolist():
            global patient_df
            patient_df = all_patient_df.loc[all_patient_df['Med_ID'] == int(inputs)]
            if int(patient_df['GENDER_F']) is 1:
                gender = 'female'
            else:
                gender = 'male'
            string = '''
            <p><b>Name: </b>'''+ str(patient_df['Med_ID'].values[0])+'''</p>
            <p><b>Age</b>: '''+ str(patient_df['age'].values[0])+'''</p>
            <p><b>Gender: </b>'''+ gender +'''</p>
            '''
        else:
            string = '''<p><b>Patient Not Exist, please create new </b>'''
    if creatnew:
        string = ''
    return html.Div(
        inner_html.DangerouslySetInnerHTML(string)
    )
Esempio n. 28
0
def display_content(n_clicks, soundFileName, eafFileName, projectDirectory,
                    grammaticalTermsFile, tierGuideFile):
    if n_clicks is None:
        return ("")
    print("--- create web page")
    print("        eaf: %s", eafFileName)
    print(" phrases in: %s", projectDirectory)
    if (grammaticalTermsFile == ""):
        grammaticalTermsFile = None
    html = createWebPage(eafFileName, projectDirectory, grammaticalTermsFile,
                         tierGuideFile)
    absolutePath = os.path.abspath(os.path.join(projectDirectory, "text.html"))
    file = open(absolutePath, "w")
    file.write(html)
    file.close()

    #url = 'file:///%s' % absolutePath

    #url = 'http:/%s/text.html' % projectDirectory
    #webbrowser.open(url, new=2)
    htmlWrapped = danger.DangerouslySetInnerHTML(html)
    return (htmlWrapped)
Esempio n. 29
0
def set_table(radius, oid, dr, catalog):
    ra, dec = find_ztf_oid.get_coord(oid, dr)
    if radius is None:
        return html.P('No radius is specified')
    radius = float(radius)
    if radius <= 0:
        return html.P('Radius should be positive')
    query = get_catalog_query(catalog)
    try:
        table = query.find(ra, dec, radius)
    except NotFound:
        return html.P(
            f'No {catalog.replace("-", " ")} objects within {radius} arcsec from {ra:.5f}, {dec:.5f}'
        )
    except (CatalogUnavailable, ConnectionError):
        return html.P('Catalog data is temporarily unavailable')
    table = table.copy()
    div = html.Div([
        ddsih.DangerouslySetInnerHTML(
            html_from_astropy_table(table, query.columns)),
    ], )
    return div
Esempio n. 30
0
def get_layout(coordinates, radius_arcsec, dr):
    ra = coordinates.ra.to_value('deg')
    dec = coordinates.dec.to_value('deg')
    cone_str = f'({ra:.5f} deg, {dec:.5f} deg), r = {radius_arcsec:.1f}″'
    try:
        j = find_ztf_circle.find(ra, dec, radius_arcsec, dr)
    except NotFound:
        return html.Div([
            html.H1('404'),
            f'Nothing inside cone {cone_str}',
        ])
    table = Table([
        dict(oid=f'<a href="/{dr}/view/{oid}">{oid}</a>',
             separation=obj['separation'],
             **obj['meta'])
        for oid, obj in sorted(j.items(), key=lambda x: x[1]['separation'])
    ])
    layout = html.Div([
        html.H1(f'Objects inside cone {cone_str}'),
        ddsih.DangerouslySetInnerHTML(html_from_astropy_table(table, COLUMNS)),
    ], )
    return layout