Skip to content

Commit

Permalink
fix: subclass MDSubWindow and catch closeEvent (close #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 8, 2020
1 parent 4cd8f9f commit 73b4d33
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- fix: polygon filters were not stored correctly in log mode
- fix: several issues related to contour plots, contour spacing,
and log-scales
- fix: subclass MDSubWindow and catch closeEvent (#29)
- enh+docs: make Young's modulus computation more user convenient and
update the section in the docs
- docs: finish first draft of documentation
Expand Down
16 changes: 4 additions & 12 deletions shapeout2/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from . import pipeline_plot
from . import quick_view
from . import update
from . import widgets

from .. import pipeline
from .. import session
Expand Down Expand Up @@ -359,28 +360,22 @@ def add_plot_window(self, plot_id):
sub = self.subwindows_plots[plot_id]
else:
# create subwindow
sub = QtWidgets.QMdiSubWindow(self)
sub = widgets.MDISubWindowWOButtons(self)
pw = pipeline_plot.PipelinePlot(parent=sub,
pipeline=self.pipeline,
plot_id=plot_id)
self.plots_changed.connect(pw.update_content)
pw.update_content()
sub.setSystemMenu(None)
sub.setWindowFlags(QtCore.Qt.CustomizeWindowHint
| QtCore.Qt.WindowTitleHint)
sub.setWidget(pw)
self.mdiArea.addSubWindow(sub)
self.subwindows_plots[plot_id] = sub
sub.setFixedSize(sub.sizeHint())
sub.show()

def init_analysis_view(self):
sub = QtWidgets.QMdiSubWindow(self)
sub = widgets.MDISubWindowWOButtons(self)
self.widget_ana_view = analysis.AnalysisView()
self.subwindows["analysis_view"] = sub
sub.setSystemMenu(None)
sub.setWindowFlags(QtCore.Qt.CustomizeWindowHint
| QtCore.Qt.WindowTitleHint)
sub.setWidget(self.widget_ana_view)
sub.hide()
self.mdiArea.addSubWindow(sub)
Expand All @@ -390,16 +385,13 @@ def init_analysis_view(self):
self.on_quickview_refresh)

def init_quick_view(self):
sub = QtWidgets.QMdiSubWindow(self)
sub = widgets.MDISubWindowWOButtons(self)
self.widget_quick_view = quick_view.QuickView()
sub.setWidget(self.widget_quick_view)
self.toolButton_quick_view.clicked.connect(self.on_quickview)
self.subwindows["quick_view"] = sub
# signals
self.block_matrix.quickviewed.connect(self.on_quickview_show_dataset)
sub.setSystemMenu(None)
sub.setWindowFlags(QtCore.Qt.CustomizeWindowHint
| QtCore.Qt.WindowTitleHint)
sub.hide()
self.mdiArea.addSubWindow(sub)

Expand Down
1 change: 1 addition & 0 deletions shapeout2/gui/widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .colorbar_widget import ColorBarWidget # noqa: F401
from .double_spin_box_nan import DoubleSpinBoxNan # noqa: F401
from .key_value_table_widget import KeyValueTableWidget # noqa: F401
from .mdi_subwindow_wo_close import MDISubWindowWOButtons # noqa: F401
from .qrangeslider import QRangeSlider # noqa: F401
from .rangecontrol import RangeControl # noqa: F401
from .simple_image_view import SimpleImageView # noqa: F401
Expand Down
12 changes: 12 additions & 0 deletions shapeout2/gui/widgets/mdi_subwindow_wo_close.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from PyQt5 import QtCore, QtWidgets


class MDISubWindowWOButtons(QtWidgets.QMdiSubWindow):
def __init__(self, *args, **kwargs):
super(MDISubWindowWOButtons, self).__init__(*args, **kwargs)
self.setSystemMenu(None)
self.setWindowFlags(QtCore.Qt.CustomizeWindowHint
| QtCore.Qt.WindowTitleHint)

def closeEvent(self, event):
event.ignore()

0 comments on commit 73b4d33

Please sign in to comment.