Dirk Meyer wrote: >> 2 : >> All input-widgets/windows could also use a (kw)args paramerer that >> gets passed to the callback. > > Were? At the eventhandler? Yes, it should. But remember, when the main > loop calls the eventhandler, there is no args at all, only the > menuw. So you can add args to an event if you like. But still, when > pressing a button, there is only the event, were should the args come > from?
OK, after some thinking, I guess we need to change this. Changing it will be ahard query-replace job, so I will only do it once. So it would be great if somone would discuss the requirements with me. 1. eventhandler. An eventhandler is for getting events. So it should always be eventhandler(self, event, menuw=None). I don't see a way to change this. Events when playing something have menuw=None, else menuw is the current active MenuWidget object. 2. actions and it's callbacks Right now actions() return a list of title, function and some additional settings. This is bad, because the list can have a different size. I started using an Action class for this, so I guess we should switch to this one: Action(title, function, description='', shortcurt='') To make it possible to send arguments to a function (we do this right now with some bad hacks), I was thinking about a function to set parameter for an action: a = Action(...) a.parameter(*args, **kwargs) When the action is called, function(menuw, *args, *kwargs) is called. Plugin also need the current item (right now we do this by saving the item in the actions() function, so for plugins it would be function(item, menuw, *args, *kwargs) To show actions in the submenu, I guess Action should inherit from Item. By this we would change all functions in actions from the parameter args, menuw to a better parameter based call. 3. The menu itself While I'm changing stuff, maybe clean up the menu code. Right now the menu is in two files, menu.py and item.py, both holding more than one class. What do you think about moving this two files into a directory menu with a file for each class. The menu you see is a MenuWidget. First of all, is it a widget? Or is it a MenuStack (menus)? We could remove the gui/application part out of the menuw. Make a basic menuw class in the menu subdir and the menu stack with all the gui stuff inherit from menuw and application and put it into applications. 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? Dischi -- Veni, Vidi, VISA: I came, I saw, I did a little shopping.
pgpuJAgRw3UTM.pgp
Description: PGP signature