[Qgis-developer] accessing project properties

bernhard.stroebl at jena.de bernhard.stroebl at jena.de
Thu Oct 6 10:51:24 EDT 2011


Hi Martin,

thank you for your answer. This is exactly what I was looking for!

regards

Bernhard

Am 05.10.2011 20:15, schrieb Martin Dobias:
> On Tue, Oct 4, 2011 at 11:43 AM,<bernhard.stroebl at jena.de>  wrote:
>> Hi all,
>>
>> I got stuck... From within a Python plugin I want to know the current
>> project's selection color. I guess I need the corresponding QgsPropertyKeys'
>> values.
>> Any hints?
>
> Hi Bernhard
>
> you want want to use something like this:
>
> prj = QgsProject.instance()
> r = prj.readNumEntry("Gui", "/SelectionColorRedPart", 255)[0]
> g = prj.readNumEntry("Gui", "/SelectionColorGreenPart", 255)[0]
> b = prj.readNumEntry("Gui", "/SelectionColorBluePart", 0)[0]
> a = prj.readNumEntry("Gui", "/SelectionColorAlphaPart", 255)[0]
> clr = QColor(r,g,b,a)
>
> The QgsProject class offers a similar interface to QSettings for
> access to properties. The example is mostly self-explanatory except
> for the "[0]" at the end of the readNumEntry lines. This function in
> python returns a tuple: first value is the number, second value is a
> boolean whether the conversion to number went fine - for simplicity we
> ignore that flag here.
>
> Martin
>
>
> ________ Information from NOD32 ________
> This message was checked by NOD32 Antivirus System for Linux Mail Server.
> http://www.nod32.com

-- 
Bernhard Ströbl
Anwendungsbetreuer GIS

Kommunale Immobilien Jena
Am Anger 26
07743 Jena

Tel.: 03641 49- 5190
E-Mail: bernhard.stroebl at jena.de
Internet: www.kij.de



Kommunale Immobilien Jena
Eigenbetrieb der Stadt Jena
Werkleiter: Thomas Dirkes


________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
http://www.nod32.com


More information about the Qgis-developer mailing list