Reputation: 459
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")
Upvotes: 1
Views: 3582
Reputation: 1778
NoneType is type of None object. When can == None and you call following:
can.show(x, y, str)
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
Upvotes: 0