On Wed, 2 Jul 2014 09:09:57 -0500 "Edward K. Ream" <[email protected]> wrote:
> On Tue, Jul 1, 2014 at 7:12 PM, 'Terry Brown' via leo-editor > <[email protected]> wrote: > > I've done some experiments and it seems that Qt can send its > > triggered(checked) signal to callables that accept zero or more > > arguments. > > Thanks for this research. The following remarks are based on: > > http://qt-project.org/doc/qt-5/qabstractbutton.html#signals > > The signature of the checked signal is:: > > void clicked(bool checked = false) > > so it seems that from the *python* point of view, the callback might > be called with either zero or one arguments. This should be true > regardless of implementation. This is getting a bit abstract :-) as we know what we need to know, but I agree with your above statement that a callback with that signature could be *called* with zero or one arguments. But you can *define* the callback to accept zero or more arguments, and somehow Qt knows to call it with one arg. when it accepts one or more args, and to call it with zero when it only accepts zero. I.e. Qt can successfully callback either def cb(): or def cb(checked): so somehow it's deciding whether to call it with zero or one args, calling the first form with an arg is an error, the first one does not have the signature (checked=False) Anyway, going forward we know what to do - in some cases it may make more sense to account for the checked arg in the callback definition, in others it might be better to strip it in a lambda. The latter when you want to invoke the cb method from other places in the code and it becomes intrusive to have to pass a dummy placeholder variable to match the signature starting with a 'checked' arg. Cheers -Terry > The "checked" argument is not necessary because there is a > checkState() getter. > > My conclusions: > > 1. The callback's signature should match the documented signature, as > you have said previously. > > 2. It doesn't matter whether the callback is defined using lambda or > def, provided the signature is correct. > > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
