Martijn Voncken wrote:
> Dirk Meyer wrote:
>>Comments please, I don't like to do this, but if I have to, I want to
>>do it right. So did I miss something?
>
> Hi Dichi,
>
> I did not mean to propose such a drastic change.
> But when things start changing lots of unexpected things pop up ;-).

Yes. But when we change, we should do it right.

> I encountered 2  "real-world" problems when trying to build a ui for
> smart-playlists/albumtree, i guess the same applies to eborn and his
> runtime-config.
> I mentioned them before but I'll try to explain with examples now.
>
> M1:
> The readability of call/callback on menuitems
>    menu.MenuItem(tree.name,action=self.MyCallback,arg=[list-of-my-arguments])
>
> A beautiful solution for me would be:
>   *arg,**kwarg instead of arg.
>   Tough search and replace job!!

A problem with the *arg and **kwarg ist that MenuItem also has
"normal" parameter. So what is normal and what should be part of the
function call? In fact MenuItem is only a short version of an Item
with one Action. So one question is how Action should handle such
things and the second, how MenuItem should do it.

> A good-enough alternative would be: only use **kwargs on callback.
>    menu.MenuItem(tree.name,action=self.MyCallback,arg=[list-of-my-arguments]
>                                  ,kwargs={dict-of-my-named-arguments})
>    Backwards compatible. + (not a lot of work??)

Having arg and kwargs as parameter doesn't look so good. It's a
personal feeling, that's all. Most parts of Freevo don't use MenuItem,
they use a self build Item with Actions.

> M2: 
> Input windows, do not pass args back so state has to be kept in another 
> object.
> By Input-Widgets/Input-Windows I really meant the following windows :
> Confirmbox,InputBox and Future input-windows like SelectionList,ComboBox etc.
> Those windows handle their own callback.
>
> Quick example  inputBox(no patch just some quick pseudo-code):
> -----
> on initialize of InputBox:
> def __init__(self,default-parameters,*args,**kwargs)
>       self.callback_args = args
>       self.callback_kwargs = kwargs
> ------       
> eventhandler of inputbox:
>         elif event == INPUT_ENTER:
>             if self.handler:
>                 #OLD CODE: ret = self.handler(self.value)
>                 #REPLACE WITH:
>                 ret =
> self.handler(self.value,*self.callback_args,**self.callback_kwargs)
>                 #END REPLACE

A good way would not use *self.callback_args here but "normal"
function parameter. Example: callback function is self.foo and *args
is ('foo', 'bar'). The foo function caould look like this:
def foo(self, param1=None, param2=None, param3=None)

> An alternative would be to just add args,kwargs parameters without the * and 
> **
> Because It would be confusing to tell what parameters are meant for
> input-window, and what parameters are meant for the callback.
>
> Now back to your remarks:
> D1:eventhandler.
> I agree
>
> D2:actions and it's callbacks
> Ahhh,actions() is also a lot like creating a menu with
> menu.MenuItem(), i forgot about that.
> It would be better to return a list of objects there indeed.
> And a lot of work....
> What is the functional difference between a MenuItem() and an Action()?
> A MenuItem() is an Action() with gui?

The menu has Items. On select, it called the actions() function to get
the possible actions. MenuItem is some sort of simple Item. It
inherits from item and has only one action you can set in __init__.


Dischi

-- 
Linux is for Network
Mac is for Artwork
Windows is for Solitaire

Attachment: pgpQX98aXPnQR.pgp
Description: PGP signature

Reply via email to