Skip to content

Commit

Permalink
Preprocess Text - PyQt6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Jan 17, 2023
1 parent 46fa2fd commit de5aeb7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions orangecontrib/text/widgets/owpreprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
QRadioButton, QGridLayout, QLineEdit, QSpinBox, QFormLayout, QHBoxLayout, \
QDoubleSpinBox, QFileDialog, QAbstractSpinBox
from AnyQt.QtWidgets import QWidget, QPushButton, QSizePolicy, QStyle
from AnyQt.QtGui import QBrush
from AnyQt.QtGui import QBrush, QValidator

from Orange.util import wrap_callback
from orangewidget.utils.filedialogs import RecentPath
Expand Down Expand Up @@ -138,7 +138,12 @@ class SpinBox(QSpinBox):
def validate(self, *args):
# accept empty input
valid, text, pos = super().validate(*args)
return 2 if valid else 0, text, pos
new_state = (
QValidator.State.Acceptable
if valid == QValidator.State.Acceptable
else QValidator.State.Invalid
)
return new_state, text, pos

def valueFromText(self, text: str) -> int:
return max(int(text) if text else self.minimum(), self.minimum())
Expand Down Expand Up @@ -242,8 +247,7 @@ def set_file_list(self):
self.file_combo.addItem(recent.basename)
self.file_combo.model().item(i).setToolTip(recent.abspath)
if not os.path.exists(recent.abspath):
self.file_combo.setItemData(i, QBrush(Qt.red),
Qt.TextColorRole)
self.file_combo.setItemData(i, QBrush(Qt.red), Qt.ForegroundRole)
self.file_combo.addItem(_DEFAULT_NONE)

def last_path(self) -> Optional[str]:
Expand Down

0 comments on commit de5aeb7

Please sign in to comment.