Skip to content

Commit f6eb603

Browse files
committed
First go at redoing readme's
1 parent cb35f0a commit f6eb603

5 files changed

Lines changed: 32 additions & 219 deletions

File tree

activity_browser/README.md

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,7 @@ The application can be started in multiple ways:
2929

3030
All entry points lead to `activity_browser.__main__:run_activity_browser`.
3131

32-
## Architecture
33-
34-
The application follows an MVC-like pattern with:
35-
- **Global signals** (`activity_browser.app.signals`) - Event bus for cross-component communication
36-
- **Deferred imports** - Heavy modules are loaded in background threads during startup
37-
- **Actions pattern** - UI operations encapsulated in `app/actions/` with a base class pattern
38-
39-
## Dependencies
40-
41-
Main dependencies include:
42-
- **PySide6** (via qtpy) - Qt bindings for the GUI
43-
- **Brightway2** ecosystem (bw2data, bw2calc, bw2analyzer, bw2io) - LCA calculation engine
44-
- **loguru** - Logging framework
45-
4632
## Development Notes
4733

48-
- Avoid top-level imports of heavy modules (PySide6, bw2data) to keep tests fast
49-
- Use project signals for cross-component communication instead of direct function calls
50-
- Global shortcuts are registered via `@application.global_shortcut` decorator
34+
- See `CONTRIBUTING.md` for guidelines on contributing to the project
35+
- Check out the Development notes specific to each submodule for more details on implementation

activity_browser/app/README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ This module orchestrates the main application components including the main wind
3131
The app module creates and wires together the core application components:
3232

3333
1. **Application** (`ABApplication`) - Qt application instance with global shortcut management
34-
2. **Signals** (`ABSignals`) - Project-wide event bus for cross-component communication
34+
2. **Signals** (`ABSignals`) - Project-wide event bus for model to UI communication
3535
3. **Main Window** (`MainWindow`) - Main application window with pages and panes
36-
4. **Actions** - Command pattern implementation for menu items and toolbar actions
36+
4. **Actions** - Command pattern implementation for menu items and toolbar actions. Modifying Brightway2 happens here.
3737
5. **Pages** - Content area widgets for different application views
3838
6. **Panes** - Dock-able side panels
3939

@@ -59,12 +59,9 @@ app.metadata # Metadata store
5959
app.main_window # Main window
6060
```
6161

62-
## Actions Pattern
62+
## Development Notes
6363

64-
Actions encapsulate user commands and are defined in the `actions/` subdirectory. Each action:
65-
- Inherits from `ABAction` base class
66-
- Defines icon, text, tooltip
67-
- Implements a `run()` static method
68-
- Can be converted to QAction or QPushButton
69-
70-
See `actions/base.py` for the action framework.
64+
- See `CONTRIBUTING.md` for guidelines on contributing to the project
65+
- This module is the place to add components that depend on the application having been initialized (e.g., actions, panes)
66+
- If the logic you want to add can only depend on brightway2, consider placing it in the `bwutils` submodule instead
67+
- If the widget you want to add does not depend on the application, consider placing it in the `ui` submodule instead

activity_browser/app/actions/README.md

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ This directory contains all user-triggered actions in Activity Browser. Each act
1717
- **`project/`** - Project-level operations
1818
- **`tools/`** - Various tools and utilities accessible via actions
1919

20-
## Key Files
21-
22-
- **`base.py`** - `ABAction` base class that all actions inherit from
23-
- **`metadatastore_open.py`** - Action to open the metadata store dialog
24-
- **`migrations_install.py`** - Database migration actions
25-
- **`node_select_open.py`** - Node selection dialog action
26-
- **`pyside_upgrade.py`** - PySide upgrade helper action
27-
- **`save_parameters_to_excel.py`** - Export parameters to Excel
28-
- **`settings_wizard_open.py`** - Settings wizard dialog action
29-
3020
## Action Pattern
3121

3222
All actions follow a consistent pattern defined in `base.py`:
@@ -48,7 +38,7 @@ class MyAction(ABAction):
4838
1. **Declarative** - Icon, text, and tooltip defined as class attributes
4939
2. **Callable arguments** - Arguments can be functions (evaluated at runtime)
5040
3. **Qt integration** - Can be converted to QAction or QPushButton
51-
4. **Exception handling** - Optional decorator for error dialogs
41+
4. **Exception handling** - Always add `@exception_dialogs` decorator for user-facing errors
5242
5. **Flexible invocation** - Triggered from menus, buttons, shortcuts
5343

5444
## Usage
@@ -99,18 +89,4 @@ When adding new actions:
9989

10090
## Signal Integration
10191

102-
Actions should emit signals when they modify application state:
103-
104-
```python
105-
from activity_browser import app
106-
107-
class MyAction(ABAction):
108-
@staticmethod
109-
def run():
110-
# Perform operation
111-
...
112-
# Emit signal
113-
app.signals.database_changed.emit()
114-
```
115-
116-
This ensures other components can react to state changes without tight coupling.
92+
**Actions should not emit signals themselves** That being said, actions should only emit signals when they modify state in a way that Brightway2 does not automatically notify the UI about. See e.g. parameter_group_delete.py for an example of emitting a signal after deleting a parameter group.

activity_browser/app/dialogs/README.md

Lines changed: 5 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -4,117 +4,10 @@ Dialog windows for user interactions throughout Activity Browser.
44

55
## Overview
66

7-
This directory contains modal and non-modal dialog windows used for various user interactions such as data entry, configuration, selection, and information display.
7+
This directory contains modal and non-modal dialog windows used for various user interactions such as data entry, configuration, selection, and information display. Dialogs in the app directory are there because they are tightly integrated with Brightway2 or depend on the application for other reasons.
88

9-
## Purpose
9+
- Generally, action specific dialogs are located alongside the corresponding action in the `actions/` directory.
10+
- Dialogs than can be applied more widely and are not intimately tied with either actions or Brightway2 are located in the `ui/dialogs/` directory.
11+
- Only if the above two locations are not appropriate should a dialog be placed here.
1012

11-
Dialogs provide focused interfaces for:
12-
- User input and data entry
13-
- Configuration and settings
14-
- Selection of items (activities, methods, databases)
15-
- Information display and confirmations
16-
- Multi-step workflows (see also `ui/wizards/`)
17-
18-
## Common Dialog Types
19-
20-
### Input Dialogs
21-
- Text input fields
22-
- Numeric value entry
23-
- Date/time selection
24-
- Multi-line text editing
25-
26-
### Selection Dialogs
27-
- List/tree item selection
28-
- Database/activity pickers
29-
- Method selection
30-
- File/directory choosers
31-
32-
### Configuration Dialogs
33-
- Settings editors
34-
- Preference panels
35-
- Option configuration
36-
37-
### Information Dialogs
38-
- Progress indicators
39-
- Status messages
40-
- Warnings and errors
41-
- About/help information
42-
43-
## Design Guidelines
44-
45-
Dialogs in Activity Browser should:
46-
47-
1. **Be modal when appropriate** - Block parent window for critical decisions
48-
2. **Provide clear actions** - OK/Cancel, Accept/Reject, or custom actions
49-
3. **Validate input** - Check data before accepting
50-
4. **Give feedback** - Show errors, warnings, progress
51-
5. **Be responsive** - Use threading for long operations
52-
6. **Follow Qt conventions** - Inherit from QDialog, use standard buttons
53-
54-
## Usage Pattern
55-
56-
```python
57-
from qtpy.QtWidgets import QDialog, QDialogButtonBox
58-
59-
class MyDialog(QDialog):
60-
def __init__(self, parent=None):
61-
super().__init__(parent)
62-
self.setup_ui()
63-
64-
def setup_ui(self):
65-
# Build dialog UI
66-
pass
67-
68-
def accept(self):
69-
# Validate and process input
70-
if self.validate():
71-
super().accept()
72-
```
73-
74-
## Integration with Actions
75-
76-
Dialogs are typically opened via actions:
77-
78-
```python
79-
from activity_browser.app.actions.base import ABAction
80-
81-
class OpenMyDialog(ABAction):
82-
@staticmethod
83-
def run():
84-
dialog = MyDialog()
85-
if dialog.exec_() == QDialog.Accepted:
86-
# Process result
87-
pass
88-
```
89-
90-
## Threading Considerations
91-
92-
Long-running operations in dialogs should use worker threads:
93-
94-
```python
95-
from activity_browser.ui.core.threading import ABThread
96-
97-
class MyDialog(QDialog):
98-
def perform_long_operation(self):
99-
worker = ABThread(self.expensive_task)
100-
worker.finished.connect(self.on_complete)
101-
worker.start()
102-
```
103-
104-
## Signal Emission
105-
106-
Dialogs should emit signals to notify the application of changes:
107-
108-
```python
109-
from activity_browser import app
110-
111-
class MyDialog(QDialog):
112-
def accept(self):
113-
# Save changes
114-
self.save_data()
115-
# Notify application
116-
app.signals.data_changed.emit()
117-
super().accept()
118-
```
119-
120-
This ensures the rest of the application can react to changes made in dialogs without tight coupling.
13+
What qualifies to be put in this directory is somewhat subjective, but the guiding principle is that these dialogs are core to the functioning of Activity Browser and are not easily reusable outside of it.

activity_browser/app/pages/README.md

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,67 +18,25 @@ This directory contains the primary content pages that users interact with in Ac
1818
## Key Files
1919

2020
- **`welcome.py`** - Welcome page shown when no project is open or on first launch
21-
- **`metadatastore.py`** - Metadata management page
21+
- **`metadatastore.py`** - Metadata view page (DEBUG only)
2222

23-
## Page Architecture
23+
## Two types of pages
2424

25-
Pages inherit from `AbstractPage` (in `ui/widgets/abstract_page.py`) which provides:
26-
- Consistent layout structure
27-
- Signal connections
28-
- Toolbar integration
29-
- State management
30-
31-
## Page Lifecycle
32-
33-
1. **Creation** - Page is instantiated and added to the main window
34-
2. **Display** - User navigates to the page (shown in central widget)
35-
3. **Updates** - Page responds to signals and refreshes data
36-
4. **Interaction** - User performs actions within the page
37-
5. **Persistence** - Page state may be saved when switching away
38-
39-
## Common Page Features
40-
41-
### Toolbars
42-
Most pages include a toolbar with actions:
43-
```python
44-
self.toolbar = QToolBar()
45-
self.toolbar.addAction(MyAction.get_QAction())
46-
```
47-
48-
### Data Display
49-
Pages typically contain:
50-
- Tables showing lists of items
51-
- Tree views for hierarchical data
52-
- Charts and plots for visualizations
53-
- Forms for data entry
54-
55-
### Signal Handling
56-
Pages connect to global signals:
57-
```python
58-
from activity_browser import app
59-
60-
app.signals.database_changed.connect(self.update_content)
61-
```
62-
63-
## Page Navigation
64-
65-
Users navigate between pages via:
66-
- Menu bar (View menu)
67-
- Toolbar buttons
68-
- Context menus
69-
- Actions triggered by events (e.g., double-click activity → show details)
25+
1. **Base pages** - Pages that are initialized once and remain in memory (e.g., Welcome Screen, Parameters, Settings).
26+
- They maintain their state and reload data on project switches.
27+
- Hidden/shown based on user actions or preferences in the settings.
28+
- Defined in `__init__.py`.
29+
2. **Dynamic pages** - Pages that show specific data and are opened as such by the user (e.g. Activity Details, LCA results).
30+
- Created on demand and closed when no longer needed.
31+
- Multiple instances can exist (e.g., multiple activity detail pages) and will be grouped.
7032

7133
## Development Guidelines
7234

7335
When creating new pages:
7436

75-
1. **Inherit from AbstractPage** - Use the base class for consistency
76-
2. **Set page title** - Provide a clear, descriptive title
77-
3. **Create toolbar** - Add relevant actions for the page
78-
4. **Connect signals** - Listen for relevant application events
79-
5. **Handle updates** - Refresh data when underlying state changes
80-
6. **Manage state** - Save/restore page state when appropriate
81-
7. **Use threading** - Long operations should not block the UI
37+
- Should follow the `PageNamePage` naming convention.
38+
- Set a unique ObjectName for identification.
39+
- Set appropriate tab titles using `setWindowTitle()`.
8240

8341
## Subdirectory Details
8442

@@ -111,6 +69,8 @@ Display LCA calculation results:
11169
- Export options
11270

11371
### `parameters/`
72+
[BASE PAGE]
73+
11474
Manage parameters and scenarios:
11575
- Project parameters
11676
- Database parameters
@@ -119,6 +79,8 @@ Manage parameters and scenarios:
11979
- Scenario management
12080

12181
### `settings/`
82+
[BASE PAGE]
83+
12284
Application configuration:
12385
- General preferences
12486
- Project settings

0 commit comments

Comments
 (0)