From: Kevin A. <al...@se...> - 2001-11-21 04:03:44
|
The existing resource format requires a reference back to the module filename and classname as shown by the following fragment of minimal.rsrc.py: { 'type':'Background', 'file':'minimal.py', 'classname':'Minimal', 'name':'bgMin', 'components': This has always seemed sort of redundant to me, but it was necessary based on the original loader mechanism. Now that the loader functionality is limited to configuration options and has been moved to config.py I wanted to see if I could modify the load process. The first simplification appears to work, but before committing the change I thought I would get some feedback (fingers crossed). The change means that the file and classname attributes are no longer used in the resource file and there is no longer a circular import of the main module. In order for the application to know which class to use for the main body of code, that has to be passed in as a parameter. app = model.PythonCardApp(Minimal, filename) A modified minimal.py is shown at the end of this message. I changed the imports. The filename for the resource is optional. If it isn't provided, then the framework looks for a file with the same basename (e.g. 'minimal' + '.rsrc.py'); this is identical to what we used to supply in the user code, but now it is handled automatically by the framework, yet you can still override with your own resource file if necessary. I think this is cleaner than what we had before. This new format means that you can change the main class (Minimal in the code below) to a different class, by simply changing the initialization line. So, unless anyone sees a problem with these initial changes, I'll update all the samples, verify that there aren't any unexpected side effects and check them into cvs tomorrow. I'm going to continue to try and simplify and improve the startup process. For example, configOptions should just be the first thing that the app does, but if I move it then some other way will be needed to force an option such as always showing the shell. The turtle sample always uses a shell and the resourceEditor always shows the Property Editor. The framework still assumes a single background, but that is one of the next changes I have in mind. Essentially, you'll have a main background and any number of additional child windows that contain their own background. I will probably wait on this change until I investigate some other bits since it has some complications as far as the menus, window size, etc. Suggestions on any or all of these issues are welcome. ka --- from PythonCardPrototype import model, config class Minimal(model.Background): def on_menuFileExit_select(self, menu, event): self.Close() if __name__ == '__main__': config.configOptions() app = model.PythonCardApp(Minimal) app.MainLoop() |