Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I want to get a PDF file, but I get an error:
AttributeError: 'NoneType' object has no attribute 'show'
. The error says that
can
doesn't have the attribute
show
. Why? As you can see, I import
show
from
pychart.canvas
.
from pychart import *
from pychart.canvas import show
can = canvas.init("pic.pdf")
x, y = (100, 500)
def show_text(str):
global x, y
can.show(x, y, str)
can.show(x + 200, y, "/12/C" + font.quotemeta(str))
y -= 20
show_text("/12/hLLeft align")
show_text("/12/hRRight align")
show_text("/12/hCCenter align")
show_text("/a20/12/hRAngled text")
def show_textv(str):
global x, y
can.show(x, y, str)
x += 150
y -= 40
x = 100
show_textv("/12/vT//12//vTTop align")
show_textv("/12/vM//12//vT/12Middle align")
show_textv("/12/vB//12//vT/12Bottom align")
y -= 40
x = 100
show_text("/16/HHelvetica")
show_text("/12/CCourier")
show_text("/12/NHelvetica-Narrow")
show_text("/12/PPalatino-Roman")
show_text("/12/AAvantgarde")
show_text("/12/T/iTimes-Italic")
show_text("/12/F{ZapfDingbats}ZapfDingbats")
–
–
you actually call None.show(x, y, str) and get AttributeError, because None doesn't have 'show' attribute
To fix your problem try to investigate why can == None
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.