Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into add_vi…
Browse files Browse the repository at this point in the history
…sual_cue_when_selecting_brf
  • Loading branch information
jnsebgosselin committed Oct 1, 2020
2 parents 82f2490 + 96413fe commit 5589d82
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 252 deletions.
5 changes: 2 additions & 3 deletions gwhat/HydroCalc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from gwhat.config.main import CONF
from gwhat.gwrecharge.gwrecharge_gui import RechgEvalWidget
from gwhat.common.widgets import DialogWindow
from gwhat.common import StyleDB
from gwhat.config.gui import FRAME_SYLE
from gwhat.utils import icons
from gwhat.utils.icons import QToolButtonNormal, get_iconsize
from gwhat.widgets.buttons import ToolBarWidget
Expand Down Expand Up @@ -131,7 +131,7 @@ def _setup_mpl_canvas(self):
# Put figure canvas in a QFrame widget so that it has a frame.
self.fig_frame_widget = QFrame()
self.fig_frame_widget.setMinimumSize(200, 200)
self.fig_frame_widget.setFrameStyle(StyleDB().frame)
self.fig_frame_widget.setFrameStyle(FRAME_SYLE)
self.fig_frame_widget.setLineWidth(2)
self.fig_frame_widget.setMidLineWidth(1)
fig_frame_layout = QGridLayout(self.fig_frame_widget)
Expand Down Expand Up @@ -505,7 +505,6 @@ def __initUI__(self):

main_layout.setHorizontalSpacing(15)
main_layout.setColumnStretch(0, 100)
main_layout.setColumnMinimumWidth(2, 250)

@property
def water_lvl(self):
Expand Down
26 changes: 14 additions & 12 deletions gwhat/HydroPrint2.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ def __initUI__(self):
self.zoom_disp.setRange(0, 9999)
self.zoom_disp.setValue(100)

zoom_pan = myqt.QFrameLayout()
zoom_pan.setSpacing(3)
zoom_pan.addWidget(btn_zoom_out, 0, 0)
zoom_pan.addWidget(btn_zoom_in, 0, 1)
zoom_pan.addWidget(self.zoom_disp, 0, 2)
zoom_pan = QFrame()
zoom_pan_layout = QGridLayout(zoom_pan)
zoom_pan_layout.setContentsMargins(0, 0, 0, 0)
zoom_pan_layout.setSpacing(3)
zoom_pan_layout.addWidget(btn_zoom_out, 0, 0)
zoom_pan_layout.addWidget(btn_zoom_in, 0, 1)
zoom_pan_layout.addWidget(self.zoom_disp, 0, 2)

# Setup the toolbar of the left widget.
toolbar = QToolBar()
Expand Down Expand Up @@ -164,12 +166,13 @@ def __initUI__(self):
# Setup the right panel.
self.tabscales = self.__init_scalesTabWidget__()

self.right_panel = myqt.QFrameLayout()
self.right_panel.addWidget(self.dmngr, 0, 0)
self.right_panel.addWidget(self.tabscales, 1, 0)
self.right_panel.setRowStretch(2, 100)

self.right_panel.setSpacing(15)
self.right_panel = QFrame()
right_panel_layout = QGridLayout(self.right_panel)
right_panel_layout.setContentsMargins(0, 0, 0, 0)
right_panel_layout.addWidget(self.dmngr, 0, 0)
right_panel_layout.addWidget(self.tabscales, 1, 0)
right_panel_layout.setRowStretch(2, 100)
right_panel_layout.setSpacing(15)

# Setup the main layout.
main_layout = QGridLayout(self)
Expand All @@ -178,7 +181,6 @@ def __initUI__(self):
main_layout.addWidget(self.right_panel, 0, 2)
main_layout.setSpacing(15)
main_layout.setColumnStretch(0, 500)
main_layout.setColumnMinimumWidth(2, 250)

# ---- EVENTS

Expand Down
49 changes: 25 additions & 24 deletions gwhat/brf_mod/kgs_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
QLabel, QDateTimeEdit, QCheckBox, QPushButton, QApplication, QSpinBox,
QAbstractSpinBox, QGridLayout, QDoubleSpinBox, QFrame, QWidget,
QMessageBox, QFileDialog, QComboBox, QDialog, QGroupBox, QToolButton,
QToolBar, QGroupBox)
QToolBar)

from xlrd.xldate import xldate_from_datetime_tuple, xldate_as_datetime
import numpy as np
Expand All @@ -32,10 +32,8 @@


# ---- Local imports
import gwhat.common.widgets as myqt
from gwhat.widgets.layout import VSep, HSep
from gwhat.widgets.buttons import LangToolButton
from gwhat.common import StyleDB
from gwhat.widgets.layout import HSep
from gwhat.config.gui import FRAME_SYLE
from gwhat.config.main import CONF
from gwhat.utils import icons
from gwhat.utils.icons import QToolButtonNormal, get_icon
Expand All @@ -49,7 +47,7 @@
mpl.rc('font', **{'family': 'sans-serif', 'sans-serif': ['Arial']})


class KGSBRFInstaller(myqt.QFrameLayout):
class KGSBRFInstaller(QFrame):
"""
A simple widget to download the kgs_brf program and install it in the
proper directory.
Expand All @@ -60,18 +58,19 @@ class KGSBRFInstaller(myqt.QFrameLayout):

def __init__(self, parent=None):
super(KGSBRFInstaller, self).__init__(parent)

self.setAutoFillBackground(True)
self.setAttribute(Qt.WA_DeleteOnClose)

self.install_btn = QPushButton("Install")
self.install_btn.clicked.connect(self.install_kgsbrf)

self.addWidget(self.install_btn, 1, 1)
self.setRowStretch(0, 100)
self.setRowStretch(self.rowCount(), 100)
self.setColumnStretch(0, 100)
self.setColumnStretch(self.columnCount(), 100)
layout = QGridLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(self.install_btn, 1, 1)
layout.setRowStretch(0, 100)
layout.setRowStretch(layout.rowCount(), 100)
layout.setColumnStretch(0, 100)
layout.setColumnStretch(layout.columnCount(), 100)

@property
def install_dir(self):
Expand Down Expand Up @@ -123,7 +122,7 @@ def install_kgsbrf(self):
QApplication.restoreOverrideCursor()


class BRFManager(myqt.QFrameLayout):
class BRFManager(QFrame):
sig_brfperiod_changed = QSignal(tuple)
sig_select_brfperiod_requested = QSignal(bool)

Expand Down Expand Up @@ -164,7 +163,7 @@ def __initGUI__(self):
lambda value: self._handle_lag_value_changed(
self.earthtides_spinbox))

self.earthtides_cbox = QCheckBox('Nbr of ET lags :')
self.earthtides_cbox = QCheckBox('No. of ET lags :')
self.earthtides_cbox.setChecked(
CONF.get('brf', 'compute_with_earthtides'))
self.earthtides_cbox.toggled.connect(
Expand Down Expand Up @@ -196,7 +195,7 @@ def __initGUI__(self):
# Setup options layout.
options_grpbox = QGroupBox()
options_layout = QGridLayout(options_grpbox)
options_layout.addWidget(QLabel('Nbr of BP lags :'), 0, 0)
options_layout.addWidget(QLabel('No. of BP lags :'), 0, 0)
options_layout.addWidget(self.earthtides_cbox, 1, 0)
options_layout.addLayout(lags_layout, 0, 1, 2, 1)
options_layout.addWidget(self.detrend_waterlevels_cbox, 2, 0, 1, 2)
Expand Down Expand Up @@ -257,12 +256,13 @@ def __initGUI__(self):
self._show_brf_results_btn.clicked.connect(self.viewer.show)

# Setup the main Layout.
self.addWidget(daterange_grpbox, 0, 0)
self.addWidget(options_grpbox, 1, 0)
self.setRowMinimumHeight(2, 15)
self.setRowStretch(2, 100)
self.addWidget(self._show_brf_results_btn, 4, 0)
self.addWidget(btn_comp, 5, 0)
main_layout = QGridLayout(self)
main_layout.setContentsMargins(0, 0, 0, 0)
main_layout.addWidget(daterange_grpbox, 0, 0)
main_layout.addWidget(options_grpbox, 1, 0)
main_layout.setRowStretch(2, 100)
main_layout.addWidget(self._show_brf_results_btn, 3, 0)
main_layout.addWidget(btn_comp, 4, 0)

# Setup the install KGS_BRF panel
if not KGSBRFInstaller().kgsbrf_is_installed():
Expand Down Expand Up @@ -462,8 +462,9 @@ def __install_kgs_brf_installer(self):
self.kgs_brf_installer = KGSBRFInstaller()
self.kgs_brf_installer.sig_kgs_brf_installed.connect(
self.__uninstall_kgs_brf_installer)
self.addWidget(
self.kgs_brf_installer, 0, 0, self.rowCount(), self.columnCount())
self.layout().addWidget(
self.kgs_brf_installer,
0, 0, self.layout().rowCount(), self.layout().columnCount())

def __uninstall_kgs_brf_installer(self):
"""
Expand Down Expand Up @@ -637,7 +638,7 @@ def __initGUI__(self):
self.brf_canvas = FigureCanvasQTAgg(BRFFigure())

self.fig_frame = QFrame()
self.fig_frame.setFrameStyle(StyleDB().frame)
self.fig_frame.setFrameStyle(FRAME_SYLE)
self.fig_frame.setObjectName("figframe")
self.fig_frame.setStyleSheet("#figframe {background-color:white;}")

Expand Down
2 changes: 0 additions & 2 deletions gwhat/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@
#
# This file is part of GWHAT (Ground-Water Hydrograph Analysis Toolbox).
# Licensed under the terms of the GNU General Public License.

from gwhat.common.styles import StyleDB
67 changes: 0 additions & 67 deletions gwhat/common/styles.py

This file was deleted.

70 changes: 3 additions & 67 deletions gwhat/common/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,9 @@

from PyQt5.QtCore import Qt, QSize, QPoint, QUrl
from PyQt5.QtCore import pyqtSignal as QSignal
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (QGridLayout, QLabel, QFrame, QMessageBox,
QComboBox, QDoubleSpinBox, QAbstractSpinBox,
QGroupBox, QWidget, QDialog, QDesktopWidget,
QTextBrowser, QPushButton, QStyle, QScrollArea,
QToolButton)


class MyQLineLayout(QGridLayout):

def __init__(self, widgets, parent=None):
super(MyQLineLayout, self).__init__(parent)

for i, widget in enumerate(widgets):
self.addWidget(widget, 0, i)

self.setContentsMargins(0, 0, 0, 0) # (l, t, r, b)
self.setColumnStretch(self.columnCount(), 100)
from PyQt5.QtWidgets import (
QGridLayout, QMessageBox, QComboBox, QDoubleSpinBox, QAbstractSpinBox,
QWidget, QDialog, QDesktopWidget, QPushButton, QStyle, QScrollArea)


class MyQComboBox(QComboBox):
Expand Down Expand Up @@ -104,55 +89,6 @@ def value(self):
return self.__value


class QFrameLayout(QFrame):
def __init__(self, parent=None):
super(QFrameLayout, self).__init__(parent)

self.setLayout(QGridLayout())
self.layout().setContentsMargins(0, 0, 0, 0)

def addWidget(self, widget, x, y, w=1, h=1):
self.layout().addWidget(widget, x, y, w, h)

def addLayout(self, layout, x, y, w=1, h=1):
self.layout().addLayout(layout, x, y, w, h)

# -------------------------------------------------------------------------

def setRowMinimumHeight(self, row, height):
self.layout().setRowMinimumHeight(row, height)

# -------------------------------------------------------------------------

def setRowStretch(self, row, stretch):
self.layout().setRowStretch(row, stretch)

def setColumnStretch(self, column, stretch):
self.layout().setColumnStretch(column, stretch)

# -------------------------------------------------------------------------

def setContentsMargins(self, left, top, right, bottom):
self.layout().setContentsMargins(left, top, right, bottom)

def setSpacing(self, spacing):
self.layout().setSpacing(spacing)

def setVerticalSpacing(self, spacing):
self.layout().setVerticalSpacing(spacing)

def setHorizontalSpacing(self, spacing):
self.layout().setHorizontalSpacing(spacing)

# -------------------------------------------------------------------------

def rowCount(self):
return self.layout().rowCount()

def columnCount(self):
return self.layout().columnCount()


class DialogWindow(QDialog):

def __init__(self, parent=None, resizable=False, maximize=True):
Expand Down
1 change: 1 addition & 0 deletions gwhat/config/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
YELLOWLIGHT = '#fcf7b6'

INIT_MAINWINDOW_SIZE = (1260, 740)
FRAME_SYLE = 22
Loading

0 comments on commit 5589d82

Please sign in to comment.