[Thuban-devel] Re: RfD: Support for layer specific resources

Martin Schulze joey at infodrom.org
Wed Aug 11 16:34:17 CEST 2004


Bernhard Herzog wrote:
> > In order to use the new ClassMapper I'd assume that we'll need
> > something like the following:
> >
> >
> > from Thuban.Lib.classmapper import ClassMapper
> >
> > _properties_dialogs = ClassMapper()
> >
> > def add_properties_dialog(layer_class, dialog_class):
> >     _properties_dialogs.add(layer_class, dialog_class)
> >
> > def get_properties_dialog_class(layer):
> >     return _properties_dialogs.get(layer)
> 
> I think in practice only the mainwindow code will look up the dialogs,
> so I'd say, the mapper should be in Thuban/UI/mainwindow.py.  I'd also
> omit the extra functions a simple
> 
> from Thuban.Lib.classmapper import ClassMapper
> 
> layer_properties_dialogs = ClassMapper()
> 
> should suffice.

Ok.

layer_properties_dialogs should become a global variable, I guess?
The classifier doesn't know about the main window, so it cannot
be a variable inside mainwindow, I'd assume.

> > And for Thuban.UI.classifier:
> >
> > add_properties_dialog(Layer, Classifier)
> > add_properties_dialog(RasterLayer, Classifier)

I'm not sure how I am supposed to implement this since
classifier.py doesn't import mainwindow and I don't know if it
would be a good idea to do so.

However, in order to call layer_properties_dialogs.add() the variable
needs to be made public somehow.

What is the preferred method of doing so?

> > as well as for Thuban.UI.mainwindow:
> >
> >     def OpenLayerProperties(self, layer, group = None):
> >         dialog_class = get_properties_dialog_class(layer)
> >
> >         if dialog_class is not None:
> >             name = "layer_properties" + str(id(layer))
> >             self.OpenOrRaiseDialog(name, dialog_class, layer, group = group)
> >
> > Right?
> 
> Yes, after adapting to my suggestion above.

Great.

Regards,

	Joey

-- 
Everybody talks about it, but nobody does anything about it!  -- Mark Twain




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)