[pygtk] Re: Retrieveing a GConf pair

Arnau Sanchez arnau at ehas.org
Tue Aug 22 03:28:01 WST 2006


Hi,

I've never used gconf, but after playing a bit I got that:

import gconf
client = gconf.client_get_default()
key = "/system/proxy/socks_port"
val = client.get(key)
print "key:", key
# the value type is an emum, not python types
print "type:", val.type
strvalue = val.to_string()
print "string:", type(strvalue), strvalue
x = gconf.Value
totype = {gconf.VALUE_INT: x.get_int, gconf.VALUE_BOOL: x.get_bool} # complete!
value = totype[val.type](val)
print "value:", type(value), value

Peter, is that what you needed?

regards
arnau

Peter Moberg escribió:
> Was it a silly question, or didn't anyone have the answer? :)
> 
> Best Regards
> Peter Moberg
> 
> On 8/16/06, *Peter Moberg* < moberg.peter at gmail.com 
> <mailto:moberg.peter at gmail.com>> wrote:
> 
>     Hi,
> 
>     I'm trying to retrieve a pair value from gconf using
>     GConfClient.get_pair(key,car_type,cdr_type). The problem is I don't
>     know the types of the pair I'm about to retrieve (car_type and
>     cdr_type).
> 
>     Is it possible to retrieve the pair without knowing the types of the
>     values in the pair?
> 
>     It would be great if there was a function:
>     get_pair(key)
> 
>     which returned a tuple containing both the values and their
>     corresponding GConfValueType:
>     ((val1, GConfValueType), (val2, GConfValueType))


More information about the pygtk mailing list