Skip to content

Commit

Permalink
Changed PlotCreator to QDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilipp committed Mar 3, 2017
1 parent d887a40 commit 360ce8e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions psyplot_gui/compat/qtcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
QTableWidget, QTableWidgetItem, QRegExpValidator, QGridLayout,
QIntValidator, QErrorMessage, QInputDialog, QTabWidget,
QDoubleValidator, QGraphicsScene, QGraphicsRectItem, QGraphicsView,
QKeySequence, QStyleOptionViewItem)
QKeySequence, QStyleOptionViewItem, QDialog, QDialogButtonBox)
from PyQt4 import QtCore
from PyQt4.QtCore import Qt
from PyQt4.QtWebKit import QWebView as QWebEngineView
Expand All @@ -41,7 +41,8 @@
QAction, QMessageBox, QCheckBox, QFileDialog, QListView,
QDesktopWidget, QStyledItemDelegate, QTableWidget, QTableWidgetItem,
QGridLayout, QErrorMessage, QInputDialog, QTabWidget,
QGraphicsScene, QGraphicsRectItem, QGraphicsView, QStyleOptionViewItem)
QGraphicsScene, QGraphicsRectItem, QGraphicsView, QStyleOptionViewItem,
QDialog, QDialogButtonBox)
from PyQt5.QtGui import (
QIcon, QKeyEvent, QStandardItem, QStandardItemModel, QTextCursor,
QValidator, QRegExpValidator, QIntValidator, QDoubleValidator,
Expand Down
12 changes: 7 additions & 5 deletions psyplot_gui/plot_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
QLabel, QValidator, QStyledItemDelegate, QLineEdit, QCheckBox,
QTableWidget, QTableWidgetItem, QGridLayout, QIntValidator, QMenu, QAction,
QInputDialog, QTabWidget, QDoubleValidator, QGraphicsScene,
QGraphicsRectItem, QGraphicsView)
QGraphicsRectItem, QGraphicsView, QDialog, QDialogButtonBox)
from psyplot_gui.common import get_icon, ListValidator, PyErrorMessage
import psyplot.project as psy

Expand Down Expand Up @@ -1607,7 +1607,7 @@ def close(self):
return super(AxesCreatorCollection, self).close()


class PlotCreator(QWidget):
class PlotCreator(QDialog):
"""
Widget to extract data from a dataset and eventually create a plot"""

Expand Down Expand Up @@ -1755,8 +1755,10 @@ def __init__(self, get_obj=None, *args, **kwargs):
self.bt_add_single_axes.clicked.connect(self.setup_subplot)

# -------------------- create and cancel connections ------------------
self.bt_create.clicked.connect(self.create_plots)
self.bt_cancel.clicked.connect(lambda b: self.close())
self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
bbox.accepted.connect(self.create_plots)
bbox.rejected.connect(self.reject)

# -------------------- other connections ------------------------------
# allow only to select either variables or newly created arrays in
Expand Down Expand Up @@ -1818,7 +1820,7 @@ def __init__(self, get_obj=None, *args, **kwargs):
self.vbox.addWidget(self.coords_table)
self.vbox.addWidget(self.array_table)
self.vbox.addLayout(self.axes_box)
self.vbox.addLayout(self.bt_box_ok_cancel)
self.vbox.addWidget(self.bbox)

self.setLayout(self.vbox)

Expand Down
6 changes: 4 additions & 2 deletions tests/test_project_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import xarray as xr
import psyplot.data as psyd
import psyplot.project as psy
from psyplot_gui.compat.qtcompat import QTest, Qt
from psyplot_gui.compat.qtcompat import QTest, Qt, QDialogButtonBox


class ProjectContentTest(bt.PsyPlotGuiTestCase):
Expand Down Expand Up @@ -259,7 +259,9 @@ def test_make_plot(self):
self.window.plot_creator.pm_combo.setCurrentText('plot2d')
except AttributeError:
self.window.plot_creator.pm_combo.setEditText('plot2d')
QTest.mouseClick(self.window.plot_creator.bt_create, Qt.LeftButton)
QTest.mouseClick(
self.window.plot_creator.bbox.button(QDialogButtonBox.Ok),
Qt.LeftButton)
self.assertIs(ds, psy.gcp()[0].psy.base)


Expand Down

0 comments on commit 360ce8e

Please sign in to comment.