Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading ST plugin causes TypeError: list indices must be integers or slices, not NoneType #23

Open
joshuacwnewton opened this issue Feb 21, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@joshuacwnewton
Copy link
Member

While trying to debug #21, I followed the installation instructions here, then followed the "Running" instructions here. All I did was run shimming-toolbox then Settings -> Ortho View (1) -> Shimming Toolbox.

Nothing happens in the GUI, and in the terminal I see:

File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes/frame.py", line 787, in wrapper
    self.__onViewPanelMenuItem(vp, aname, sc, **kwargs)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes/frame.py", line 937, in __onViewPanelMenuItem
    func()
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes/actions/base.py", line 347, in __call__
    result  = Action.__call__(self, *args, **kwargs)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes/actions/base.py", line 200, in __call__
    return self.__func(*args, **kwargs)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes/actions/togglecontrolpanel.py", line 84, in __togglePanel
    **self.__kwargs)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes/views/viewpanel.py", line 521, in togglePanel
    **kwargs)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes_plugin_shimming_toolbox/st_plugin.py", line 60, in __init__
    my_panel = TabPanel(self)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes_plugin_shimming_toolbox/st_plugin.py", line 154, in __init__
    tab2 = FieldMapTab(nb)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes_plugin_shimming_toolbox/st_plugin.py", line 1092, in __init__
    info_text="Algorithm for unwrapping"
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes_plugin_shimming_toolbox/st_plugin.py", line 362, in __init__
    self.on_choice(None)
  File "/home/joshua/shimming-toolbox/python/envs/pst_venv/lib/python3.7/site-packages/fsleyes_plugin_shimming_toolbox/st_plugin.py", line 400, in on_choice
    self.input_text_boxes = self.list_components[index].input_text_boxes
TypeError: list indices must be integers or slices, not NoneType

So, for some reason, index is None.

I did some print-statement debugging, and found that selection is returned as an empty string "".

selection = self.choice_box.GetString(self.choice_box.GetSelection())

So, self.find_index() fails to find anything, hence the crash:

I'm still not sure why selection is an empty string in the first place. I thought I would stop here and report to get insight from folks who have worked on st_plugin.py for longer.

@joshuacwnewton joshuacwnewton added the bug Something isn't working label Feb 21, 2022
@joshuacwnewton
Copy link
Member Author

(Anyways, to continue debugging #21, I just quickly modified self.find_index to return 0 if the label can't be found. Once I did that, then the plugin loaded fine. But obviously I don't recommend that as a fix -- I just did that to demonstrate that this is the only issue I ran into.)

@gaspardcereza
Copy link
Member

Hi @joshuacwnewton. I just encountered the same problem when trying to open the GUI in WSL2. I don't really understand what happens here especially since it works just fine on macOS... What OS are you using ?

@gaspardcereza
Copy link
Member

gaspardcereza commented Feb 24, 2022

It seems to me that this happens because the dropdown box is empty when we initialize the GUI so we get selection = "". and nothing is displayed. However, I don't get why it does not occur on macOS...

image

@joshuacwnewton
Copy link
Member Author

What OS are you using ?

I encountered the issue on Ubuntu 20.04, so that would align with you encountering it in WSL2 (I presume with Ubuntu?)

@gaspardcereza
Copy link
Member

Indeed I use a Ubuntu 20.04 distribution inside WSL2. Have you ever experienced something similar in the past (something that works on macOS but not on Ubuntu) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants