New submission from Guilherme Polo <ggp...@gmail.com>: Hi,
It seems to me that it would be useful to add something to indicate which packages should be loaded, and how they should be loaded, when a Tcl interpreter is created through Tkinter.Tk. Right now every extension has to add some boilerplate code to load a package before starting the use of extension, and this code tends to be very similar -- like this: if not required_extension_loaded: extlib = os.environ.get('OPTIONAL_VAR_THAT_POINTS_TO_EXT') if extlib: master.tk.eval('global auto_path; ' 'lappend auto_path {%s}' % extlib) master.tk.call('package', 'require', 'Extlibname') required_extension_loaded = True master is an instance of Tkinter.Tk which has to be created before this, of course. Some extensions do it in different places in their code, but tend to involve basically the same code. The patch attached adds a new module in lib-tk named tkdeploader (not very nice eh) which handles these "indications". Each dependence to be loaded can define its own preloader callable, but the module adds a basic one, named basic_preloader, that should be enough for most situations. The patch also includes the changes necessary in Tkinter.py, just two lines. ---------- components: Tkinter files: tkdeploader.diff keywords: patch messages: 81223 nosy: gpolo severity: normal status: open title: Indicating packages to be loaded when a Tcl interpreter is created in tkinter versions: Python 2.7, Python 3.1 Added file: http://bugs.python.org/file12947/tkdeploader.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5159> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com