The style of arguments in the GUI examples

There are code examples in the Panda GUI manual. However, too many arguments make the code cumbersome and unreadable. I would like to discuss the external code style for such cases.

I suggest we do it this way:

textObject = OnscreenText(
    text="This is my Demo",
    pos=(0.95, -0.95),
    fg=(1, 0.5, 0.5, 1),


textObject = OnscreenText(mayChange=1)
textObject.setText("This is my Demo")
textObject.setPos(0.95, -0.95)
textObject.setFg((1, 0.5, 0.5, 1))

The second method is also a way to get to know the API.

At the moment the original looks like this:

bk_text = "This is my Demo"
textObject = OnscreenText(text=bk_text, pos=(0.95, -0.95), scale=0.07,
                          fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter,

Which looks neat to me, but it’s not very informative or structured.

I definitely prefer the first style that you posted–all parameters listed vertically. I find it much more readable, I do believe. And being more readable, it seems likely to not only make for code that’s easier to work with, but also examples that are easier to learn from.

As to the second style, I think that there are a few parameters that don’t work properly if not applied in the constructor; as a result, the first style seems like the safer.

I like the vertical listing in the first sample too.

In fact, the question here is rather philosophical. In the GUI examples, there is an abuse of arguments for the constructor class. This leads to going beyond the style for other classes. I’m not talking about access through keys, it’s completely beyond common sense.

It is ideal to use arguments for immutable class properties via the constructor. Properties that can change during program execution, it is best to use the API function.

Hmm… I don’t know: I rather like being able to specify the details of a given widget in a single constructor-line, and the constructor makes sense to me as a place in which to specify such details.

But as you say, it’s a matter of philosophy: some will prefer one way, and some will prefer the other.