[Python-3000] GUI -- an API, not a toolkit

Giovanni Bajo rasky at develer.com
Wed May 10 11:51:56 CEST 2006


>> [Antoine Pitrou]
>> But magic numbers are ugly, even if they are hidden behind an
>> enumeration. If you try to print them for debugging, it will only show
>> the numeric values, which is hardly intuitive.
>> [...]

>> [Giovanni Bajo]
>> No, you're over-generalizing. What if I wanted the buttons Ok/Cancel
>> instead? Or "Abort"/"Retry"/"Cancel"? The mental overhead is having
>> to remember different APIs from the Yes/No case, if you're going to
>> use a specialized version returning just a boolean.

> [Greg Erwing]
> In PyGUI I've tried to get some consistency here by
> returning 1 or 0 for Yes-No dialogs (so you can
> use it as a boolean if you want) and 1, 0, -1 for
> three buttons (Yes, No, Cancel).

Then, I'd like to have a name for 1,0,-1 instead of using the bare numbers (in
case there are 4 buttons...). So, we're back to what Qt does: you're using
magic numbers too. I don't think there's a way out.

Giovanni Bajo



More information about the Python-3000 mailing list