JuliaPy / JuliaPy/PyCall.jl

python-pptx trouble

Offen
#725 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Julia
Sterne
1.5k
Forks
186
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Installed python-pptx like this
```
using Conda, PyCall
run(PyCall.python_cmd(`-m pip install python-pptx`))
```

In this example, the second last line fails, since `ERROR: KeyError: key "rgb" not found`.
```julia
using PyCall
pptx = pyimport("pptx")
RGBColor = pptx.dml.color.RGBColor
Inches = pptx.util.Inches
prs = pptx.Presentation()
title_slide_layout = get(prs.slide_layouts, 1)
slide = prs.slides.add_slide(title_slide_layout)
shape = slide.shapes.add_table(4, 3, Inches(1), Inches(1), Inches(3), Inches(2))
shape.table.cell(1,1).fill.solid()
isnothing(shape.table.cell(1,1).fill.fore_color.type) # true
shape.table.cell(1,1).fill.fore_color.rgb = RGBColor(255, 0, 0) # ERROR: KeyError: key "rgb" not found
prs.save("debug_rgb_jl.pptx")
```
For some reason `shape.table.cell(1,1).fill.fore_color.type` is `nothing`. whereas in the Python version it is `1`. Here is Python version of the above
```python
import pptx
from pptx.dml.color import RGBColor
from pptx.util import Inches
prs = pptx.Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
shape = slide.shapes.add_table(4, 3, Inches(1), Inches(1), Inches(3), Inches(2))
shape.table.cell(1,1).fill.solid()
shape.table.cell(1,1).fill.fore_color.type == 1 # True
shape.table.cell(1,1).fill.fore_color.rgb = RGBColor(255, 0, 0)
prs.save("debug_rgb_py.pptx")
```

Also, in Julia, typing `shape.` results in `Error: Error in the keymap...`.

Julia v1.2, Conda v1.3.0, PyCall v1.91.2.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.