Skip to content

Commit

Permalink
Merge pull request #61 from paulromano/fix-qfontmetrics-width
Browse files Browse the repository at this point in the history
Fix deprecation warning on QFontMetrics.width
  • Loading branch information
pshriwise authored Apr 15, 2021
2 parents 6532d9e + e341fdc commit 71524a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion openmc_plotter/docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 6 additions & 5 deletions openmc_plotter/plotgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -812,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)
Expand Down
10 changes: 5 additions & 5 deletions openmc_plotter/plotmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 71524a3

Please sign in to comment.