Dear Arnd, it was intended to allow layer instance here, only. You can always use the layer method itself to get the instance. Hence
layer2 = c.layer("level2", below=c.layer("level1"))
would work, too. The below and above arguments are considered rare use cases.
I've updated the docstring to be more clear here, that strings are not
supported for those arguments, but layer instances need to be passed directly.
Best,
André
Am 31.12.2012 um 16:55 schrieb Arnd Baecker:
> Hi Joerg,
>
> On Mon, 10 Dec 2012, Joerg Lehmann wrote:
>
>> Hi Arnd,
>>
>> Indeed in PyX 0.12.1, the graph code uses the newly introduced canvas
>> layer system to specify the drawing order of various parts of the graph.
>> This fixes an old bug (graph grids had been drawn above the axis ticks).
>> Unfortunately, this also breaks old scripts - that's why PyX is still,
>> even after so many years, in an alpha state - and documentation is still
>> lacking a bit...
>
> Well, as it works so nicely for so many bachelor/diploma/PhD theses
> and papers, one tends to forget this ... ;-).
>
>> In any case, in order to draw the bitmap below lines and/or symbols of,
>> e.g., a function plot use:
>>
>> g.layer("filldata").insert(...)
>
> I tried to understand the new layers a bit and got to the following point:
>
> # <--- snip here
> from pyx import *
>
> c = canvas.canvas()
> layer1 = c.layer("level1")
> layer1.text(0, 0, "Hello, layer1")
> layer2 = c.layer("level2", below="level1")
> #layer2 = c.layer("level2", below=layer1) # <--- this works
> layer2.stroke(path.line(0, 0, 2, 0.5), [style.linewidth.THICK,
> color.rgb.red])
> c.writeEPSfile()
> # <--- and here
>
>
> Gives:
> Traceback (most recent call last):
> File "hello_layer1.py", line 6, in <module>
> layer2 = c.layer("level2", below="level1")
> File ".../pyx/canvas.py", line 230, in layer
> self.layers[name] = self.insert(canvas(texrunner=self.texrunner),
> after=above, before=below)
> File ".../pyx/canvas.py", line 259, in insert
> self.items.insert(self.items.index(before), item)
> ValueError: 'level1' is not in list
>
> So it seems that a string is not the right way of specifying a layer:
>
> Looking at the code, it cannot work this way, as the `below`
> string given to `canvas.layer(...)` is passed as `before`
> argument to `canvas.insert(...)` which is then
> used to via `self.items.index(before)` to obtain
> the right index in the list `self.items` containing the
> different canvas(=layer) instances.
>
> So the solution is to provide the layer instance as argument
> to `below`. Is this the intended way?
> If yes, I am not sure, whether I read the doc-string to `canvas.layer`
> correctly, as I interpreted it such that strings would
> also be correct for `above` and `below` and not just the `name`.
>
> Best, Arnd
>
>
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122412
> _______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
--
by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
/ \ \ / ) [email protected], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712
_______________________________________________ PyX-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyx-user
