enthought / enthought/traitsui
WX helper save_window pos + size behavior
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
Started seeing this issue with the examples and my own code from the get go.
```
$ python3 File_Open_with_ImageInfo_Extension.py
09:59:25: Debug: Adding duplicate image handler for 'Windows bitmap file'
09:59:25: Debug: Adding duplicate animation handler for '1' type
09:59:25: Debug: Adding duplicate animation handler for '2' type
09:59:25: Debug: Adding duplicate image handler for 'Windows bitmap file'
09:59:25: Debug: Adding duplicate animation handler for '1' type
09:59:25: Debug: Adding duplicate animation handler for '2' type
09:59:25: Debug: Adding duplicate image handler for 'Windows bitmap file'
09:59:25: Debug: Adding duplicate animation handler for '1' type
09:59:25: Debug: Adding duplicate animation handler for '2' type
Exception occurred in traits notification handler for object: <__main__.FileDialogDemo object at 0x7fa4d3021ea0>, trait: open, old value: , new value: 0
Traceback (most recent call last):
File "/home/dev/.local/lib/python3.8/site-packages/traits/trait_notifiers.py", line 342, in __call__
self.handler(*args)
File "File_Open_with_ImageInfo_Extension.py", line 79, in _open_changed
file_name = open_file(
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/file_dialog.py", line 671, in open_file
if fd.edit_traits(view="open_file_view").result:
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/handler.py", line 427, in edit_traits
return self.trait_view(view).ui(
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/view.py", line 457, in ui
ui.ui(parent, kind)
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/ui.py", line 234, in ui
self.rebuild(self, parent)
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/wx/toolkit.py", line 110, in ui_livemodal
ui_live.ui_livemodal(ui, parent)
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/wx/ui_live.py", line 52, in ui_livemodal
_ui_dialog(ui, parent, BaseDialog.MODAL)
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/wx/ui_live.py", line 81, in _ui_dialog
BaseDialog.display_ui(ui, parent, style)
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/wx/ui_base.py", line 79, in display_ui
restore_window(ui, is_popup=(style in BaseDialog.POPUP_TYPES))
File "/home/dev/.local/lib/python3.8/site-packages/traitsui/wx/helper.py", line 149, in restore_window
x, y, dx, dy = prefs
ValueError: not enough values to unpack (expected 4, got 2)
```
I traced the issue until `/home/dev/.local/lib/python3.8/site-packages/traitsui/wx/helper.py`
```
def save_window(ui):
"""Saves the user preference items for a specified UI."""
control = ui.control
print("pos")
print(type(control.GetPosition()))
print(control.GetPosition())
print("size")
print(type(control.GetSize()))
print(control.GetSize())
print("possize")
print(control.GetPosition() + control.GetSize())
ui.save_prefs(control.GetPosition() + control.GetSize())
```
and added some debug prints. Output:
```
pos
(1928, 864)
size
(2406, 432)
possize
(4334, 1296)
```
I assume, that the intention is to concatenate the the Point and Size into 4 element tuple(?) but for some reason the elements are added together ending up to 2 element tuple. This then fails when trying to restore the window and preferences.
I'd expect plenty of users to be hit by this so might be that my setup is corrupted or something.
Env:
```
$ python3 --version
Python 3.8.10
$ pip show traitsui
Name: traitsui
Version: 7.4.0
Summary: traitsui: traits-capable user interfaces
Home-page: http://docs.enthought.com/traitsui
Author: David C. Morrill, et. al.
Author-email: dmorrill@enthought.com
License: BSD
Location: /home/dev/.local/lib/python3.8/site-packages
Requires: pyface, traits
Required-by: apptools
$ pip show wxPython
Name: wxPython
Version: 4.2.0
Summary: Cross platform GUI toolkit for Python, "Phoenix" version
Home-page: http://wxPython.org/
Author: Robin Dunn
Author-email: robin@alldunn.com
License: wxWindows Library License (https://opensource.org/licenses/wxwindows.php)
Location: /home/dev/.local/lib/python3.8/site-packages
Requires: numpy, pillow, six
Required-by:
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.