Jump to content

Item not recognizing in vscode python

AmateurBuildr

Whenever i try pasting a .png file in vs code i get this error: Error loading webview: "Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state.."

 

I do not know what its trying to say. If its maybe a problem with my code heres my code:

import pgzrun
from random import randint

WIDTH,HEIGHT = 600,500

bee=Actor(bee)
def draw():
    bee.draw()

 

Link to comment
Share on other sites

Link to post
Share on other sites

Maybe I'm misunderstand what you're asking, but why exactly are you trying to copy & paste an image into a text editor?

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Eigenvektor said:

Maybe I'm misunderstand what you're asking, but why exactly are you trying to copy & paste an image into a text editor?

I am trying to make a game.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, AmateurBuildr said:

I am trying to make a game.

Then you need to write (Python) code that is able to open and display an image. That is not achieved by pasting an image into an editor.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

I think it might benefit you if you took a step back and learnt some of the basics of how the computer works from metal to the OS and above. Skipping that, even just how the tools you are using work. The text you're writing needs to abide by the rules of the interpreter, in this case Python. It'll take your text and covert it into instructions that your CPU understands. A PNG file is not valid python. So what are your options? You could convert the PNG into a format that can be represented in valid python or an algorithm to generate such data - but that's probably not the best option since it already exists on your disk. Then how do you access it there? You write the instructions to read the file from the disk. You can simply read it in as a bunch of bits. That's not too useful for what you're doing and you probably don't want to write your own PNG parser, so you can use a library that can do it for you. There's tons of options for that, however the only one i know of that'll be useful for you would be pygame

 

It might seem more fun to skip the boring fundamentals, but it'll help you in the long run. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×