[TUTORIAL]Running Python Mode in VScode

You mean, like, the IntelliSense code-completion? I don’t think this is possible, because there’s no Python file that you’ve imported that contains all of the Processing.py definitions for VScode to use.

But you might work around this somehow. One (very hacky and gross) solution is to create a file named codecompletion.py with the following code:

EXPAND for codecompletion.py code
# functions

def abs(*arg): return 1
def acos(*arg): return 1
def add_library(*arg): return 1
def alpha(*arg): return 1
def applyMatrix(*arg): return 1
def arc(*arg): return 1
def asin(*arg): return 1
def atan(*arg): return 1
def atan2(*arg): return 1
def background(*arg): return 1
def beginContour(*arg): return 1
def beginShape(*arg): return 1
def bezier(*arg): return 1
def bezierDetail(*arg): return 1
def bezierPoint(*arg): return 1
def bezierTangent(*arg): return 1
def bezierVertex(*arg): return 1
def blend(*arg): return 1
def blendColor(*arg): return 1
def blendMode(*arg): return 1
def blue(*arg): return 1
def brightness(*arg): return 1
def ceil(*arg): return 1
def circle(*arg): return 1
def clear(*arg): return 1
def color(*arg): return 1
def colorMode(*arg): return 1
def constrain(*arg): return 1
def copy(*arg): return 1
def cos(*arg): return 1
def createFont(*arg): return 1
def createShape(*arg): return 1
def cursor(*arg): return 1
def curve(*arg): return 1
def curveDetail(*arg): return 1
def curvePoint(*arg): return 1
def curveTangent(*arg): return 1
def curveTightness(*arg): return 1
def curveVertex(*arg): return 1
def day(*arg): return 1
def degrees(*arg): return 1
def dist(*arg): return 1
def ellipse(*arg): return 1
def ellipseMode(*arg): return 1
def endContour(*arg): return 1
def endShape(*arg): return 1
def exp(*arg): return 1
def fill(*arg): return 1
def filter(*arg): return 1
def floor(*arg): return 1
def frameRate(*arg): return 1
def fullScreen(*arg): return 1
def get(*arg): return 1
def green(*arg): return 1
def hour(*arg): return 1
def hue(*arg): return 1
def image(*arg): return 1
def imageMode(*arg): return 1
def keyPressed(*arg): return 1
def keyReleased(*arg): return 1
def keyTyped(*arg): return 1
def lerp(*arg): return 1
def lerpColor(*arg): return 1
def line(*arg): return 1
def loadFont(*arg): return 1
def loadImage(*arg): return 1
def loadPixels(*arg): return 1
def loadShape(*arg): return 1
def loadStrings(*arg): return []
def log(*arg): return 1
def mag(*arg): return 1
def map(*arg): return 1
def max(*arg): return 1
def millis(*arg): return 1
def min(*arg): return 1
def minute(*arg): return 1
def month(*arg): return 1
def mouseClicked(*arg): return 1
def mouseDragged(*arg): return 1
def mouseMoved(*arg): return 1
def mousePressed(*arg): return 1
def mouseReleased(*arg): return 1
def mouseWheel(*arg): return 1
def noCursor(*arg): return 1
def noFill(*arg): return 1
def noise(*arg): return 1
def noiseDetail(*arg): return 1
def noiseSeed(*arg): return 1
def norm(*arg): return 1
def noSmooth(*arg): return 1
def noStroke(*arg): return 1
def noTint(*arg): return 1
def point(*arg): return 1
def popMatrix(*arg): return 1
def pow(*arg): return 1
def printMatrix(*arg): return 1
def pushMatrix(*arg): return 1
def quad(*arg): return 1
def quadraticVertex(*arg): return 1
def radians(*arg): return 1
def random(*arg): return 1
def randomGaussian(*arg): return 1
def randomSeed(*arg): return 1
def rect(*arg): return 1
def rectMode(*arg): return 1
def red(*arg): return 1
def requestImage(*arg): return 1
def resetMatrix(*arg): return 1
def rotate(*arg): return 1
def rotateX(*arg): return 1
def rotateY(*arg): return 1
def rotateZ(*arg): return 1
def round(*arg): return 1
def saturation(*arg): return 1
def save(*arg): return 1
def saveFrame(*arg): return 1
def scale(*arg): return 1
def second(*arg): return 1
def set(*arg): return 1
def shape(*arg): return 1
def shapeMode(*arg): return 1
def shearX(*arg): return 1
def shearY(*arg): return 1
def sin(*arg): return 1
def size(*arg): return 1
def smooth(*arg): return 1
def sq(*arg): return 1
def sqrt(*arg): return 1
def square(*arg): return 1
def stroke(*arg): return 1
def strokeCap(*arg): return 1
def strokeJoin(*arg): return 1
def strokeWeight(*arg): return 1
def tan(*arg): return 1
def text(*arg): return 1
def textAlign(*arg): return 1
def textFont(*arg): return 1
def textLeading(*arg): return 1
def textMode(*arg): return 1
def textSize(*arg): return 1
def texture(*arg): return 1
def textureMode(*arg): return 1
def textWidth(*arg): return 1
def tint(*arg): return 1
def translate(*arg): return 1
def triangle(*arg): return 1
def updatePixels(*arg): return 1
def vertex(*arg): return 1
def year(*arg): return 1

# variables

displayHeight = 1
displayWidth = 1
focused = 1
frameCount = 1
frameRate = 1
HALF_PI = 1
height = 1
key = 1
keyCode = 1
keyPressed = 1
mouseButton = 1
mousePressed = 1
mouseX = 1
mouseY = 1
pixels = 1
PI = 1
pmouseX = 1
pmouseY = 1
QUARTER_PI = 1
TAU = 1
TWO_PI = 1
width = 1

# arguments

ADD = 1
BLEND = 1
BLUR = 1
CENTER = 1
CLOSE = 1
DARKEST = 1
DIFFERENCE = 1
HSB = 1
LEFT = 1
LIGHTEST = 1
MULTIPLY = 1
PIE = 1
PROJECT = 1
RGB = 1
RIGHT = 1
ROUND = 1
SCREEN = 1
SQUARE = 1
SUBTRACT = 1

# classes

class PFont():
    def list(): return 1

class ControlP5():
    pass

class PVector(x, y):
    def __add__(a, b): return a
    def __sub__(a, b): return a
    def limit(self): return self

Save this codecompletion.py file in the same directory as your sketch file; then import it using:

if False: from codecompletion import *

You can refine the codecompletion.py file for better hinting (adding arguments, etc.). You can also add iGeo definitions.

I’m sure there are far better ways to do this …

3 Likes