basic setup

This commit is contained in:
Ross
2025-05-05 08:04:54 +01:00
commit b157a13df9
4 changed files with 123 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
# My NiceGUI App
This project is a simple web application built using NiceGUI. It demonstrates how to create a user interface with interactive components.
## Project Structure
```
my-nicegui-app
├── main.py # Entry point of the NiceGUI application
├── requirements.txt # Lists the dependencies required for the project
├── static
│ └── styles.css # Contains the CSS styles for the application
└── README.md # Documentation for the project
```
## Setup Instructions
1. Clone the repository:
```
git clone https://github.com/yourusername/my-nicegui-app.git
cd my-nicegui-app
```
2. Install the required dependencies:
```
pip install -r requirements.txt
```
3. Run the application:
```
python main.py
```
4. Open your web browser and navigate to `http://localhost:8080` to view the application.
## Usage Examples
- Explore the various components and features of the NiceGUI application.
- Customize the styles by editing the `static/styles.css` file.
## Contributing
Feel free to submit issues or pull requests if you have suggestions or improvements for the project.
+20
View File
@@ -0,0 +1,20 @@
from nicegui import ui
from report_stroke import report_stroke # Import the report_stroke page
def main():
ui.label('Welcome to My NiceGUI App!')
ui.button('Click Me', on_click=lambda: ui.navigate.to('/report_stroke'))
@ui.page('/about')
def about_page():
ui.label('This is the About page.')
# Register the report_stroke page
@ui.page('/report_stroke')
def report_stroke_page():
report_stroke()
ui.run()
if __name__ in {"__main__", "__mp_main__"}:
main()
+59
View File
@@ -0,0 +1,59 @@
from nicegui import ui
def report_stroke():
ui.label('Please answer the following questions:')
# Create a dictionary to store the selected answers and custom text
answers = {
'haemorrhage': 'False',
'ischaemia': 'False',
'lvo': 'False',
'stenosis': 'False'
}
custom_text = {
'haemorrhage': '',
'ischaemia': '',
'lvo': '',
'stenosis': ''
}
# Text box to display the selected answers
result_box = ui.textarea('Selected Answers:', value='').props('rows=5 readonly')
def update_result():
# Generate a formatted string with labels, answers, and custom text
formatted_text = (
f"There is evidence of intracranial haemorrhage: {answers['haemorrhage']} {custom_text['haemorrhage']}\n"
f"There is evidence of acute ischaemia: {answers['ischaemia']} {custom_text['ischaemia']}\n"
f"There is an intracranial LVO: {answers['lvo']} {custom_text['lvo']}\n"
f"There is significant stenosis of the internal carotid arteries: {answers['stenosis']} {custom_text['stenosis']}"
)
result_box.value = formatted_text
with ui.row():
ui.label('There is evidence of intracranial haemorrhage')
ui.radio(['True', 'False'], on_change=lambda e: (answers.update({'haemorrhage': e.value}), update_result())).props('inline')
toggle_haemorrhage = ui.checkbox('Add custom text', value=False, on_change=lambda e: custom_input_haemorrhage.set_visibility(e.value))
custom_input_haemorrhage = ui.input('Custom text', on_change=lambda e: (custom_text.update({'haemorrhage': e.value}), update_result()))
custom_input_haemorrhage.visible = toggle_haemorrhage.value
with ui.row():
ui.label('There is evidence of acute ischaemia')
ui.radio(['True', 'False'], on_change=lambda e: (answers.update({'ischaemia': e.value}), update_result())).props('inline')
toggle_ischaemia = ui.checkbox('Add custom text', value=False, on_change=lambda e: custom_input_ischaemia.set_visibility(e.value))
custom_input_ischaemia = ui.input('Custom text', on_change=lambda e: (custom_text.update({'ischaemia': e.value}), update_result()))
custom_input_ischaemia.visible = toggle_ischaemia.value
with ui.row():
ui.label('There is an intracranial LVO')
ui.radio(['True', 'False'], on_change=lambda e: (answers.update({'lvo': e.value}), update_result())).props('inline')
toggle_lvo = ui.checkbox('Add custom text', value=False, on_change=lambda e: custom_input_lvo.set_visibility(e.value))
custom_input_lvo = ui.input('Custom text', on_change=lambda e: (custom_text.update({'lvo': e.value}), update_result()))
custom_input_lvo.visible = toggle_lvo.value
with ui.row():
ui.label('There is significant stenosis of the internal carotid arteries')
ui.radio(['True', 'False'], on_change=lambda e: (answers.update({'stenosis': e.value}), update_result())).props('inline')
toggle_stenosis = ui.checkbox('Add custom text', value=False, on_change=lambda e: custom_input_stenosis.set_visibility(e.value))
custom_input_stenosis = ui.input('Custom text', on_change=lambda e: (custom_text.update({'stenosis': e.value}), update_result()))
custom_input_stenosis.visible = toggle_stenosis.value
+1
View File
@@ -0,0 +1 @@
nicegui