Skip to content

Commit

Permalink
Upgraded to work with QtPy and PySide2
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Blumberg committed Dec 31, 2018
1 parent d42c426 commit 7c48f31
Show file tree
Hide file tree
Showing 37 changed files with 130 additions and 108 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ BUG FIXES
* Additional error handling for partial profiles.
* Various model forecast points relocated to their proper places.
* Error handling for opening the program without an Internet connection.
* Removed PySide dependency and unused imports for those using SHARPpy routines in scripts.
* Removed qtpy dependency and unused imports for those using SHARPpy routines in scripts.

SHARPpy v1.2.0 "El Reno" Release
--------------------------------
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ The Anaconda Python Distribution can be downloaded here: https://www.anaconda.co
__Required Python Packages/Libraries:__

* NumPy
* PySide
* qtpy

Since SHARPpy requires the PySide and Numpy packages, you will need to install them. If you choose to use the Anaconda distribution, Numpy comes installed by default. PySide can be installed through the Anaconda package manager that comes with the Anaconda distribution by opening up your command line program (Terminal in Mac OS X/Linux and Command Prompt in Windows) and typing:
Since SHARPpy requires the qtpy and Numpy packages, you will need to install them. If you choose to use the Anaconda distribution, Numpy comes installed by default. qtpy can be installed through the Anaconda package manager that comes with the Anaconda distribution by opening up your command line program (Terminal in Mac OS X/Linux and Command Prompt in Windows) and typing:

conda install -c conda-forge pyside=1.2.4

Expand Down
4 changes: 3 additions & 1 deletion ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ conda update -q conda
conda install -n -q root _license
conda info -a
conda config --add channels conda-forge
conda create -q -n test-environment python=$PYTHON_VERSION nose pyside pyinstaller conda-build anaconda-client numpy=$NUMPY_VERSION
conda create -q -n test-environment python=$PYTHON_VERSION nose pyinstaller conda-build anaconda-client numpy=$NUMPY_VERSION
source activate test-environment

pip install --upgrade pip
pip install PySide2
conda install -q qtpy
conda install -c conda-forge -q pytest-cov
if [[ "$COVERALLS" == "YES" ]]; then
conda install -c conda-forge -q coveralls
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'gallery_dirs': 'auto_examples',
}

#autodoc_mock_imports = ["numpy", "PySide"]
#autodoc_mock_imports = ["numpy", "qtpy"]

napoleon_google_docstring = False
napolean_numpy_docstring = True
Expand Down
6 changes: 3 additions & 3 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ install the required packages manually. These instructions assume that you have
*Required Python Packages/Libraries:*

* NumPy
* PySide
* qtpy

Since SHARPpy requires the PySide and Numpy packages, you will need to install them. If you choose to use the Anaconda distribution, Numpy comes installed by default. PySide can be installed through the Anaconda package manager that comes with the Anaconda distribution by opening up your command line program (Terminal in macOS/Linux and Command Prompt in Windows) and typing:
Since SHARPpy requires the qtpy and Numpy packages, you will need to install them. If you choose to use the Anaconda distribution, Numpy comes installed by default. qtpy can be installed through the Anaconda package manager that comes with the Anaconda distribution by opening up your command line program (Terminal in macOS/Linux and Command Prompt in Windows) and typing:

.. prompt:: bash

conda install -c conda-forge pyside=1.2.4
pip install PySide2

After installing all the required Python packages for SHARPpy, you now can install the SHARPpy package to your computer. You'll need to download it to your computer first and open up a command line prompt. You can download it as a ZIP file (link on the right) or clone the Git respository (you will need the git program) into a directory on your computer by typing this into your command line:

Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ dependencies:
- sphinx-gallery
- sphinx-rtd-theme
- pytest
- qtpy
- pip:
- sphinx-prompt
- pydocstyle

- PySide2
21 changes: 17 additions & 4 deletions runsharp/full_gui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from qtpy.QtGui import *
from qtpy.QtCore import *
from qtpy.QtWidgets import *
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
#QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
#QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
from sharppy.viz.map import MapWidget
import argparse
import traceback
Expand All @@ -6,8 +13,7 @@
import cProfile
from functools import wraps, partial
import datetime as date
from PySide.QtGui import *
from PySide.QtCore import *

from utils.progress import progress
from utils.async_threads import AsyncThreads
from datasources import data_source
Expand All @@ -23,7 +29,7 @@
import warnings
import utils.frozenutils as frozenutils
import logging
import PySide
import qtpy
import platform
HOME_DIR = os.path.join(os.path.expanduser("~"), ".sharppy")

Expand Down Expand Up @@ -67,7 +73,7 @@
logging.info('Started logging output for SHARPpy')
logging.info('SHARPpy version: ' + str(__version__))
logging.info('numpy version: ' + str(np.__version__))
logging.info('PySide version: ' + str(PySide.__version__))
logging.info('qtpy version: ' + str(qtpy.__version__))
logging.info("Python version: " + str(platform.python_version()))

# from sharppy._version import __version__#, __version_name__
Expand Down Expand Up @@ -1013,6 +1019,10 @@ def createWindow(file_names, collect=False, close=True):

# Create an application
app = QApplication([])
app.setAttribute(Qt.AA_EnableHighDpiScaling)
app.setAttribute(Qt.AA_UseHighDpiPixmaps)
#
#app.setStyle("fusion")
win = createWindow(args.file_names, collect=args.collect, close=args.close)

if args.file_names != [] and args.close:
Expand All @@ -1022,4 +1032,7 @@ def createWindow(file_names, collect=False, close=True):


if __name__ == '__main__':
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
#
main()
14 changes: 7 additions & 7 deletions sharppy/gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import numpy as np
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
from sharppy.viz import plotSkewT, plotHodo, plotText, plotAnalogues
from sharppy.viz import plotThetae, plotWinds, plotSpeed, plotKinematics
from sharppy.viz import plotSlinky, plotWatch, plotAdvection, plotSTP
Expand All @@ -18,7 +18,7 @@
title += 'in Python'
mainWindow.setWindowTitle(title)
mainWindow.setStyleSheet("QMainWindow {background-color: rgb(0, 0, 0);}")
centralWidget = QtGui.QFrame()
centralWidget = QtWidgets.QFrame()
mainWindow.setCentralWidget(centralWidget)
grid = QtGui.QGridLayout()
grid.setHorizontalSpacing(0)
Expand All @@ -35,11 +35,11 @@
grid.addWidget(sound, 0, 0, 3, 1)

# Handle the Upper Right
urparent = QtGui.QFrame()
urparent = QtWidgets.QFrame()
urparent_grid = QtGui.QGridLayout()
urparent_grid.setContentsMargins(0, 0, 0, 0)
urparent.setLayout(urparent_grid)
ur = QtGui.QFrame()
ur = QtWidgets.QFrame()
ur.setStyleSheet("QFrame {"
" background-color: rgb(0, 0, 0);"
" border-width: 0px;"
Expand Down Expand Up @@ -83,7 +83,7 @@
grid.addWidget(urparent, 0, 1, 3, 1)

# Handle the Text Areas
text = QtGui.QFrame()
text = QtWidgets.QFrame()
text.setStyleSheet("QWidget {"
" background-color: rgb(0, 0, 0);"
" border-width: 2px;"
Expand All @@ -94,8 +94,8 @@
grid3.setContentsMargins(0, 0, 0, 0)
text.setLayout(grid3)
convective = plotText(prof)
#convective = QtGui.QFrame()
#kinematic = QtGui.QFrame()
#convective = QtWidgets.QFrame()
#kinematic = QtWidgets.QFrame()
kinematic = plotKinematics(prof)
SARS = plotAnalogues(prof)
stp = plotSTP(prof)
Expand Down
2 changes: 1 addition & 1 deletion sharppy/tests/test_gui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
import sharppy.viz as viz
import sharppy.viz.preferences as preferences
from sharppy.io.spc_decoder import SPCDecoder
Expand Down
5 changes: 3 additions & 2 deletions sharppy/viz/SPCWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from sharppy.viz import plotThetae, plotWinds, plotSpeed, plotKinematics #, plotGeneric
from sharppy.viz import plotSlinky, plotWatch, plotAdvection, plotSTP, plotWinter
from sharppy.viz import plotSHIP, plotSTPEF, plotFire, plotVROT
from PySide.QtCore import *
from PySide.QtGui import *
from qtpy.QtCore import *
from qtpy.QtGui import *
from qtpy.QtWidgets import *
import sharppy.sharptab.profile as profile
import sharppy.sharptab as tab
import sharppy.io as io
Expand Down
4 changes: 2 additions & 2 deletions sharppy/viz/advection.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets, QtWidgets
import sharppy.sharptab as tab
from sharppy.sharptab.constants import *
import platform

__all__ = ['backgroundAdvection', 'plotAdvection']
class backgroundAdvection(QtGui.QFrame):
class backgroundAdvection(QtWidgets.QFrame):
'''
Draw the background frame and lines for the Theta-E plot frame
'''
Expand Down
6 changes: 3 additions & 3 deletions sharppy/viz/analogues.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import os
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
import sharppy.sharptab as tab
from sharppy.sharptab.constants import *
import sharppy.databases.sars as sars
Expand All @@ -13,15 +13,15 @@

__all__ = ['backgroundAnalogues', 'plotAnalogues']

class backgroundAnalogues(QtGui.QFrame):
class backgroundAnalogues(QtWidgets.QFrame):
'''
Handles drawing the background frame for the
SARS window.
'''
def __init__(self):
''' Calls the initUI function to initialize
the background frame. Inherits from the
QtGui.QFrame Object.
QtWidgets.QFrame Object.
'''
super(backgroundAnalogues, self).__init__()
self.initUI()
Expand Down
2 changes: 1 addition & 1 deletion sharppy/viz/barbs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
import sharppy.sharptab as tab
from sharppy.sharptab.constants import *

Expand Down
4 changes: 2 additions & 2 deletions sharppy/viz/draggable.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import numpy as np

from PySide.QtGui import *
from PySide.QtCore import *
from qtpy.QtGui import *
from qtpy.QtCore import *

class Draggable(object):
"""
Expand Down
6 changes: 3 additions & 3 deletions sharppy/viz/ensemble.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import os
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
import sharppy.sharptab.params as params
import sharppy.sharptab.winds as winds
import sharppy.sharptab.interp as interp
Expand All @@ -12,7 +12,7 @@

__all__ = ['backgroundENS', 'plotENS']

class backgroundENS(QtGui.QFrame):
class backgroundENS(QtWidgets.QFrame):
'''
Draw the background frame and lines for the Theta-E plot frame
'''
Expand Down Expand Up @@ -323,7 +323,7 @@ def draw_ensemble_point(self, qp, prof):
return


class DrawTest(QtGui.QMainWindow):
class DrawTest(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(DrawTest, self).__init__(parent)
# x = np.asarray([1,2,3,4])
Expand Down
4 changes: 2 additions & 2 deletions sharppy/viz/fire.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
import sharppy.sharptab as tab
from sharppy.sharptab.constants import *
import platform
Expand All @@ -9,7 +9,7 @@

__all__ = ['backgroundFire', 'plotFire']

class backgroundFire(QtGui.QFrame):
class backgroundFire(QtWidgets.QFrame):
'''
Handles drawing the background frame.
'''
Expand Down
10 changes: 5 additions & 5 deletions sharppy/viz/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import numpy as np
from sharppy.sharptab.constants import *
import sharppy.sharptab as tab
from PySide import QtGui, QtCore
from PySide.QtGui import *
from PySide.QtCore import *
from PySide.QtOpenGL import *
from qtpy import QtGui, QtCore, QtWidgets
from qtpy.QtGui import *
from qtpy.QtCore import *
from qtpy.QtOpenGL import *

class backgroundGeneric(QtGui.QFrame):
class backgroundGeneric(QtWidgets.QFrame):
"""
A generic class for drawing the background of a widget.
"""
Expand Down
15 changes: 8 additions & 7 deletions sharppy/viz/hodo.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import numpy as np
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
import sharppy.sharptab as tab
from sharppy.viz.draggable import Draggable
from sharppy.sharptab.profile import Profile, create_profile
from sharppy.sharptab.constants import *
from PySide.QtGui import *
from PySide.QtCore import *
from qtpy.QtGui import *
from qtpy.QtCore import *
from qtpy.QtWidgets import *

__all__ = ['backgroundHodo', 'plotHodo']


class backgroundHodo(QtGui.QFrame):
class backgroundHodo(QFrame):
'''
Handles the plotting of the backgroun frame onto
a QPixmap. Inherits from the QtGui.QFrame object.
a QPixmap. Inherits from the QtWidgets.QFrame object.
Unlike most plotting classes in SHARPPy, this class
will not call the function to draw the background.
This is so that the background can be redrawn when
Expand Down Expand Up @@ -387,7 +388,7 @@ def __init__(self, **kwargs):
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.showCursorMenu)
self.popupmenu=QMenu("Cursor Type:")
ag = QtGui.QActionGroup(self, exclusive=True)
ag = QtWidgets.QActionGroup(self, exclusive=True)

self.readout_hght = -999.
self.readout_visible = False
Expand All @@ -408,7 +409,7 @@ def __init__(self, **kwargs):
self.popupmenu.addAction(a)

self.popupmenu.addSeparator()
ag2 = QtGui.QActionGroup(self, exclusive=True)
ag2 = QtWidgets.QActionGroup(self, exclusive=True)

norm = QAction(self)
norm.setText("Normal")
Expand Down
4 changes: 2 additions & 2 deletions sharppy/viz/kinematics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import numpy as np
from PySide import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
import sharppy.sharptab as tab
from sharppy.viz.barbs import drawBarb
from sharppy.sharptab.constants import *
Expand All @@ -11,7 +11,7 @@

__all__ = ['backgroundKinematics', 'plotKinematics']

class backgroundKinematics(QtGui.QFrame):
class backgroundKinematics(QtWidgets.QFrame):
'''
Handles drawing the background frame.
'''
Expand Down
Loading

0 comments on commit 7c48f31

Please sign in to comment.