Short update Dirk Meyer wrote: > 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.
Done, it's eitheronly event, event and menuw or event, menuw and item. See a description at eventhandler.py > 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. Started this, see 3. > 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. I moved item.py and menu.py in a subdir menu. Everything is prepared for task 2, using Action for all the callbacks. There is an ActionWrapper defined used for the old callbacks. I hope everything still works, now I (or someone else) need to change all actions() functions to return Action objects and remove the import of item. Dischi -- I started out with nothing... I still have most of it.
pgpdSPsSNgDoq.pgp
Description: PGP signature