On Sun, Oct 24, 2010 at 02:51:16PM +0200, Jérôme Borme wrote: > I would like to use the pygwy interface to batch-process containers by > calling > modules with specific parameters. I tried something like this: > > cons = gwy_app_data_browser_get_containers() > for c in cons: > --> c.set_double_by_name("/module/cwt/scale", 10.0) > gwy_process_func_run("cwt", c, RUN_IMMEDIATE) > > How should I put it to work?
By doing something like this: import re, gwyutils settings = gwy_app_settings_get() settings.set_double_by_name('/module/cwt/scale', 10.0) for container in gwy_app_data_browser_get_containers(): for key in container.keys_by_name(): m = re.match(r'^/(?P<i>\d+)/data$', key) if not m: continue i = int(m.group('i')) gwy_app_data_browser_select_data_field(container, i) gwy_process_func_run('cwt', container, RUN_IMMEDIATE) There are several things to note: - the module parameters are in settings, which is a container separate from data itself - container corresponds to a file so to iterate over all loaded channels you need to iterate at two levels: files (containers) and data fields inside them - there is a function to enumerate data fields but I find it simpler to just match the regexp /\d+/data on all container keys - to run a module function on a specific channel you need to select it in the data browser (this is a bit silly but follows from the fact that you essentially simulate what the user would do using the GUI) Regards, Yeti ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Gwyddion-users mailing list Gwyddion-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gwyddion-users