Is it possible to run pygame using python-shell?
I am working on a project to create a working python terminal in the browser and love this node python solution.
Is there anyway to import and run pygame using python-shell? I'm not sure how the window would appear on the front end.
Here is the code I currently have:
const shell = new PythonShell('script.py', { mode: 'text', pythonOptions: ['-u'] }); shell.on('message', line => { console.log('line: ', line); }) .on('error', err => { console.log(err); }) .on('close', () => { console.log('Finished'); }); setTimeout(() => { shell.send(4); }, 1000);
script.py:
import pygame pygame.init() screen = pygame.display.set_mode((500, 500)) done = False x=60 y=60 while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True pygame.draw.rect(screen, (0,128,255), pygame.Rect(x, y, 90, 90)) pygame.display.flip()
Would be curious to know more about this too!
I don't see a reason why it should not work. I have tried using several other modules earlier and they worked smoothly. You should have the pyGame module installed using pip into your desktop.
You can also refer to a similar issue in case you run into any problems. [https://github.com//issues/187]
hey,can anyone help with Pygame,its shows an error when writing the pygame.init()