Skip to content

Commit

Permalink
Further fixes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Apr 15, 2018
1 parent 8bc696f commit 47d8b71
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion glue/external/echo/qt/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _find_combo_data(widget, value):
# Here we check that the result is True, because some classes may overload
# == and return other kinds of objects whether true or false.
for idx in range(widget.count()):
if widget.itemData(idx).data is value or (widget.itemData(idx).data == value) is True:
if widget.itemData(idx) is not None and (widget.itemData(idx).data is value or (widget.itemData(idx).data == value) is True):
return idx
else:
raise ValueError("%s not found in combo box" % (value,))
Expand Down
17 changes: 3 additions & 14 deletions glue/utils/qt/widget_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def __init__(self):
from glue.external.six.moves import reduce
from glue.utils.array import pretty_number

from glue.external.echo.qt.connect import _find_combo_data

# Backward-compatibility
from glue.external.echo.qt import (connect_checkable_button as connect_bool_button,
connect_combo_data as connect_current_combo,
Expand Down Expand Up @@ -98,7 +100,7 @@ def getter(self, widget):
if widget.currentIndex() == -1:
return None
else:
return widget.itemData(widget.currentIndex())
return widget.itemData(widget.currentIndex()).data

def setter(self, widget, value):
"""
Expand Down Expand Up @@ -264,16 +266,3 @@ def setter(self, widget, val):
vmin, vmax = self.value_range
val = (val - vmin) / (vmax - vmin) * (imax - imin) + imin
widget.setValue(val)


def _find_combo_data(widget, value):
"""
Returns the index in a combo box where itemData == value
Raises a ValueError if data is not found
"""
i = widget.findData(value)
if i == -1:
raise ValueError("{0} not found in combo box".format(value))
else:
return i
3 changes: 2 additions & 1 deletion glue/viewers/custom/qt/custom_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
from glue.core.edit_subset_mode import EditSubsetMode
from glue.utils import nonpartial, as_list, all_artists, new_artists, remove_artists
from glue import core
from glue.external.echo.qt.connect import UserDataWrapper

from glue.viewers.common.viz_client import GenericMplClient

Expand Down Expand Up @@ -1397,7 +1398,7 @@ def _update_components(self):

comps = self._list_components()
for c in comps:
combo.addItem(c.label, userData=c)
combo.addItem(c.label, userData=UserDataWrapper(c))

try:
combo.setCurrentIndex(comps.index(old))
Expand Down

0 comments on commit 47d8b71

Please sign in to comment.