From 2822ac85876e82f1148c011c1418336b23a7f56b Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 15 Apr 2021 07:12:24 -0500 Subject: [PATCH 1/3] Fix warnings about QFontMetrics.width being deprecated --- openmc_plotter/plotgui.py | 9 +++++---- openmc_plotter/plotmodel.py | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openmc_plotter/plotgui.py b/openmc_plotter/plotgui.py index 0c2f750..65a7149 100644 --- a/openmc_plotter/plotgui.py +++ b/openmc_plotter/plotgui.py @@ -736,9 +736,10 @@ def createGeneralTab(self): self.maskingCheck = QCheckBox('') self.maskingCheck.stateChanged.connect(main_window.toggleMasking) + button_width = self.font_metric.boundingRect("XXXXXXXXXX").width() self.maskColorButton = QPushButton() self.maskColorButton.setCursor(QtCore.Qt.PointingHandCursor) - self.maskColorButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX")) + self.maskColorButton.setFixedWidth(button_width) self.maskColorButton.setFixedHeight(self.font_metric.height() * 1.5) self.maskColorButton.clicked.connect(main_window.editMaskingColor) @@ -748,7 +749,7 @@ def createGeneralTab(self): self.hlColorButton = QPushButton() self.hlColorButton.setCursor(QtCore.Qt.PointingHandCursor) - self.hlColorButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX")) + self.hlColorButton.setFixedWidth(button_width) self.hlColorButton.setFixedHeight(self.font_metric.height() * 1.5) self.hlColorButton.clicked.connect(main_window.editHighlightColor) @@ -764,7 +765,7 @@ def createGeneralTab(self): # General options self.bgButton = QPushButton() self.bgButton.setCursor(QtCore.Qt.PointingHandCursor) - self.bgButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX")) + self.bgButton.setFixedWidth(button_width) self.bgButton.setFixedHeight(self.font_metric.height() * 1.5) self.bgButton.clicked.connect(main_window.editBackgroundColor) @@ -788,7 +789,7 @@ def createGeneralTab(self): self.overlapColorButton = QPushButton() self.overlapColorButton.setCursor(QtCore.Qt.PointingHandCursor) - self.overlapColorButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX")) + self.overlapColorButton.setFixedWidth(button_width) self.overlapColorButton.setFixedHeight(self.font_metric.height() * 1.5) self.overlapColorButton.clicked.connect(main_window.editOverlapColor) diff --git a/openmc_plotter/plotmodel.py b/openmc_plotter/plotmodel.py index 335d38d..e77f133 100644 --- a/openmc_plotter/plotmodel.py +++ b/openmc_plotter/plotmodel.py @@ -984,13 +984,13 @@ def sizeHint(self, option, index): column = index.column() if column == ID: - return QSize(fm.width("XXXXXX"), fm.height()) + return QSize(fm.boundingRect("XXXXXX").width(), fm.height()) elif column == COLOR: - return QSize(fm.width("XXXXXX"), fm.height()) + return QSize(fm.boundingRect("XXXXXX").width(), fm.height()) elif column == COLORLABEL: - return QSize(fm.width("X(XXX, XXX, XXX)X"), fm.height()) + return QSize(fm.boundingRect("X(XXX, XXX, XXX)X").width(), fm.height()) elif column == MASK: - return QSize(fm.width("XXXX"), fm.height()) + return QSize(fm.boundingRect("XXXX").width(), fm.height()) else: return QItemDelegate.sizeHint(self, option, index) From 9cc65cf9a400cb9236c79532c227b7f40a637791 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 15 Apr 2021 07:14:12 -0500 Subject: [PATCH 2/3] Fix a few labels --- openmc_plotter/docks.py | 2 +- openmc_plotter/plotgui.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc_plotter/docks.py b/openmc_plotter/docks.py index 96ffcd8..1a4a11c 100644 --- a/openmc_plotter/docks.py +++ b/openmc_plotter/docks.py @@ -336,7 +336,7 @@ def __init__(self, model, font_metric, parent=None): self.tallyGroupBox.setLayout(self.tallySelectorLayout) # Create submit button - self.applyButton = QPushButton("ApplyChanges") + self.applyButton = QPushButton("Apply Changes") self.applyButton.setMinimumHeight(self.font_metric.height() * 1.6) self.applyButton.clicked.connect(self.main_window.applyChanges) diff --git a/openmc_plotter/plotgui.py b/openmc_plotter/plotgui.py index 65a7149..d735880 100644 --- a/openmc_plotter/plotgui.py +++ b/openmc_plotter/plotgui.py @@ -813,7 +813,7 @@ def createGeneralTab(self): formLayout.addRow('Background Color: ', self.bgButton) formLayout.addRow(HorizontalLine()) formLayout.addRow('Show Overlaps:', self.overlapCheck) - formLayout.addRow('OVerlap Color:', self.overlapColorButton) + formLayout.addRow('Overlap Color:', self.overlapColorButton) formLayout.addRow(HorizontalLine()) formLayout.addRow('Color Plot By:', self.colorbyBox) formLayout.addRow('Universe Level:', self.universeLevelBox) From e341fdcbd8688858345dd30f7202b813bb3fdebb Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 15 Apr 2021 07:15:22 -0500 Subject: [PATCH 3/3] Fix missing import of QMessageBox --- openmc_plotter/plotmodel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc_plotter/plotmodel.py b/openmc_plotter/plotmodel.py index e77f133..941bb68 100644 --- a/openmc_plotter/plotmodel.py +++ b/openmc_plotter/plotmodel.py @@ -4,7 +4,7 @@ import threading from ast import literal_eval -from PySide2.QtWidgets import QItemDelegate, QColorDialog, QLineEdit +from PySide2.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox from PySide2.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent from PySide2.QtGui import QColor import openmc