From 2aac1faa176552be07c23b069c1196e1b936ae9e Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Fri, 27 Dec 2013 22:32:05 -0500 Subject: [PATCH] fixes for python3 --- pyqtgraph/widgets/ComboBox.py | 8 ++++---- pyqtgraph/widgets/tests/test_combobox.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyqtgraph/widgets/ComboBox.py b/pyqtgraph/widgets/ComboBox.py index 66ea4205..f9983c97 100644 --- a/pyqtgraph/widgets/ComboBox.py +++ b/pyqtgraph/widgets/ComboBox.py @@ -1,6 +1,6 @@ from ..Qt import QtGui, QtCore from ..SignalProxy import SignalProxy -from ..ordereddict import OrderedDict +from ..pgcollections import OrderedDict from ..python2_3 import asUnicode class ComboBox(QtGui.QComboBox): @@ -189,9 +189,9 @@ class ComboBox(QtGui.QComboBox): texts = items items = dict([(x, x) for x in items]) elif isinstance(items, dict): - texts = items.keys() + texts = list(items.keys()) else: - raise TypeError("items argument must be list or dict.") + raise TypeError("items argument must be list or dict (got %s)." % type(items)) for t in texts: if t in self._items: @@ -200,7 +200,7 @@ class ComboBox(QtGui.QComboBox): for k,v in items.items(): self._items[k] = v - QtGui.QComboBox.addItems(self, texts) + QtGui.QComboBox.addItems(self, list(texts)) self.itemsChanged() diff --git a/pyqtgraph/widgets/tests/test_combobox.py b/pyqtgraph/widgets/tests/test_combobox.py index 300489e0..f511331c 100644 --- a/pyqtgraph/widgets/tests/test_combobox.py +++ b/pyqtgraph/widgets/tests/test_combobox.py @@ -24,7 +24,7 @@ def test_combobox(): assert cb.value() == 5 # Set list instead of dict - cb.setItems(items.keys()) + cb.setItems(list(items.keys())) assert str(cb.currentText()) == 'b' cb.setValue('c') @@ -40,5 +40,5 @@ if __name__ == '__main__': cb.show() cb.setItems({'': None, 'a': 1, 'b': 2, 'c': 3}) def fn(ind): - print "New value:", cb.value() + print("New value: %s" % cb.value()) cb.currentIndexChanged.connect(fn) \ No newline at end of file