Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to QtPy compatibility #1404

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Adding parents to graphs
mrvisscher committed Sep 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7cfb0e68ee9966ffa9d381c7859d95f4bd39ded5
3 changes: 2 additions & 1 deletion activity_browser/application.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from logging import getLogger

from qtpy.QtCore import QCoreApplication, QObject, QSysInfo, Qt
from qtpy.QtWidgets import QApplication
from qtpy.QtWidgets import QApplication, QStyleFactory

log = getLogger(__name__)

@@ -55,3 +55,4 @@ def deleteLater(self):
QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True)

application = ABApplication()
application.setStyle(QStyleFactory.create("fusion"))
4 changes: 2 additions & 2 deletions activity_browser/layouts/tabs/LCA_results_tabs.py
Original file line number Diff line number Diff line change
@@ -893,7 +893,7 @@ def __init__(self, parent, **kwargs):
)

self.df = None
self.plot = ContributionPlot()
self.plot = ContributionPlot(self)
self.table = ContributionTable(self)
self.contribution_fn = None
self.has_method, self.has_func = False, False
@@ -1045,7 +1045,7 @@ def update_plot(self):
# name is already altered by set_filename before update_plot occurs.
name = self.plot.plot_name
self.plot.deleteLater()
self.plot = ContributionPlot()
self.plot = ContributionPlot(self)
self.pt_layout.insertWidget(idx, self.plot)
super().update_plot(self.df, unit=self.unit)
self.plot.plot_name = name
10 changes: 8 additions & 2 deletions activity_browser/ui/figures.py
Original file line number Diff line number Diff line change
@@ -34,6 +34,9 @@ def __init__(self, parent=None):
self.figure = Figure(constrained_layout=True)
self.canvas = FigureCanvasQTAgg(self.figure)
self.canvas.setMinimumHeight(0)

self.canvas.destroyed.connect(self.check)

self.ax = self.figure.add_subplot(111) # create an axis
self.plot_name = "Figure"

@@ -46,6 +49,9 @@ def __init__(self, parent=None):
)
self.updateGeometry()

def check(self):
print("WHY DELETE")

def plot(self, *args, **kwargs):
raise NotImplementedError

@@ -177,8 +183,8 @@ def plot(self, df: pd.DataFrame, invert_plot: bool = False):
class ContributionPlot(Plot):
MAX_LEGEND = 30

def __init__(self):
super().__init__()
def __init__(self, parent=None):
super().__init__(parent)
self.plot_name = "Contributions"

def plot(self, df: pd.DataFrame, unit: str = None):