brightway-basic-explorer 0.9.dev3__tar.gz → 0.9.dev4__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.
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/PKG-INFO +1 -1
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer/__init__.py +89 -52
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer.egg-info/PKG-INFO +1 -1
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/pyproject.toml +1 -1
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/COPYING +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/README.md +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer/icons/emission.png +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer/icons/natural_resource.png +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer/icons/process.png +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer/icons/unknown.png +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer.egg-info/SOURCES.txt +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer.egg-info/dependency_links.txt +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer.egg-info/requires.txt +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/brightway_basic_explorer.egg-info/top_level.txt +0 -0
- {brightway_basic_explorer-0.9.dev3 → brightway_basic_explorer-0.9.dev4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brightway-basic-explorer
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.dev4
|
|
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>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
2
|
|
|
3
3
|
from IPython.external.qt_for_kernel import QtGui, QtCore
|
|
4
|
-
from IPython.lib.guisupport import
|
|
4
|
+
from IPython.lib.guisupport import get_app_qt4, is_event_loop_running_qt4
|
|
5
5
|
|
|
6
6
|
import os
|
|
7
7
|
import sys
|
|
@@ -26,7 +26,7 @@ def activity_to_json_with_params(act, params):
|
|
|
26
26
|
_getAmountOrFormula,
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
-
from sympy import Basic
|
|
29
|
+
from sympy import Basic
|
|
30
30
|
except:
|
|
31
31
|
raise Exception("lca_algebraic not found, please install it before using show_activity_with_params")
|
|
32
32
|
|
|
@@ -39,11 +39,10 @@ def activity_to_json_with_params(act, params):
|
|
|
39
39
|
|
|
40
40
|
# Params provided ? Evaluate formulas
|
|
41
41
|
if isinstance(amount, Basic):
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
print(amount)
|
|
42
|
+
new_params = list(_complete_and_expand_params(params, list(all_params().keys())).items())
|
|
43
|
+
amount = amount.subs(new_params)
|
|
44
|
+
if amount.is_number:
|
|
45
|
+
amount = float(amount.evalf())
|
|
47
46
|
de["computed_amount"] = True
|
|
48
47
|
|
|
49
48
|
de["amount"] = amount
|
|
@@ -110,6 +109,9 @@ class ActionMenu(QtGui.QMenu):
|
|
|
110
109
|
self.action_explore = self.addAction("Explore")
|
|
111
110
|
self.action_explore.triggered.connect(self.explore_triggered)
|
|
112
111
|
|
|
112
|
+
self.action_explore = self.addAction("Explore in new window")
|
|
113
|
+
self.action_explore.triggered.connect(self.explore_in_new_window_triggered)
|
|
114
|
+
|
|
113
115
|
def copy_triggered(self):
|
|
114
116
|
QtGui.QGuiApplication.clipboard().setText(self.index.data())
|
|
115
117
|
|
|
@@ -122,22 +124,75 @@ class ActionMenu(QtGui.QMenu):
|
|
|
122
124
|
def explore_triggered(self):
|
|
123
125
|
self.parentWidget().explore(self.index)
|
|
124
126
|
|
|
127
|
+
def explore_in_new_window_triggered(self):
|
|
128
|
+
self.parentWidget().explore_in_new_window(self.index)
|
|
129
|
+
|
|
130
|
+
class TabBar(QtGui.QTabBar):
|
|
131
|
+
def __init__(self):
|
|
132
|
+
super().__init__()
|
|
133
|
+
|
|
134
|
+
def tabSizeHint(self, index):
|
|
135
|
+
value = super().tabSizeHint(index)
|
|
136
|
+
return QtCore.QSize(200, value.height())
|
|
137
|
+
|
|
138
|
+
def minimumTabSizeHint(self, index):
|
|
139
|
+
value = super().minimumTabSizeHint(index)
|
|
140
|
+
return QtCore.QSize(100, value.height())
|
|
141
|
+
|
|
125
142
|
|
|
126
143
|
class ActivityWindow(QtGui.QMainWindow):
|
|
127
|
-
keep =
|
|
144
|
+
keep = list()
|
|
128
145
|
|
|
129
|
-
def __init__(self, activity_json):
|
|
146
|
+
def __init__(self, activity_json, params=None):
|
|
130
147
|
super().__init__()
|
|
131
|
-
self.
|
|
148
|
+
self.tabs = dict()
|
|
149
|
+
self.xcount = 0
|
|
150
|
+
self.params = params
|
|
132
151
|
|
|
133
152
|
self.setWindowTitle("Activity Viewer")
|
|
134
|
-
self.
|
|
153
|
+
self.setMinimumSize(QtCore.QSize(800, 600))
|
|
154
|
+
|
|
155
|
+
self.tabs_widget = QtGui.QTabWidget()
|
|
156
|
+
self.tabs_widget.setTabBar(TabBar())
|
|
157
|
+
self.tabs_widget.setTabsClosable(True)
|
|
158
|
+
self.tabs_widget.setMovable(True)
|
|
159
|
+
self.tabs_widget.tabCloseRequested.connect(self.close_tab)
|
|
160
|
+
self.tabs_widget.setElideMode(QtCore.Qt.TextElideMode.ElideRight)
|
|
161
|
+
self.setCentralWidget(self.tabs_widget)
|
|
162
|
+
self.add_activity(activity_json)
|
|
163
|
+
|
|
164
|
+
def add_activity(self, activity_json):
|
|
165
|
+
key = (activity_json["database"], activity_json["code"])
|
|
166
|
+
if key in self.tabs:
|
|
167
|
+
activity_widget = self.tabs[key]
|
|
168
|
+
self.tabs_widget.setCurrentWidget(activity_widget)
|
|
169
|
+
return
|
|
170
|
+
|
|
171
|
+
activity_widget = ActivityTab(self, activity_json)
|
|
172
|
+
self.tabs[activity_widget.activity_key] = activity_widget
|
|
173
|
+
self.tabs_widget.addTab(activity_widget, f"#{self.xcount} "+activity_json["name"])
|
|
174
|
+
self.tabs_widget.setCurrentWidget(activity_widget)
|
|
175
|
+
activity_widget.tree_view.setColumnWidth(0, 400)
|
|
176
|
+
self.xcount += 1
|
|
177
|
+
|
|
178
|
+
def close_tab(self, index):
|
|
179
|
+
w = self.tabs_widget.widget(index)
|
|
180
|
+
del self.tabs[w.activity_key]
|
|
181
|
+
self.tabs_widget.removeTab(index)
|
|
182
|
+
|
|
183
|
+
def closeEvent(self, ev):
|
|
184
|
+
ActivityWindow.keep.remove(self)
|
|
185
|
+
super().closeEvent(ev)
|
|
186
|
+
|
|
187
|
+
class ActivityTab(QtGui.QWidget):
|
|
188
|
+
def __init__(self, xparent, activity_json):
|
|
189
|
+
super().__init__()
|
|
190
|
+
|
|
191
|
+
self.xparent = xparent
|
|
192
|
+
self.activity_key = (activity_json["database"], activity_json["code"])
|
|
135
193
|
|
|
136
|
-
# Create central widget and layout
|
|
137
|
-
central_widget = QtGui.QWidget()
|
|
138
|
-
self.setCentralWidget(central_widget)
|
|
139
194
|
layout = QtGui.QVBoxLayout()
|
|
140
|
-
|
|
195
|
+
self.setLayout(layout)
|
|
141
196
|
|
|
142
197
|
grid = QtGui.QGridLayout()
|
|
143
198
|
layout.addLayout(grid)
|
|
@@ -183,11 +238,6 @@ class ActivityWindow(QtGui.QMainWindow):
|
|
|
183
238
|
self.action_menu = ActionMenu(self, index)
|
|
184
239
|
self.action_menu.exec(self.tree_view.viewport().mapToGlobal(point))
|
|
185
240
|
|
|
186
|
-
def closeEvent(self, ev):
|
|
187
|
-
if self.activity_key in ActivityWindow.keep:
|
|
188
|
-
del ActivityWindow.keep[self.activity_key]
|
|
189
|
-
super().closeEvent(ev)
|
|
190
|
-
|
|
191
241
|
def update_filter(self, *args):
|
|
192
242
|
text = self.filter_edit.text()
|
|
193
243
|
if self.ignore_case.isChecked():
|
|
@@ -208,28 +258,19 @@ class ActivityWindow(QtGui.QMainWindow):
|
|
|
208
258
|
def explore(self, index):
|
|
209
259
|
r = index.row()
|
|
210
260
|
v = self.model.root.child(r, 0).data()
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
class ActivityWindowWithParams(ActivityWindow):
|
|
218
|
-
keep = dict()
|
|
219
|
-
|
|
220
|
-
def __init__(self, activity_json, params):
|
|
221
|
-
super().__init__(activity_json)
|
|
222
|
-
self.params = params
|
|
223
|
-
|
|
224
|
-
def closeEvent(self, ev):
|
|
225
|
-
if self.activity_key in ActivityWindow.keep:
|
|
226
|
-
del ActivityWindowWithParams.keep[self.activity_key]
|
|
227
|
-
super().closeEvent(ev)
|
|
261
|
+
act = bw2data.get_activity((v["database"], v["code"]))
|
|
262
|
+
if self.xparent.params is None:
|
|
263
|
+
activity_json = activity_to_json(act)
|
|
264
|
+
else:
|
|
265
|
+
activity_json = activity_to_json_with_params(act, self.xparent.params)
|
|
266
|
+
self.xparent.add_activity(activity_json)
|
|
228
267
|
|
|
229
|
-
def
|
|
268
|
+
def explore_in_new_window(self, index):
|
|
230
269
|
r = index.row()
|
|
231
270
|
v = self.model.root.child(r, 0).data()
|
|
232
|
-
|
|
271
|
+
act = bw2data.get_activity((v["database"], v["code"]))
|
|
272
|
+
show_activity(act, self.xparent.params)
|
|
273
|
+
|
|
233
274
|
|
|
234
275
|
# Replace IPython version to one compatible with Qt6
|
|
235
276
|
def start_event_loop_qt4(app=None):
|
|
@@ -246,7 +287,7 @@ def start_event_loop_qt4(app=None):
|
|
|
246
287
|
else:
|
|
247
288
|
app._in_event_loop = True
|
|
248
289
|
|
|
249
|
-
def
|
|
290
|
+
def show_activity(act, params=None):
|
|
250
291
|
|
|
251
292
|
if 'matplotlib' in sys.modules:
|
|
252
293
|
import matplotlib
|
|
@@ -256,9 +297,13 @@ def _show_activity(cls, activity_json, *args):
|
|
|
256
297
|
|
|
257
298
|
app = get_app_qt4()
|
|
258
299
|
|
|
259
|
-
if
|
|
260
|
-
|
|
261
|
-
|
|
300
|
+
if params is None:
|
|
301
|
+
activity_json = activity_to_json(act)
|
|
302
|
+
else:
|
|
303
|
+
activity_json = activity_to_json_with_params(act, params)
|
|
304
|
+
|
|
305
|
+
window = ActivityWindow(activity_json, params)
|
|
306
|
+
ActivityWindow.keep.append(window)
|
|
262
307
|
window.show()
|
|
263
308
|
|
|
264
309
|
if not is_event_loop_running_qt4(app):
|
|
@@ -266,14 +311,6 @@ def _show_activity(cls, activity_json, *args):
|
|
|
266
311
|
|
|
267
312
|
window.activateWindow()
|
|
268
313
|
|
|
269
|
-
def show_activity(act):
|
|
270
|
-
activity_json = activity_to_json(act)
|
|
271
|
-
_show_activity(ActivityWindow, activity_json)
|
|
272
|
-
|
|
273
|
-
def show_activity_with_params(act, params):
|
|
274
|
-
activity_json = activity_to_json_with_params(act, params)
|
|
275
|
-
_show_activity(ActivityWindowWithParams, activity_json, params)
|
|
276
|
-
|
|
277
314
|
def close_all():
|
|
278
|
-
for w in list(ActivityWindow.keep
|
|
315
|
+
for w in list(ActivityWindow.keep):
|
|
279
316
|
w.close()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brightway-basic-explorer
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.dev4
|
|
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>
|
|
@@ -12,7 +12,7 @@ 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.
|
|
15
|
+
version = "0.9.dev4"
|
|
16
16
|
dependencies = [ "ipython" ]
|
|
17
17
|
requires-python = ">= 3.10"
|
|
18
18
|
keywords = ["lca", "ecoinvent", "brightway"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|