jdf / Processing.py-Bugs

A home for all bugs and feature requests about Python Mode for the Processing Development Environment.
41 stars 8 forks source link

I can't import tabs #264

Open NotRandy opened 5 years ago

NotRandy commented 5 years ago

I'm trying to import a tab with a class in it and it cant find the class global name 'class_name' is not defined

villares commented 5 years ago

Hi @NotRandy,

Show us a minimal code example... Tab class import is working perfectly here. Check this: tab file/name: module_name.py class: Animal

from module_name import Animal

cdonnay commented 5 years ago

Hi @villares , I am having the same issue. I am trying to make a simple polygon function in a new tab, but the main tab states that "NameError: global name 'polygon' is not defined." It works fine when the function is in the same tab as setup.

Screen Shot 2019-05-16 at 1 18 33 PM Screen Shot 2019-05-16 at 1 18 38 PM

def setup(): size(480, 480) background(255) polygon(3, 50)

def polygon(n, radius): theta = 0 x = 0 y = 0

beginShape()
for i in range(n):
    x = cos(theta) * radius
    y = sin(theta) * radius
    vertex(x, y)
    theta += TWO_PI/n
endShape(CLOSE)   
villares commented 5 years ago

Hi @cdonnay!

Your tab is treated as a "Python module" and so its filename must be polygon.py then on the main `.pyde' tab you must write:

form polygon import polygon 

def setup():
    size(480, 480)
    background(255)
    polygon(3, 50)
cdonnay commented 5 years ago

Thank you so much! That worked perfectly.

On Thu, May 16, 2019 at 1:38 PM Alexandre B A Villares < notifications@github.com> wrote:

Hi @cdonnay https://github.com/cdonnay!

Your tab is treated as a "Python module" and so its filename must be polygon.py then on the main `.pyde' tab you must write:

form polygon import polygon

def setup(): size(480, 480) background(255) polygon(3, 50)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jdf/Processing.py-Bugs/issues/264?email_source=notifications&email_token=AFTCCMSRA2ZKVEERULRX5G3PVWL2LA5CNFSM4G65LFM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVSRH6I#issuecomment-493163513, or mute the thread https://github.com/notifications/unsubscribe-auth/AFTCCMSN2I4H6EBUK2OQJFTPVWL2LANCNFSM4G65LFMQ .

-- Chris Donnay Math & Computer Science | The Shipley School Teaching Fellow | University of Pennsylvania GSE

acejacek commented 4 years ago

or simply:

form polygon import *