toga icon indicating copy to clipboard operation
toga copied to clipboard

Add content argument to MainWindow instantiation

Open hyuri opened this issue 1 year ago • 1 comments

What is the problem or limitation you are having?

Right now, to create a MainWindow and add content to it, we have to do it in two steps and in a not so elegant way:

self.main_window = toga.MainWindow(
	title=self.formal_name
)

self.main_window.content = self.main_box

Describe the solution you'd like

Allow assigning "content" during instantiation of MainWindow as well, so we can do it in one step and more elegantly:

self.main_window = toga.MainWindow(
	title=self.formal_name,
	content=self.main_box
)

This would be consistent with, for example, ScrollContainer.

Describe alternatives you've considered

  1. Make it consistent with other classes — that use "children" — and use "child" instead:
self.main_window = toga.MainWindow(
	title=self.formal_name,
	child=self.main_box
)
  1. Or keep things as they are, at least until other higher priority tasks are completed, as this is a minor improvement

Additional context

No response

hyuri avatar Dec 29 '23 18:12 hyuri

That's an odd inconsistency - I'm surprised I didn't notice this before. Agreed that it's something we should address.

content= would seem the obvious API spelling.

freakboy3742 avatar Dec 30 '23 00:12 freakboy3742

Currently working on this at PyCon Sprints.

Franklin19c avatar May 20 '24 15:05 Franklin19c

@Cameronsplaze is now looking at this in #2586.

mhsmith avatar May 20 '24 21:05 mhsmith

I believe that I have everything ready. I'll submit the PR now. This is my first PR for any projects like this, and I had limited time at the sprints. Please don't let me hold anything up.

Franklin19c avatar May 21 '24 01:05 Franklin19c