I've committed a fix so this at least works. (We can change how the
trait is specified later if necessary.) The validation is not as tight
as it should be, yet.
I think I've passed through this bug onto another one, though:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/config/mplconfig.py",
line 469, in update
self[key] = arg[key]
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/config/mplconfig.py",
line 454, in __setitem__
See rcParams.keys() for a list of valid parameters.'%key)
KeyError: 'text.fontangle is not a valid rc parameter.See
rcParams.keys() for a list of valid parameters.'
It seems that unlike the regular string choice traits, the custom Trait
handlers *are* called with the default value when initialized. Is that
something to be relied on? (Other parts of mplconfig, such as the
colors, depend on this).
Cheers,
Mike
Michael Droettboom wrote:
> This was an attempt to do a direct translation from what I had in the
> "classic" rcsetup.py. (The previous version in mplconfig.py was
> semantically incorrect.) I had tested this with settings in my
> matplotlib.conf, but didn't realise that the default wasn't validated
> (and thus not interpreted into a FontPropertiesProxy object).
>
> Darren Dale wrote:
>> I am trying to work out some way to make rcdefaults() work with the traited
>> config. Along the way, I discovered this in mplconfig:
>>
>> class mathtext(TConfig):
>> cal = T.Trait("['cursive']", mplT.FontPropertiesHandler())
>> rm = T.Trait("['serif']", mplT.FontPropertiesHandler())
>> tt = T.Trait("['monospace']", mplT.FontPropertiesHandler())
>> it = T.Trait("['serif'], style='oblique'",
>> mplT.FontPropertiesHandler())
>> bf = T.Trait("['serif'], weight='bold'",
>> mplT.FontPropertiesHandler())
>> sf = T.Trait("['sans-serif']", mplT.FontPropertiesHandler())
>> use_cm = T.true
>> fallback_to_cm = T.true
>>
>> I dont think that will work. One of the highlights of the new config files
>> is
>> that when a file says:
>>
>> [mathtext]
>> rm = ['serif', 'sans-serif']
>>
>> you actually get a list, not a string, to pass to
>> mplT.FontPropertiesHandler().
>
> Right. But it works like:
>
> rm = "['serif', 'sans-serif']"
>
> I realize it's hacky. The most obvious alternative is to expect a
> dictionary here, e.g.:
>
> rm = { 'family': ['serif'], 'style': 'oblique' }
>
> But that's less like the FontProperties constructor. My goal was to
> make specifying fonts as similar as possible to the FontProperties
> object so the user doesn't have to learn a new syntax. Is there a
> better way to do this with Traits? Can the user specify the arguments
> (with keyword arguments) to a constructor?
>
> Cheers,
> Mike
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Matplotlib-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel