On Thu, Jan 16, 2014 at 11:48 AM, Tim Chase <python.l...@tim.thechases.com> wrote: > On 2014-01-16 10:09, Chris Angelico wrote: >> myWindow = Window( >> title="Hello World", >> children=[Button( >> label="I'm a button", >> onClick=exit >> )] >> ) > > This also solves the problem that **kwargs are just a dict, which is > inherently unordered. So with the previous scheme, you'd just get an > unordered bag of controls that Python could then dump into your > containing window as its dict-traversal algorithms saw fit. :-)
Yeah, I don't really want my window layout to randomize every Python startup :) Actually... I'm really REALLY glad code like the previous version wasn't prevalent. It would have made for intense opposition to hash randomization - as I recall, the strongest voice against randomization was that tests would start to fail (IMO, a simple way to print a dictionary with its keys sorted would both solve that and provide an aesthetically-pleasing display). Imagine if someone spent hours crafting child object names in order to force the children to be added in the right order, and then along comes the new Python and it's all broken... But I still think it should be a method (as it is in GTK, not familiar enough with the others), as there's no way with the parameter system to (a) add children after object creation, or (b) specify parameters (GTK's boxes let you choose, per-child, whether they'll be expanded to fill any spare space - by default they all will, ie spare room is split between them, but often you want to choose one to be expanded and another not). PyGTK is mostly there, but since its .add() method returns None, chaining isn't possible. Method chaining like that is somewhat controversial... I would love to have some kind of syntax that says "and the value of this expression is the bit before the dot", but I have no idea what would be clean. ChrisA -- https://mail.python.org/mailman/listinfo/python-list