Skip to content

Textual apps require window content to run #2818

Open
@rmartin16

Description

@rmartin16

Describe the bug

If a Toga textual app does not define any window content, the app will crash.

❯ TOGA_BACKEND=toga_textual \
python -c 'import toga; toga.App(formal_name="MyApp", app_id="MyApp").main_loop()'

╭───────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────╮
│ /home/russell/github/beeware/toga/textual/src/toga_textual/window.py:111 in on_resize                                                                               │
│                                                                                                                                                                     │
│   108 │   │   self.impl = impl                                                                                                                                      │
│   109 │                                                                                                                                                             │
│   110 │   def on_resize(self, event) -> None:                                                                                                                       │
│ ❱ 111 │   │   self.interface.content.refresh()                                                                                                                      │
│   112                                                                                                                                                               │
│   113                                                                                                                                                               │
│   114 class Window:                                                                                                                                                 │
│                                                                                                                                                                     │
│ ╭───────────────────────────────────────── locals ─────────────────────────────────────────╮                                                                        │
│ │ event = Resize(size=Size(width=167, height=43), virtual_size=Size(width=167, height=43)) │                                                                        │
│ │  self = TogaMainWindow()                                                                 │                                                                        │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯                                                                        │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'refresh'

Steps to reproduce

Run this app:

TOGA_BACKEND=toga_textual \
python -c 'import toga; toga.App(formal_name="MyApp", app_id="MyApp").main_loop()'

Windows:

$env:TOGA_BACKEND="toga_textual"
python -c 'import toga; toga.App(formal_name="MyApp", app_id="MyApp").main_loop()'

Expected behavior

Apps using the textual backend are not required to use window content.

Screenshots

No response

Environment

  • Operating System: all
  • Python version:
  • Software versions:
    • Briefcase: 0.3.20.dev192+g32f529a4
    • Toga: 0.4.7.dev43+g63480d545

Logs

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA crash or error in behavior.good first issueIs this your first time contributing? This could be a good place to start!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions