Skip to content

Commit

Permalink
final QT4 > QT5 updates to make GUI work + addition of tide_model
Browse files Browse the repository at this point in the history
namelist entry to the variable info for the GUI
  • Loading branch information
jdha committed Jan 14, 2020
1 parent 5de9b80 commit c766adb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
6 changes: 3 additions & 3 deletions pynemo/gui/nemo_bdy_input_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def __init__(self, setup):

self.mpl_widget.set_mask_settings(float(setup.settings['mask_max_depth']), float(setup.settings['mask_shelfbreak_dist']))

splitter = QtGui.QSplitter(Qt.Horizontal)
splitter = QtWidgets.QSplitter(Qt.Horizontal)
splitter.addWidget(self.nl_editor)
splitter.addWidget(self.mpl_widget)

hbox = QtGui.QHBoxLayout()
hbox = QtWidgets.QHBoxLayout()
hbox.addWidget(splitter)
self.setLayout(hbox)
#set the Dialog title
self.setWindowTitle("PyNEMO Settings Editor")
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create('Cleanlooks'))
#show the window
self.show()
2 changes: 1 addition & 1 deletion pynemo/gui/nemo_bdy_mask_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, parent=None, mask=None, min_depth = 200.0, shelfbreak_dist =
self.toolbar.drawing_tool.connect(self.drawing_tool_callback)
self.axes = self.figure.add_subplot(111)
self.cbar = None
layout = QtGui.QVBoxLayout()
layout = QtWidgets.QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
self.setLayout(layout)
Expand Down
28 changes: 14 additions & 14 deletions pynemo/gui/nemo_bdy_namelist_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,33 @@ def init_ui(self):
'''
Initialises the UI components of the GUI
'''
client = QtGui.QWidget(self)
client = QtWidgets.QWidget(self)
# Create the Layout to Grid
grid = QtGui.QGridLayout()
grid = QtWidgets.QGridLayout()

# Loop through the settings and create widgets for each setting
index = 0
for setting in self.settings:
# initialises setting Widget
label = QtGui.QLabel(setting)
qlabel = QtGui.QPushButton("")
qlabel.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MessageBoxQuestion))
label = QtWidgets.QLabel(setting)
qlabel = QtWidgets.QPushButton("")
qlabel.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_MessageBoxQuestion))
if type(self.settings[setting]).__name__ in ['str', 'float', 'double',
'int', 'time', 'dict']:
text = QtGui.QLineEdit(self)
text = QtWidgets.QLineEdit(self)
text.setText(str(self.settings[setting]))
text.textChanged.connect(lambda value=setting,\
var_name=setting: self.label_changed(value, var_name))
if setting in self.bool_settings:
chkbox = QtGui.QCheckBox(self)
chkbox = QtWidgets.QCheckBox(self)
chkbox.setChecked(self.bool_settings[setting])
chkbox.stateChanged.connect(lambda value=setting,\
var_name=setting:\
self.state_changed(value, var_name))
grid.addWidget(chkbox, index, 0)

elif type(self.settings[setting]).__name__ == 'bool':
text = QtGui.QComboBox(self)
text = QtWidgets.QComboBox(self)
text.insertItem(0, 'True')
text.insertItem(1, 'False')
if self.settings[setting]:
Expand All @@ -84,22 +84,22 @@ def init_ui(self):

client.setLayout(grid)
#scrollbars
scroll_area = QtGui.QScrollArea(self)
scroll_area = QtWidgets.QScrollArea(self)
#scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
scroll_area.setWidget(client)

#save cancel buttons
btn_widget = QtGui.QWidget(self)
hbox_layout = QtGui.QHBoxLayout(self)
btn_save = QtGui.QPushButton('Save')
btn_widget = QtWidgets.QWidget(self)
hbox_layout = QtWidgets.QHBoxLayout(self)
btn_save = QtWidgets.QPushButton('Save')
btn_save.clicked.connect(self._btn_save_callback)
self.btn_cancel = QtGui.QPushButton('Close')
self.btn_cancel = QtWidgets.QPushButton('Close')
self.btn_cancel.clicked.connect(self._btn_cancel_callback)
hbox_layout.addWidget(btn_save)
hbox_layout.addWidget(self.btn_cancel)
btn_widget.setLayout(hbox_layout)

box_layout = QtGui.QVBoxLayout(self)
box_layout = QtWidgets.QVBoxLayout(self)
box_layout.addWidget(scroll_area)
box_layout.addWidget(btn_widget)
btn_widget.setMaximumWidth(400)
Expand Down
6 changes: 3 additions & 3 deletions pynemo/pynemo_settings_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'''
# pylint: disable=E1103
# pylint: disable=no-name-in-module
from PyQt5 import QtGui
from PyQt5 import QtGui, QtWidgets

from .gui.nemo_bdy_input_window import InputWindow
from . import nemo_bdy_setup
Expand All @@ -16,7 +16,7 @@ def open_settings_window(fname):
""" Main method which starts a Qt application and gives user
an option to pick a namelist.bdy file to edit. Once user selects it
it will open a dialog box where users can edit the parameters"""
app = QtGui.QApplication(sys.argv)
app = QtWidgets.QApplication(sys.argv)
if fname is None:
fname = QtGui.QFileDialog.getOpenFileName(None, 'Open file')

Expand All @@ -29,7 +29,7 @@ def open_settings_dialog(setup):
""" This method is to start the settings window using the setup settings provided
in the input. On clicking the cancel button it doesn't shutdown the applicaiton
but carries on with the execution"""
app = QtGui.QApplication(sys.argv)
app = QtWidgets.QApplication(sys.argv)
ex = InputWindow(setup)
ex.nl_editor.btn_cancel.clicked.connect(app.quit)
return app.exec_(), ex.mpl_widget.mask
Expand Down
3 changes: 2 additions & 1 deletion pynemo/variable.info
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ln_tra = boundary conditions for T and S
ln_ice = ice boundary condition
nn_rimwidth = width of the relaxation zone
ln_tide = if .true. : produce bdy tidal conditions
sn_tide_model = 'FES'
clname(0) = constituent name
ln_trans =
nn_year_000 = year start
Expand All @@ -47,4 +48,4 @@ nn_alpha = Euler rotation angle
nn_beta = Euler rotation angle
nn_gamma = Euler rotation angle
rn_mask_max_depth = Maximum depth to be ignored for the mask
rn_mask_shelfbreak_dist = Distance from the shelf break
rn_mask_shelfbreak_dist = Distance from the shelf break

0 comments on commit c766adb

Please sign in to comment.