Cocoa Button Cramped with Parent Not In Layout
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 40
Description
### Describe the bug
```
import os
import toga
from toga.style import Pack
from toga.style.pack import CENTER
def button_handler(widget):
print("Button clicked!")
def button_handler2(widget):
print("Button2 clicked!")
def build(app):
box = toga.Box()
button = toga.Button('Click Me', on_press=button_handler, style=Pack(margin=5))
box.add(button)
return button
def main():
return toga.App('Simple Button App', 'org.example.simplebutton', startup=build)
if __name__ == '__main__':
app = main()
app.main_loop()
```
So over here the content should be a button that fills the window but we instead get this cramped:
### Steps to reproduce
- Install Toga 0.5.2
- Run the above repro
- See cramped button
### Expected behavior
Something like this, i.e. box.add(button) does not impact layout at all.
### Screenshots
_No response_
### Environment
- macOS Sonoma
- Toga 0.5.2
- Python 3.10.14
- Rubicon-objc 0.5.1
### Logs
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by running the provided Python button example with Toga 0.5.2 on macOS Sonoma and compare the button's layout when it is added to the box. Trace the Cocoa layout path for a parent that is not explicitly configured for layout. Done means box.add(button) leaves the button filling the window as shown in the expected screenshot.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100