Skip to content

Commit

Permalink
Fix not to use setFilterMode in PyQt4
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Aug 1, 2018
1 parent 636decd commit 55c7ec8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions labelme/widgets/label_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

QT5 = QT_VERSION[0] == '5' # NOQA

from labelme import logger
import labelme.utils


Expand Down Expand Up @@ -64,12 +65,19 @@ def __init__(self, text="Enter object label", parent=None, labels=None,
self.setLayout(layout)
# completion
completer = QtWidgets.QCompleter()
if not QT5 and completion != 'startswith':
logger.warn(
"completion other than 'startswith' is only "
"supported with Qt5. Using 'startswith'"
)
completion = 'startswith'
if completion == 'startswith':
completer.setFilterMode(QtCore.Qt.MatchStartsWith)
completer.setCompletionMode(QtWidgets.QCompleter.InlineCompletion)
# Default settings.
# completer.setFilterMode(QtCore.Qt.MatchStartsWith)
elif completion == 'contains':
completer.setFilterMode(QtCore.Qt.MatchContains)
completer.setCompletionMode(QtWidgets.QCompleter.PopupCompletion)
completer.setFilterMode(QtCore.Qt.MatchContains)
else:
raise ValueError('Unsupported completion: {}'.format(completion))
completer.setModel(self.labelList.model())
Expand Down

0 comments on commit 55c7ec8

Please sign in to comment.