Skip to content

Commit

Permalink
dash app finished
Browse files Browse the repository at this point in the history
  • Loading branch information
noahluech committed Dec 2, 2023
1 parent f5497a4 commit ab86fa7
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 105 deletions.
106 changes: 1 addition & 105 deletions src/dash_app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,105 +1 @@
"""import dash
from dash import dcc
from dash import html
app = dash.Dash(__name__)
app.layout = html.Div([
html.Label('Select a value from the dropdown:'),
dcc.Dropdown(
id='dropdown',
options=[
{'label': 'Option 1', 'value': 'opt1'},
{'label': 'Option 2', 'value': 'opt2'},
{'label': 'Option 3', 'value': 'opt3'}
],
value='opt1' # default selected value
),
dcc.Textarea(
id='textarea',
placeholder='Enter text...',
value='',
readOnly=True,
style={'width': '50%', 'height': '100px'}
),
dcc.Input(
placeholder='Enter a value...',
type='text',
value=''
),
dcc.RadioItems(['Active wheelchair', 'No limitations', 'E-wheelchair' ,'Stroller', 'Scewo BRO'],'No limitations')
])
@app.callback(
dash.dependencies.Output('textarea', 'value'),
[dash.dependencies.Input('dropdown', 'value')]
)
def update_textarea(selected_value):
return f'You selected: {selected_value}'
if __name__ == '__main__':
app.run_server(debug=True)
"""
import dash
from dash import dcc
from dash import html
import os


app = dash.Dash(__name__)

app.layout = html.Div([
# Company description on the left
html.Div([
html.H1("Your Company Name"),
html.P("Welcome to our company. We specialize in... (add your description here)"),
], style={'width': '30%', 'float': 'left'}),

# Logo at the top right
html.Div([
html.Img(src=r'C:\git\OpenDataHackSG\src\dash_app\your_logo.png',alt='logo', style={'width': '100px', 'float': 'right'}),
], style={'width': '70%', 'float': 'right'}),

# Dropdown menu and text input on the second line
html.Div([
html.Label('Select a value from the dropdown:'),
dcc.Dropdown(
id='dropdown',
options=[
{'label': 'Option 1', 'value': 'opt1'},
{'label': 'Option 2', 'value': 'opt2'},
{'label': 'Option 3', 'value': 'opt3'}
],
value='opt1' # default selected value
),
dcc.Input(
id='text-input',
type='text',
value='', # Initial value is empty
placeholder='Enter text...',
style={'width': '50%'}
),
], style={'clear': 'both'}), # Clear the float to start a new line

# Text output on the third line
html.Div([
html.Label('Output:'),
dcc.Textarea(
id='output-textarea',
value='',
readOnly=True,
style={'width': '100%', 'height': '100px'}
),
]),
])

@app.callback(
dash.dependencies.Output('output-textarea', 'value'),
[dash.dependencies.Input('dropdown', 'value'),
dash.dependencies.Input('text-input', 'value')]
)
def update_output(selected_dropdown_value, text_input_value):
return f'You selected: {selected_dropdown_value}\nText input: {text_input_value}'

if __name__ == '__main__':
app.run_server(debug=True)
from .open_data_dash_app import OpenDataDashApp
154 changes: 154 additions & 0 deletions src/dash_app/__init__.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
"""import dash
from dash import dcc
from dash import html

app = dash.Dash(__name__)

app.layout = html.Div([
html.Label('Select a value from the dropdown:'),
dcc.Dropdown(
id='dropdown',
options=[
{'label': 'Option 1', 'value': 'opt1'},
{'label': 'Option 2', 'value': 'opt2'},
{'label': 'Option 3', 'value': 'opt3'}
],
value='opt1' # default selected value
),
dcc.Textarea(
id='textarea',
placeholder='Enter text...',
value='',
readOnly=True,
style={'width': '50%', 'height': '100px'}
),
dcc.Input(
placeholder='Enter a value...',
type='text',
value=''
),
dcc.RadioItems(['Active wheelchair', 'No limitations', 'E-wheelchair' ,'Stroller', 'Scewo BRO'],'No limitations')
])

@app.callback(
dash.dependencies.Output('textarea', 'value'),
[dash.dependencies.Input('dropdown', 'value')]
)
def update_textarea(selected_value):
return f'You selected: {selected_value}'

if __name__ == '__main__':
app.run_server(debug=True)
"""
import dash
from dash import dcc
from dash import html
import os
from ..settings import ProjectSettings
from data_handler import DataHandler

config = ProjectSettings.get_instance()
data_handler = DataHandler(config.DB_SERVER, config.DB_PORT, config.DB_NAME, config.COLLECTION_NAME)
places = data_handler.get_places()
print(places)

app = dash.Dash(__name__)

app.layout = html.Div([
# Company description on the left
html.Div([
html.H1("Your Company Name"),
html.P("Welcome to our company. We specialize in... (add your description here)"),
], style={'width': '30%', 'float': 'left'}),

# Logo at the top right
html.Div([
html.Img(src=r'C:\git\OpenDataHackSG\src\dash_app\your_logo.png',alt='logo', style={'width': '100px', 'float': 'right'}),
], style={'width': '70%', 'float': 'right'}),

# Dropdown menu and text input on the second line
html.Div([
html.Label('Select a value from the dropdown:'),
dcc.Dropdown(liste, id='pandas-dropdown-1',value='opt1'), # default selected value),
html.Div(id='pandas-output-container-1'),

dcc.Input(
id='text-input',
type='text',
value='', # Initial value is empty
placeholder='Enter text...',
style={'width': '50%'}
),
], style={'clear': 'both'}), # Clear the float to start a new line

# Text output on the third line
html.Div([
html.Label('Output:'),
dcc.Textarea(
id='output-textarea',
value='',
readOnly=True,
style={'width': '100%', 'height': '100px'}
),
]),
])

@app.callback(
dash.dependencies.Output('output-textarea', 'value'),
[dash.dependencies.Input('dropdown', 'value'),
dash.dependencies.Input('text-input', 'value')]
)
def update_output(selected_dropdown_value, text_input_value):
return f'You selected: {selected_dropdown_value}\nText input: {text_input_value}'

if __name__ == '__main__':
app.run_server(debug=True)










"""self.app.layout = html.Div([
# Company description on the left
html.Div([
html.H1("Your Company Name"),
html.P("Welcome to our company. We specialize in... (add your description here)"),
], style={'width': '30%', 'float': 'left'}),

# Logo at the top right
html.Div([
html.Img(src=r'C:\git\OpenDataHackSG\src\dash_app\your_logo.png', alt='logo', style={'width': '100px', 'float': 'right'}),
], style={'width': '70%', 'float': 'right'}),

# Dropdown menu and text input on the second line
html.Div([
html.Label('Select a value from the dropdown:'),
dcc.Dropdown(places, id='pandas-dropdown-1',value='opt1'), # default selected value),
html.Div(id='pandas-output-container-1'),

dcc.Input(
id='text-input',
type='text',
value='', # Initial value is empty
placeholder='Enter text...',
style={'width': '50%'}
),
], style={'clear': 'both'}), # Clear the float to start a new line

# Text output on the third line
html.Div([
html.Label('Output:'),
dcc.Textarea(
id='output-textarea',
value='',
readOnly=True,
style={'width': '100%', 'height': '100px'}
),
]),
])
"""
Binary file added src/dash_app/assets/megatron.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ab86fa7

Please sign in to comment.