peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Apache License 2.0
3.61k stars 238 forks source link

Fatal Error when Multiple Frames in a scene with widgets #353

Closed jameswhiteguitar closed 2 years ago

jameswhiteguitar commented 2 years ago

If you run the StackBootstrap_TUI.py file and click on start configuration, it will bring you to our main page, which is where we are experiencing the inability to move the focus from frame to frame using the keyboard. I am sure that our code is not the cleanest, we may not be configuring scenes in the most efficient way as well. As for resolving the frame-switching issue, is that something that you would add or we would have to do on our end? BuggedTUI.zip

bash-4.4$ /bin/python3 /home/knack.works/jwhite/Projects/stack-bootstrap-wizard/StackBootstrap_TUI.py Traceback (most recent call last): File "/home/knack.works/jwhite/Projects/stack-bootstrap-wizard/StackBootstrap_TUI.py", line 392, in Screen.wrapper(demo, catch_interrupt=True, arguments=[last_scene]) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/screen.py", line 1433, in wrapper return func(screen, *arguments) File "/home/knack.works/jwhite/Projects/stack-bootstrap-wizard/StackBootstrap_TUI.py", line 386, in demo screen.play(scenes, stop_on_resize=True, start_scene=scene, allow_int=True) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/screen.py", line 1606, in play self.draw_next_frame(repeat=repeat) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/screen.py", line 1694, in draw_next_frame event = scene.process_event(event) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/scene.py", line 105, in process_event event = effect.process_event(event) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/widgets/frame.py", line 708, in process_event self._switch_to_nearest_vertical_widget(-1) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/widgets/frame.py", line 637, in _switch_to_nearest_vertical_widget match = self._layouts[focus].get_nearest_widget(current_widget, direction) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/widgets/layout.py", line 286, in get_nearest_widget new_distance = _euclidian_distance(target_widget, candidate) File "/home/knack.works/jwhite/.local/lib/python3.6/site-packages/asciimatics/widgets/utilities.py", line 259, in _euclidian_distance point1 = widget1.get_location() AttributeError: 'NoneType' object has no attribute 'get_location'

Steps to Reproduce: Click in a separate frame, see the highlighted widgets. Click into another frame and use arrow keys to navigate past the bottom or top of a list of widgets

Thank you for your help.

peterbrittain commented 2 years ago

It's a bug in asciimatics where it doesn't expect a Frame to have no current widget. I'll sort a fix for this.

peterbrittain commented 2 years ago

This fixed the bug for me. LMK 8f you still have problems with this build...