Skip to content

Commit

Permalink
Merge pull request #1476 from HEXRD/pyside6
Browse files Browse the repository at this point in the history
Upgrade to PySide6
  • Loading branch information
psavery authored Oct 19, 2023
2 parents f23950c + 55aaf85 commit f93458a
Show file tree
Hide file tree
Showing 292 changed files with 1,190 additions and 1,120 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: hexrdgui
Expand All @@ -44,9 +44,13 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: '3.10'
python-version: '3.11'
auto-activate-base: false

- name: Install EGL on Linux (PySide6 needs it)
if: ${{ matrix.config.name == 'Linux' }}
run: sudo apt-get install -y libegl1-mesa-dev

- name: Get version using git describe
working-directory: hexrdgui
run: echo "HEXRDGUI_GIT_DESCRIBE=$(git describe --tag)" >> $GITHUB_ENV
Expand Down Expand Up @@ -89,34 +93,34 @@ jobs:

- name: Upload InstallOutput.log
if: ${{ failure() }}
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v3
with:
name: InstallOutput.log
path: ${{ github.workspace }}/hexrdgui/packaging/_CPack_Packages/*/InstallOutput.log

- name: Upload WIX log ( Windows only )
if: ${{ failure() && matrix.config.os == 'windows-latest'}}
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v3
with:
name: wix.log
path: ${{ github.workspace }}/hexrdgui/packaging/_CPack_Packages/WIX/wix.log

- name: Upload installer package
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v3
with:
name: HEXRDGUI-v${{env.VERSION}}.${{ matrix.config.package }}
path: ${{ github.workspace }}/hexrdgui/packaging/HEXRDGUI-${{env.VERSION}}.${{ matrix.config.package }}

- name: Upload installer package Zip ( Windows only )
if: ${{ matrix.config.os == 'windows-latest'}}
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v3
with:
name: HEXRDGUI-v${{env.VERSION}}.zip
path: ${{ github.workspace }}/hexrdgui/packaging/HEXRDGUI-${{env.VERSION}}.zip

- name: Upload the HEXRDGUI conda package ( PRs only )
if: github.ref != 'refs/heads/master'
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v3
with:
name: HEXRDGUI-${{ matrix.config.name }}-${{ env.HEXRDGUI_GIT_DESCRIBE }}.tar.bz2
path: ${{ github.workspace }}/hexrdgui/packaging/output/**/*.tar.bz2
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: [3.9, '3.10']
python-version: ['3.10', '3.11']
config:
- {
name: "Linux",
Expand All @@ -39,25 +39,29 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Checkout HEXRD
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: HEXRD/hexrd
path: hexrd

- name: Checkout HEXRDGUI
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: hexrdgui

- name: Checkout examples
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: HEXRD/examples
path: examples

- name: Install EGL on Linux (PySide6 needs it)
if: ${{ matrix.config.name == 'Linux' }}
run: sudo apt-get install -y libegl1-mesa-dev

- name: Set environment variable to work around setuptools/numpy issue
run: echo 'SETUPTOOLS_USE_DISTUTILS=stdlib' >> $GITHUB_ENV
if: ${{ matrix.config.os == 'windows-latest'}}
if: ${{ matrix.config.name == 'Windows' }}

- name: Install HEXRD
run: |
Expand Down
7 changes: 7 additions & 0 deletions conda.recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
python:
- 3.11
target_platform:
- linux-64 # [linux]
- osx-64 # [osx]
- osx-arm64 # [osx]
- win-64 # [win]
24 changes: 13 additions & 11 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,34 @@ source:
build:
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
entry_points:
- hexrdgui = hexrd.ui.main:main
- hexrdgui = hexrdgui.main:main

requirements:
build:
- python=3.10
- python {{ python }} # [build_platform != target_platform]
- cross-python_{{ target_platform }} # [build_platform != target_platform]
host:
- python {{ python }}
- setuptools
- setuptools_scm

run:
- python
- pyside2>=5.15
- Pillow
- matplotlib
- importlib_resources
- fabio
- pyyaml
- hexrd=={{ hexrd_version }}
- matplotlib-base
- Pillow
- pyhdf
- silx
- pyside6
- pyyaml
- silx-base

test:
test: # [build_platform == target_platform]
imports:
- hexrd.ui
- hexrdgui

about:
home: https://github.com/HEXRD/hexrdgui
license: BSD
license_family: BSD
summary: "Qt5 PySide2 based HEXRD GUI"
summary: "Qt6 PySide6 based HEXRD GUI"
1 change: 0 additions & 1 deletion hexrd/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions hexrd/ui/__init__.py → hexrdgui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PySide2.QtCore import QEvent, QObject, Qt
from PySide2.QtWidgets import QDialog, QPushButton
from PySide6.QtCore import QEvent, QObject, Qt
from PySide6.QtWidgets import QDialog, QPushButton


class EnterKeyFilter(QObject):
Expand Down
22 changes: 11 additions & 11 deletions hexrd/ui/about_dialog.py → hexrdgui/about_dialog.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from importlib.metadata import version
import sys

from PySide2.QtCore import Qt, QObject, QSize
from PySide2.QtSvg import QSvgWidget
from PySide2.QtWidgets import QTreeWidgetItem, QLabel
from PySide2.QtGui import QPixmap
from PySide6.QtCore import Qt, QObject, QSize
from PySide6.QtSvgWidgets import QSvgWidget
from PySide6.QtWidgets import QTreeWidgetItem, QLabel
from PySide6.QtGui import QPixmap

import hexrd

from hexrd.ui.ui_loader import UiLoader
from hexrd.ui.resource_loader import load_resource
from hexrdgui.ui_loader import UiLoader
from hexrdgui.resource_loader import load_resource

LOGO_HEIGHT = 80

Expand All @@ -24,7 +24,7 @@ def __init__(self, parent=None):
self._populate_versions()

def _populate_hexrd_logo(self):
data = load_resource(hexrd.ui.resources.icons,
data = load_resource(hexrdgui.resources.icons,
'hexrd.ico', binary=True)
pixmap = QPixmap()
pixmap.loadFromData(data, 'ico')
Expand All @@ -36,7 +36,7 @@ def _calculate_size(self, size):
return QSize(LOGO_HEIGHT/ratio, LOGO_HEIGHT)

def _populate_logos(self):
data = load_resource(hexrd.ui.resources.icons, 'llnl_logo.svg',
data = load_resource(hexrdgui.resources.icons, 'llnl_logo.svg',
binary=True)

self.ui.logos_horizontal_layout.addStretch()
Expand All @@ -47,7 +47,7 @@ def _populate_logos(self):
self.ui.logos_horizontal_layout.addWidget(llnl, stretch=1)
self.ui.logos_horizontal_layout.addStretch()

data = load_resource(hexrd.ui.resources.icons,
data = load_resource(hexrdgui.resources.icons,
'kitware_logo.svg', binary=True)

kitware = QSvgWidget()
Expand All @@ -57,7 +57,7 @@ def _populate_logos(self):
self.ui.logos_horizontal_layout.addWidget(kitware, stretch=1)
self.ui.logos_horizontal_layout.addStretch()

data = load_resource(hexrd.ui.resources.icons,
data = load_resource(hexrdgui.resources.icons,
'afrl_logo.png', binary=True)

pixmap = QPixmap()
Expand All @@ -78,7 +78,7 @@ def _populate_versions(self):
"HEXRD",
"NumPy",
"SciPy",
"PySide2"
"PySide6"
]

for package in packages:
Expand Down
File renamed without changes.
18 changes: 10 additions & 8 deletions hexrd/ui/async_runner.py → hexrdgui/async_runner.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
from PySide2.QtCore import QThreadPool, QTimer
from PySide2.QtWidgets import QMessageBox
from PySide6.QtCore import QThreadPool, QTimer
from PySide6.QtWidgets import QMessageBox

from hexrd.ui.async_worker import AsyncWorker
from hexrd.ui.progress_dialog import ProgressDialog
from hexrdgui.async_worker import AsyncWorker
from hexrdgui.progress_dialog import ProgressDialog


class AsyncRunner:

def __init__(self, parent):
self.parent = parent

self.thread_pool = QThreadPool(parent)

self.progress_dialog = ProgressDialog(parent)

# Some defaults...
Expand Down Expand Up @@ -41,7 +39,7 @@ def run(self, f, *args, **kwargs):
# have a segmentation fault.
self.thread_pool.start(worker)

self.progress_dialog.exec_()
self.progress_dialog.exec()

def on_worker_finished(self):
self.reset_callbacks()
Expand All @@ -67,4 +65,8 @@ def on_async_error(self, t):
msg = f'An ERROR occurred: {exctype}: {value}.'
msg_box = QMessageBox(QMessageBox.Critical, 'Error', msg)
msg_box.setDetailedText(traceback)
msg_box.exec_()
msg_box.exec()

@property
def thread_pool(self):
return QThreadPool.globalInstance()
2 changes: 1 addition & 1 deletion hexrd/ui/async_worker.py → hexrdgui/async_worker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This class was modified from the following example online:
# https://www.learnpyqt.com/courses/concurrent-execution/multithreading-pyqt-applications-qthreadpool/

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

import inspect
import traceback
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from hexrd.ui.hexrd_config import HexrdConfig
from hexrd.ui.ui_loader import UiLoader
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.ui_loader import UiLoader


class AzimuthalOverlayEditor:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import random
from PySide2.QtCore import Qt, QItemSelectionModel
from PySide2.QtWidgets import (
from PySide6.QtCore import Qt, QItemSelectionModel
from PySide6.QtWidgets import (
QCheckBox, QComboBox, QHBoxLayout, QHeaderView, QSizePolicy,
QTableWidgetItem, QWidget
)
from hexrd.ui import utils
from hexrdgui import utils

from hexrd.ui.hexrd_config import HexrdConfig
from hexrd.ui.azimuthal_overlay_editor import AzimuthalOverlayEditor
from hexrd.ui.azimuthal_overlay_style_picker import AzimuthalOverlayStylePicker
from hexrd.ui.ui_loader import UiLoader
from hexrd.ui.utils import block_signals
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.azimuthal_overlay_editor import AzimuthalOverlayEditor
from hexrdgui.azimuthal_overlay_style_picker import AzimuthalOverlayStylePicker
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals

import numpy as np

Expand Down Expand Up @@ -272,7 +272,7 @@ def remove(self):
def edit_style(self):
self._style_picker = AzimuthalOverlayStylePicker(self.active_overlay,
self.ui)
self._style_picker.exec_()
self._style_picker.exec()

def show_legend(self, value):
HexrdConfig().show_azimuthal_legend = value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from PySide2.QtCore import QObject
from PySide2.QtGui import QColor
from PySide2.QtWidgets import QColorDialog
from PySide6.QtCore import QObject
from PySide6.QtGui import QColor
from PySide6.QtWidgets import QColorDialog

from hexrd.ui.hexrd_config import HexrdConfig
from hexrd.ui.ui_loader import UiLoader
from hexrd.ui.utils import block_signals
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals


class AzimuthalOverlayStylePicker(QObject):
Expand All @@ -23,9 +23,9 @@ def __init__(self, overlay, parent=None):
self.setup_connections()
self.update_gui()

def exec_(self):
def exec(self):
self.ui.adjustSize()
return self.ui.exec_()
return self.ui.exec()

def setup_connections(self):
self.ui.color.pressed.connect(self.pick_color)
Expand Down Expand Up @@ -72,7 +72,7 @@ def pick_color(self):
color = sender.text()

dialog = QColorDialog(QColor(color), self.ui)
if dialog.exec_():
if dialog.exec():
sender.setText(dialog.selectedColor().name())
self.update_button_colors()
self.update_config()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from matplotlib.markers import MarkerStyle

from PySide2.QtGui import QColor
from PySide2.QtWidgets import QColorDialog
from PySide6.QtGui import QColor
from PySide6.QtWidgets import QColorDialog

from hexrd.ui.hexrd_config import HexrdConfig
from hexrd.ui.ui_loader import UiLoader
from hexrd.ui.utils import block_signals
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals


class BeamMarkerStyleEditor:
Expand Down Expand Up @@ -80,7 +80,7 @@ def pick_color(self):
color = w.text()

dialog = QColorDialog(QColor(color), self.ui)
if dialog.exec_():
if dialog.exec():
w.setText(dialog.selectedColor().name())
self.update_button_colors()
self.update_config()
Expand Down
Loading

0 comments on commit f93458a

Please sign in to comment.