commit b157a13df9a531807220df5e37a1f93f82e98acc Author: Ross Date: Mon May 5 08:04:54 2025 +0100 basic setup diff --git a/README.md b/README.md new file mode 100644 index 0000000..3733c29 --- /dev/null +++ b/README.md @@ -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. \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..9f14e4e --- /dev/null +++ b/main.py @@ -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() \ No newline at end of file diff --git a/report_stroke.py b/report_stroke.py new file mode 100644 index 0000000..881b41f --- /dev/null +++ b/report_stroke.py @@ -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 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fe58d5f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +nicegui \ No newline at end of file