brightway-basic-explorer 0.9.dev0__tar.gz → 0.9.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (17) hide show
  1. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/PKG-INFO +30 -2
  2. brightway_basic_explorer-0.9.dev1/README.md +28 -0
  3. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/brightway_basic_explorer/__init__.py +37 -8
  4. brightway_basic_explorer-0.9.dev1/brightway_basic_explorer/icons/emission.png +0 -0
  5. brightway_basic_explorer-0.9.dev1/brightway_basic_explorer/icons/natural_resource.png +0 -0
  6. brightway_basic_explorer-0.9.dev1/brightway_basic_explorer/icons/process.png +0 -0
  7. brightway_basic_explorer-0.9.dev1/brightway_basic_explorer/icons/unknown.png +0 -0
  8. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/brightway_basic_explorer.egg-info/PKG-INFO +30 -2
  9. brightway_basic_explorer-0.9.dev1/brightway_basic_explorer.egg-info/SOURCES.txt +12 -0
  10. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/pyproject.toml +5 -3
  11. brightway_basic_explorer-0.9.dev0/README.md +0 -0
  12. brightway_basic_explorer-0.9.dev0/brightway_basic_explorer.egg-info/SOURCES.txt +0 -9
  13. brightway_basic_explorer-0.9.dev0/brightway_basic_explorer.egg-info/requires.txt +0 -1
  14. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/COPYING +0 -0
  15. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/brightway_basic_explorer.egg-info/dependency_links.txt +0 -0
  16. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/brightway_basic_explorer.egg-info/top_level.txt +0 -0
  17. {brightway_basic_explorer-0.9.dev0 → brightway_basic_explorer-0.9.dev1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brightway-basic-explorer
3
- Version: 0.9.dev0
3
+ Version: 0.9.dev1
4
4
  Summary: Implement basic GUI to explorer brightway ativities
5
5
  Author-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>, OIE - Mines Paris PSL <benoit.gschwind@minesparis.psl.eu>
6
6
  Maintainer-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>
@@ -16,5 +16,33 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Requires-Python: >=3.10
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: COPYING
19
- Requires-Dist: PyQt6
20
19
  Dynamic: license-file
20
+
21
+ # Brightway Basic Explorer
22
+
23
+ Implement a basic activity explorer mostly to use in interractive python such as notebooks, ipython and spyder.
24
+
25
+ # Install
26
+
27
+ ```
28
+ pip install brightway_basic_explorer
29
+ ```
30
+
31
+ # Sample and Documentation
32
+
33
+ ![Sample Window](https://github.com/gschwind/brightway-basic-explorer/raw/main/doc/sample-window.png)
34
+
35
+ ```python
36
+ import bw2data
37
+ from brightway_basic_explorer import show_activity, close_all
38
+
39
+ db = bw2data.Database("ecoinvent-3.11-cutoff")
40
+
41
+ act = db.search("570kWp")
42
+
43
+ # Show the first activity
44
+ show_activity(act[0])
45
+
46
+ # Close all activity windows
47
+ close_all()
48
+ ```
@@ -0,0 +1,28 @@
1
+ # Brightway Basic Explorer
2
+
3
+ Implement a basic activity explorer mostly to use in interractive python such as notebooks, ipython and spyder.
4
+
5
+ # Install
6
+
7
+ ```
8
+ pip install brightway_basic_explorer
9
+ ```
10
+
11
+ # Sample and Documentation
12
+
13
+ ![Sample Window](https://github.com/gschwind/brightway-basic-explorer/raw/main/doc/sample-window.png)
14
+
15
+ ```python
16
+ import bw2data
17
+ from brightway_basic_explorer import show_activity, close_all
18
+
19
+ db = bw2data.Database("ecoinvent-3.11-cutoff")
20
+
21
+ act = db.search("570kWp")
22
+
23
+ # Show the first activity
24
+ show_activity(act[0])
25
+
26
+ # Close all activity windows
27
+ close_all()
28
+ ```
@@ -3,6 +3,7 @@
3
3
  from IPython.external.qt_for_kernel import QtGui, QtCore
4
4
  from IPython.lib.guisupport import start_event_loop_qt4, get_app_qt4, is_event_loop_running_qt4
5
5
 
6
+ import os
6
7
  import matplotlib
7
8
  import bw2data
8
9
 
@@ -40,10 +41,23 @@ class TableModel(QtGui.QStandardItemModel):
40
41
  self.exchanges = [e for e in data]
41
42
  self.root = self.invisibleRootItem()
42
43
  for e in data:
43
- self.root.appendRow([
44
+ row = [
44
45
  QStandardItemRO(str(e.get(k, "-")), data=e)
45
46
  for k in ["name", "unit", "categories", "location", "amount", "formula"]
46
- ])
47
+ ]
48
+
49
+ etype = e.get("type", "unknown")
50
+ if etype == "emission":
51
+ path = os.path.join(os.path.dirname(__file__), "icons", "emission.png")
52
+ elif etype == "process":
53
+ path = os.path.join(os.path.dirname(__file__), "icons", "process.png")
54
+ elif etype == "natural resource":
55
+ path = os.path.join(os.path.dirname(__file__), "icons", "natural_resource.png")
56
+ else:
57
+ path = os.path.join(os.path.dirname(__file__), "icons", "unknown.png")
58
+
59
+ row[0].setIcon(QtGui.QIcon(path))
60
+ self.root.appendRow(row)
47
61
 
48
62
  class ActionMenu(QtGui.QMenu):
49
63
  def __init__(self, parent, index):
@@ -53,12 +67,21 @@ class ActionMenu(QtGui.QMenu):
53
67
  self.action_copy = self.addAction("Copy")
54
68
  self.action_copy.triggered.connect(self.copy_triggered)
55
69
 
70
+ self.action_copy = self.addAction("Copy Full Reference")
71
+ self.action_copy.triggered.connect(self.copy_full_reference_triggered)
72
+
56
73
  self.action_explore = self.addAction("Explore")
57
74
  self.action_explore.triggered.connect(self.explore_triggered)
58
75
 
59
76
  def copy_triggered(self):
60
77
  QtGui.QGuiApplication.clipboard().setText(self.index.data())
61
78
 
79
+ def copy_full_reference_triggered(self):
80
+ parent = self.parentWidget()
81
+ v = parent.model.root.child(self.index.row(), 0).data()
82
+ text = (v["database"], v["name"], v.get("location", None), v.get("categories", tuple()), v.get("unit", None))
83
+ QtGui.QGuiApplication.clipboard().setText(str(text))
84
+
62
85
  def explore_triggered(self):
63
86
  self.parentWidget().explore(self.index)
64
87
 
@@ -84,15 +107,16 @@ class ActivityWindow(QtGui.QMainWindow):
84
107
  grid = QtGui.QGridLayout()
85
108
  layout.addLayout(grid)
86
109
 
87
- for i, k in enumerate(["database", "name", "location", "unit", "categories"]):
110
+ for i, k in enumerate(["database", "name", "location", "unit", "categories", "type"]):
88
111
  grid.addWidget(QtGui.QLabel(f"{k}:"), i, 0)
89
112
  x = QtGui.QLabel(f"{str(data.get(k, '-'))}")
90
113
  x.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
91
114
  grid.addWidget(x, i, 1)
92
- grid.addWidget(QtGui.QLabel("filter:"), 5, 0)
115
+ next_row = grid.rowCount()
116
+ grid.addWidget(QtGui.QLabel("filter:"), next_row, 0)
93
117
  self.filter_edit = QtGui.QLineEdit("")
94
118
  self.filter_edit.textChanged.connect(self.update_filter)
95
- grid.addWidget(self.filter_edit, 5, 1)
119
+ grid.addWidget(self.filter_edit, next_row, 1)
96
120
  grid.setColumnStretch(0, 0)
97
121
  grid.setColumnStretch(1, 1)
98
122
  self.ignore_case = QtGui.QCheckBox("Ignore Case")
@@ -101,7 +125,8 @@ class ActivityWindow(QtGui.QMainWindow):
101
125
  self.ignore_case.checkStateChanged.connect(self.update_filter)
102
126
  else:
103
127
  self.ignore_case.stateChanged.connect(self.update_filter)
104
- grid.addWidget(self.ignore_case, 6, 1)
128
+ next_row = grid.rowCount()
129
+ grid.addWidget(self.ignore_case, next_row, 1)
105
130
  # Create tree view
106
131
  self.tree_view = QtGui.QTreeView()
107
132
  layout.addWidget(self.tree_view)
@@ -124,7 +149,8 @@ class ActivityWindow(QtGui.QMainWindow):
124
149
  self.action_menu.exec(self.tree_view.viewport().mapToGlobal(point))
125
150
 
126
151
  def closeEvent(self, ev):
127
- #del ActivityWindow.keep[self.act]
152
+ if self.act.key in ActivityWindow.keep:
153
+ del ActivityWindow.keep[self.act.key]
128
154
  super().closeEvent(ev)
129
155
 
130
156
  def update_filter(self, *args):
@@ -168,5 +194,8 @@ def show_activity(act):
168
194
  if not is_event_loop_running_qt4(app):
169
195
  start_event_loop_qt4(app)
170
196
 
197
+ window.activateWindow()
171
198
 
172
-
199
+ def close_all():
200
+ for w in list(ActivityWindow.keep.values()):
201
+ w.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brightway-basic-explorer
3
- Version: 0.9.dev0
3
+ Version: 0.9.dev1
4
4
  Summary: Implement basic GUI to explorer brightway ativities
5
5
  Author-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>, OIE - Mines Paris PSL <benoit.gschwind@minesparis.psl.eu>
6
6
  Maintainer-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>
@@ -16,5 +16,33 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Requires-Python: >=3.10
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: COPYING
19
- Requires-Dist: PyQt6
20
19
  Dynamic: license-file
20
+
21
+ # Brightway Basic Explorer
22
+
23
+ Implement a basic activity explorer mostly to use in interractive python such as notebooks, ipython and spyder.
24
+
25
+ # Install
26
+
27
+ ```
28
+ pip install brightway_basic_explorer
29
+ ```
30
+
31
+ # Sample and Documentation
32
+
33
+ ![Sample Window](https://github.com/gschwind/brightway-basic-explorer/raw/main/doc/sample-window.png)
34
+
35
+ ```python
36
+ import bw2data
37
+ from brightway_basic_explorer import show_activity, close_all
38
+
39
+ db = bw2data.Database("ecoinvent-3.11-cutoff")
40
+
41
+ act = db.search("570kWp")
42
+
43
+ # Show the first activity
44
+ show_activity(act[0])
45
+
46
+ # Close all activity windows
47
+ close_all()
48
+ ```
@@ -0,0 +1,12 @@
1
+ COPYING
2
+ README.md
3
+ pyproject.toml
4
+ brightway_basic_explorer/__init__.py
5
+ brightway_basic_explorer.egg-info/PKG-INFO
6
+ brightway_basic_explorer.egg-info/SOURCES.txt
7
+ brightway_basic_explorer.egg-info/dependency_links.txt
8
+ brightway_basic_explorer.egg-info/top_level.txt
9
+ brightway_basic_explorer/icons/emission.png
10
+ brightway_basic_explorer/icons/natural_resource.png
11
+ brightway_basic_explorer/icons/process.png
12
+ brightway_basic_explorer/icons/unknown.png
@@ -12,8 +12,8 @@ name = "brightway-basic-explorer"
12
12
  description = "Implement basic GUI to explorer brightway ativities"
13
13
  readme = "README.md"
14
14
  license-files = ["COPYING"]
15
- version = "0.9.dev0"
16
- dependencies = [ "PyQt6" ]
15
+ version = "0.9.dev1"
16
+ dependencies = [ ]
17
17
  requires-python = ">= 3.10"
18
18
  keywords = ["lca", "ecoinvent", "brightway"]
19
19
  classifiers = [
@@ -28,4 +28,6 @@ Repository = "https://github.com/gschwind/brightway-basic-explorer"
28
28
  Documentation = "https://github.com/gschwind/brightway-basic-explorer"
29
29
  Issues = "https://github.com/gschwind/brightway-basic-explorer/issues"
30
30
  [tool.setuptools]
31
- packages = ["brightway_basic_explorer"]
31
+ packages = ["brightway_basic_explorer", "brightway_basic_explorer.icons"]
32
+ [tool.setuptools.package-data]
33
+ "brightway_basic_explorer.icons" = ["*.png"]
File without changes
@@ -1,9 +0,0 @@
1
- COPYING
2
- README.md
3
- pyproject.toml
4
- brightway_basic_explorer/__init__.py
5
- brightway_basic_explorer.egg-info/PKG-INFO
6
- brightway_basic_explorer.egg-info/SOURCES.txt
7
- brightway_basic_explorer.egg-info/dependency_links.txt
8
- brightway_basic_explorer.egg-info/requires.txt
9
- brightway_basic_explorer.egg-info/top_level.txt