wxPython again: Presets.py bug?
Added by Anonymous over 19 years ago
Hi,
we may have found another bug concerning the wxPython interface, but I'm not sure whether this is a bug or a change in the wx interface, so maybe you could give it a look.... Brief reminder: Leginon is running on non-Suse, 2.6.9 kernel with Python 2.3.5, wxWidgets 2.6 and wxPython 2.6.
When running MSI, we get some errors from the wxPython interface when opening the settings dialog in any of the grid- square-, hole- and exposure-nodes. The error message from Python is:
Traceback (most recent call last):
File "/package/leginon/2.6/lib/python2.3/site-packages/Leginon/gui/wx/Acquisition.py", line 84, in onSettingsTool
dialog = SettingsDialog(self)
File "/package/leginon/2.6/lib/python2.3/site-packages/Leginon/gui/wx/Settings.py", line 69, in init
sz = self.initialize()
File "/package/leginon/2.6/lib/python2.3/site-packages/Leginon/gui/wx/Acquisition.py", line 158, in initialize
self.widgets['preset order'].setChoices(presets)
File "/package/leginon/2.6/lib/python2.3/site-packages/Leginon/gui/wx/Presets.py", line 310, in setChoices
self.choice.Enable(choices)
File "/package/leginon/2.6/lib/python2.3/site-packages/wx-2.6-gtk2-ansi/wx/_core.py", line 7192, in Enable
return core.Window_Enable(*args, **kwargs)
TypeError: argument number 2: a 'bool' is expected, 'list(['gr', 'sq', 'hl', 'fc', 'fa', 'ef'])' is received
The settings dialog fails to open. The same thing works correctly on the (Suse) laptop.
The documentation for wx.Window (base class for wx.Choice) on wxpython.org states:
virtual bool Enable(bool enable = true)
I tried changing the source code to reflect the parameters by passing the boolean arg >True< instead of the original (preset-)list >choices< to the function wx.Choice.Enable() in three instances in Presets.py and this seems to work: the dialog opens and seems to work correctly, as far as I can tell. Is this a bug in Presets.py? Will my changes cause any problems or loss of functionality?
Thanks,
Justus
Replies (2)
- Added by Anonymous over 19 years ago
Justus,
This was a bug in 1.0. It was fixed as of 1.1, but if you want to fix your version, you can just cast the 'choices' list to a bool like this:
self.choice.Enable(bool(choices))
Using True all the time will probably work, but converting to bool is more proper, because the choice will not be enabled if 'choices' is an empty list.
There may be a few other instances of this bug, so you might look around for other calls of Enable() and make the same change, or just wait for them to raise an exception.
Jim
- Added by Anonymous over 19 years ago
thanks a lot, i hadn't thought of casting the list to bool; seems kind of obvious now.....
actually, i think i will get busy installing v1.1 now, maybe i will be able to post some new bugs instead of pestering you with old ones. :)