Skip to content

Commit

Permalink
Port to PySide6
Browse files Browse the repository at this point in the history
* Update imports to reference `PySide6`
* Update `QAction` imports, it has moved from `QtWidgets` to `QtGui`

For general porting notes, see:
  https://doc.qt.io/qtforpython-6/gettingstarted/porting_from2.html

Signed-off-by: Joao Goncalves <jsvgoncalves@gmail.com>
  • Loading branch information
jsvgoncalves committed Feb 17, 2024
1 parent 0955df9 commit 9ba7360
Show file tree
Hide file tree
Showing 90 changed files with 148 additions and 150 deletions.
4 changes: 2 additions & 2 deletions activity_browser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys
import traceback

from PySide2.QtCore import QSysInfo, __version__ as qt_version
from PySide2.QtWidgets import QApplication
from PySide6.QtCore import QSysInfo, __version__ as qt_version
from PySide6.QtWidgets import QApplication

from .application import Application
from .info import __version__
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/bwutils/calculations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2.QtWidgets import QMessageBox, QApplication
from PySide6.QtWidgets import QMessageBox, QApplication

from ..bwutils import (
Contributions, MonteCarloLCA, MLCA,
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/bwutils/multilca.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from typing import Iterable, Optional, Union
from PySide2.QtWidgets import QMessageBox, QApplication
from PySide6.QtWidgets import QMessageBox, QApplication
import numpy as np
import pandas as pd
import brightway2 as bw
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/bwutils/superstructure/dataframe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from typing import List, Tuple
from PySide2.QtWidgets import QApplication, QPushButton
from PySide2.QtCore import Qt
from PySide6.QtWidgets import QApplication, QPushButton
from PySide6.QtCore import Qt
import sys
import ast

Expand Down
2 changes: 1 addition & 1 deletion activity_browser/bwutils/superstructure/file_dialogs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PySide2 import QtWidgets, QtCore
from PySide6 import QtWidgets, QtCore
import pandas as pd


Expand Down
4 changes: 2 additions & 2 deletions activity_browser/bwutils/superstructure/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import numpy as np
import pandas as pd
from pandas.api.types import is_numeric_dtype
from PySide2.QtWidgets import QApplication, QPushButton
from PySide2.QtCore import Qt
from PySide6.QtWidgets import QApplication, QPushButton
from PySide6.QtCore import Qt
from typing import Union, Optional

import brightway2 as bw
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/bwutils/superstructure/mlca.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from typing import Iterable, Optional
from PySide2.QtWidgets import QPushButton
from PySide6.QtWidgets import QPushButton

from bw2calc.matrices import TechnosphereBiosphereMatrixBuilder as MB
import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/controllers/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import brightway2 as bw
import pandas as pd
from bw2data.backends.peewee.proxies import Activity, ExchangeProxyBase
from PySide2.QtCore import QObject, Slot, Qt
from PySide2 import QtWidgets
from PySide6.QtCore import QObject, Slot, Qt
from PySide6 import QtWidgets

from activity_browser.bwutils import AB_metadata, commontasks as bc
from activity_browser.bwutils.strategies import relink_activity_exchanges
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/controllers/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import brightway2 as bw
from bw2data.backends.peewee import sqlite3_lci_db
from bw2data.parameters import Group
from PySide2 import QtWidgets
from PySide2.QtCore import QObject, Slot, Qt
from PySide6 import QtWidgets
from PySide6.QtCore import QObject, Slot, Qt

from ..bwutils import commontasks as bc
from ..bwutils.strategies import relink_exchanges_existing_db
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/controllers/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import brightway2 as bw
from bw2data.parameters import ActivityParameter, Group, ParameterBase
from PySide2.QtCore import QObject, Slot
from PySide2.QtWidgets import QInputDialog, QMessageBox, QErrorMessage
from PySide6.QtCore import QObject, Slot
from PySide6.QtWidgets import QInputDialog, QMessageBox, QErrorMessage

from activity_browser.bwutils import commontasks as bc
from activity_browser.signals import signals
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/controllers/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pkgutil import iter_modules
from shutil import rmtree

from PySide2.QtCore import QObject, Slot
from PySide6.QtCore import QObject, Slot

from ..ui.wizards.plugins_manager_wizard import PluginsManagerWizard
from ..signals import signals
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/controllers/project.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
import brightway2 as bw
import traceback
from PySide2.QtCore import QObject, Slot
from PySide2 import QtWidgets
from PySide6.QtCore import QObject, Slot
from PySide6 import QtWidgets

from activity_browser.bwutils import commontasks as bc
from activity_browser.settings import ab_settings
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/controllers/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2.QtCore import QObject, Slot
from PySide6.QtCore import QObject, Slot

from activity_browser.bwutils import AB_metadata
from activity_browser.signals import signals
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/layouts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import shutil

from PySide2 import QtCore, QtGui, QtWidgets
from PySide6 import QtCore, QtGui, QtWidgets

from ..ui.icons import qicons
from ..ui.menu_bar import MenuBar
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/layouts/panels/panel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2 import QtWidgets, QtCore
from PySide6 import QtWidgets, QtCore

from ...signals import signals

Expand Down
2 changes: 1 addition & 1 deletion activity_browser/layouts/panels/right.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

import brightway2 as bw
from PySide2.QtWidgets import QVBoxLayout
from PySide6.QtWidgets import QVBoxLayout

from .panel import ABTab
from ...ui.web import GraphNavigatorWidget, RestrictedWebViewWidget
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/layouts/tabs/LCA_results_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import traceback

from bw2calc.errors import BW2CalcError
from PySide2.QtCore import Qt, Slot
from PySide2.QtWidgets import QMessageBox, QVBoxLayout, QApplication
from PySide6.QtCore import Qt, Slot
from PySide6.QtWidgets import QMessageBox, QVBoxLayout, QApplication

from .LCA_results_tabs import LCAResultsSubTab
from ..panels import ABTab
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/layouts/tabs/LCA_results_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from typing import List, Optional, Union
import pandas as pd

from PySide2.QtWidgets import (
from PySide6.QtWidgets import (
QWidget, QTabWidget, QVBoxLayout, QHBoxLayout, QScrollArea, QRadioButton,
QLabel, QLineEdit, QCheckBox, QPushButton, QComboBox, QTableView,
QButtonGroup, QMessageBox, QGroupBox, QGridLayout, QFileDialog,
QButtonGroup, QMessageBox, QGroupBox, QGridLayout, QFileDialog,
QApplication, QSizePolicy, QToolBar
)
from PySide2 import QtGui, QtCore
from PySide6 import QtGui, QtCore
from stats_arrays.errors import InvalidParamsError

from ...bwutils import (
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/layouts/tabs/LCA_setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from typing import Optional, Union

from PySide2 import QtWidgets
from PySide2.QtCore import Slot, Qt
from PySide6 import QtWidgets
from PySide6.QtCore import Slot, Qt
from brightway2 import calculation_setups
import pandas as pd
import re
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/layouts/tabs/activity.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
import brightway2 as bw
from peewee import DoesNotExist
from PySide2 import QtCore, QtWidgets
from PySide2.QtCore import Slot
from PySide6 import QtCore, QtWidgets
from PySide6.QtCore import Slot

from ...ui.icons import qicons
from ...ui.style import style_activity_tab
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/layouts/tabs/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from PySide2.QtCore import Slot
from PySide2.QtWidgets import QMessageBox, QWidget
from PySide6.QtCore import Slot
from PySide6.QtWidgets import QMessageBox, QWidget


class BaseRightTab(QWidget):
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/layouts/tabs/history.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2 import QtCore, QtWidgets
from PySide6 import QtCore, QtWidgets

from ...ui.style import horizontal_line, header
from ...ui.tables import ActivitiesHistoryTable
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/layouts/tabs/impact_categories.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from PySide2 import QtCore, QtWidgets
from PySide6 import QtCore, QtWidgets
from ...ui.icons import qicons

from ...ui.style import header, horizontal_line
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/layouts/tabs/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import brightway2 as bw
import pandas as pd
from PySide2.QtCore import Slot, QSize, Qt
from PySide2.QtWidgets import (
from PySide6.QtCore import Slot, QSize, Qt
from PySide6.QtWidgets import (
QCheckBox, QFileDialog, QHBoxLayout, QMessageBox, QPushButton, QToolBar,
QStyle, QVBoxLayout, QTabWidget, QSplitter, QWidget, QAbstractButton
)
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/layouts/tabs/project_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2 import QtCore, QtWidgets
from PySide6 import QtCore, QtWidgets

from ..panels import ABTab
from ...ui.style import header
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
import shutil
from typing import Optional
from PySide2.QtWidgets import QMessageBox
from PySide6.QtWidgets import QMessageBox

import appdirs
import brightway2 as bw
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2.QtCore import QObject, Signal, QModelIndex
from PySide6.QtCore import QObject, Signal, QModelIndex


class Signals(QObject):
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from matplotlib.figure import Figure
import numpy as np
import pandas as pd
from PySide2 import QtWidgets
from PySide6 import QtWidgets
import seaborn as sns

from activity_browser.utils import savefilepath
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/icons.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from pathlib import Path

from PySide2.QtGui import QIcon
from PySide6.QtGui import QIcon

PACKAGE_DIR = Path(__file__).resolve().parents[1]

Expand Down
12 changes: 6 additions & 6 deletions activity_browser/ui/menu_bar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import brightway2 as bw
from PySide2 import QtWidgets, QtGui
from PySide2.QtCore import QSize, QUrl, Slot
from PySide6 import QtWidgets, QtGui
from PySide6.QtCore import QSize, QUrl, Slot

from ..info import __version__ as ab_version
from .icons import qicons
Expand All @@ -18,18 +18,18 @@ def __init__(self, window):
self.tools_menu = QtWidgets.QMenu('&Tools', self.window)
self.help_menu = QtWidgets.QMenu('&Help', self.window)

self.update_biosphere_action = QtWidgets.QAction(
self.update_biosphere_action = QtGui.QAction(
window.style().standardIcon(QtWidgets.QStyle.SP_BrowserReload),
"&Update biosphere...", None
)
self.export_db_action = QtWidgets.QAction(
self.export_db_action = QtGui.QAction(
self.window.style().standardIcon(QtWidgets.QStyle.SP_DriveHDIcon),
"&Export database...", None
)
self.import_db_action = QtWidgets.QAction(
self.import_db_action = QtGui.QAction(
qicons.import_db, '&Import database...', None
)
self.manage_plugins_action = QtWidgets.QAction(
self.manage_plugins_action = QtGui.QAction(
qicons.plugin, '&Plugins...', None
)

Expand Down
4 changes: 2 additions & 2 deletions activity_browser/ui/statusbar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from PySide2.QtCore import Slot
from PySide2.QtWidgets import QLabel, QStatusBar
from PySide6.QtCore import Slot
from PySide6.QtWidgets import QLabel, QStatusBar

import brightway2 as bw

Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/style.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2 import QtGui, QtWidgets
from PySide6 import QtGui, QtWidgets

default_font = QtGui.QFont('Arial', 8)

Expand Down
4 changes: 2 additions & 2 deletions activity_browser/ui/tables/LCA_setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import brightway2 as bw
from PySide2.QtCore import Slot, Qt
from PySide2 import QtWidgets
from PySide6.QtCore import Slot, Qt
from PySide6 import QtWidgets

from activity_browser.signals import signals
from ..icons import qicons
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/ui/tables/activity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from PySide2 import QtWidgets
from PySide2.QtCore import Slot
from PySide6 import QtWidgets
from PySide6.QtCore import Slot

from .delegates import *
from .models import (
Expand Down
4 changes: 1 addition & 3 deletions activity_browser/ui/tables/delegates/checkbox.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2 import QtCore, QtWidgets
from PySide6 import QtCore, QtWidgets


class CheckboxDelegate(QtWidgets.QStyledItemDelegate):
Expand All @@ -16,8 +16,6 @@ def paint(self, painter, option, index):
https://stackoverflow.com/a/11778012
https://stackoverflow.com/q/15235273
NOTE: PyQt 5.9.2 needs to treat OSX different from others.
PySide2 5.13.1 and higher no longer has this issue.
"""
painter.save()
value = bool(index.data(QtCore.Qt.DisplayRole))
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/tables/delegates/database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from bw2data import databases
from PySide2 import QtCore, QtWidgets
from PySide6 import QtCore, QtWidgets


class DatabaseDelegate(QtWidgets.QStyledItemDelegate):
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/tables/delegates/float.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import math

from PySide2 import QtCore, QtGui, QtWidgets
from PySide6 import QtCore, QtGui, QtWidgets


class FloatDelegate(QtWidgets.QStyledItemDelegate):
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/ui/tables/delegates/formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from os import devnull

from asteval import Interpreter
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Signal, Slot
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Signal, Slot

from activity_browser.signals import signals
from activity_browser.ui.icons import qicons
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/tables/delegates/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from itertools import zip_longest
from typing import List

from PySide2 import QtCore, QtGui, QtWidgets
from PySide6 import QtCore, QtGui, QtWidgets


class OrderedListInputDialog(QtWidgets.QDialog):
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/tables/delegates/string.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from PySide2 import QtCore, QtWidgets
from PySide6 import QtCore, QtWidgets


class StringDelegate(QtWidgets.QStyledItemDelegate):
Expand Down
Loading

0 comments on commit 9ba7360

Please sign in to comment.