fixes for python3
This commit is contained in:
parent
4886270b53
commit
2aac1faa17
@ -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()
|
||||
|
||||
|
@ -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)
|
Loading…
Reference in New Issue
Block a user