fixes for python3
This commit is contained in:
parent
4886270b53
commit
2aac1faa17
@ -1,6 +1,6 @@
|
|||||||
from ..Qt import QtGui, QtCore
|
from ..Qt import QtGui, QtCore
|
||||||
from ..SignalProxy import SignalProxy
|
from ..SignalProxy import SignalProxy
|
||||||
from ..ordereddict import OrderedDict
|
from ..pgcollections import OrderedDict
|
||||||
from ..python2_3 import asUnicode
|
from ..python2_3 import asUnicode
|
||||||
|
|
||||||
class ComboBox(QtGui.QComboBox):
|
class ComboBox(QtGui.QComboBox):
|
||||||
@ -189,9 +189,9 @@ class ComboBox(QtGui.QComboBox):
|
|||||||
texts = items
|
texts = items
|
||||||
items = dict([(x, x) for x in items])
|
items = dict([(x, x) for x in items])
|
||||||
elif isinstance(items, dict):
|
elif isinstance(items, dict):
|
||||||
texts = items.keys()
|
texts = list(items.keys())
|
||||||
else:
|
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:
|
for t in texts:
|
||||||
if t in self._items:
|
if t in self._items:
|
||||||
@ -200,7 +200,7 @@ class ComboBox(QtGui.QComboBox):
|
|||||||
|
|
||||||
for k,v in items.items():
|
for k,v in items.items():
|
||||||
self._items[k] = v
|
self._items[k] = v
|
||||||
QtGui.QComboBox.addItems(self, texts)
|
QtGui.QComboBox.addItems(self, list(texts))
|
||||||
|
|
||||||
self.itemsChanged()
|
self.itemsChanged()
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def test_combobox():
|
|||||||
assert cb.value() == 5
|
assert cb.value() == 5
|
||||||
|
|
||||||
# Set list instead of dict
|
# Set list instead of dict
|
||||||
cb.setItems(items.keys())
|
cb.setItems(list(items.keys()))
|
||||||
assert str(cb.currentText()) == 'b'
|
assert str(cb.currentText()) == 'b'
|
||||||
|
|
||||||
cb.setValue('c')
|
cb.setValue('c')
|
||||||
@ -40,5 +40,5 @@ if __name__ == '__main__':
|
|||||||
cb.show()
|
cb.show()
|
||||||
cb.setItems({'': None, 'a': 1, 'b': 2, 'c': 3})
|
cb.setItems({'': None, 'a': 1, 'b': 2, 'c': 3})
|
||||||
def fn(ind):
|
def fn(ind):
|
||||||
print "New value:", cb.value()
|
print("New value: %s" % cb.value())
|
||||||
cb.currentIndexChanged.connect(fn)
|
cb.currentIndexChanged.connect(fn)
|
Loading…
Reference in New Issue
Block a user