Coder Social home page Coder Social logo

jupylet's People

Contributors

fatenghriss avatar nir avatar ofer1992 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jupylet's Issues

ipykernel_launcher error in vscode .ipynb cell

When I run the cells of 02-hello-jupylet.ipynb or of the other files from the examples,
in VSCode in .ipynb model,
on Win10 with Python 3.9,
and get error in cell of app = App(width=320, height=64):

usage: ipykernel_launcher [-h] [--window {pyglet,glfw}]
                          [--log_level {DEBUG,INFO,WARNING,ERROR}]
ipykernel_launcher: error: unrecognized arguments: --ip=127.0.0.1 --stdin=9013 --control=9011 --hb=9010 --Session.signature_scheme="hmac-sha256" --Session.key=b"5601a025-9f20-4b88-afbb-44baf429e64a" --shell=9012 --transport="tcp" --iopub=9014 --f=C:\Users\ah21\AppData\Local\Temp\tmp-10760RJVa1Rf2n20M.json
SystemExit: 2
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2
D:\venvs\jupylet\lib\site-packages\IPython\core\interactiveshell.py:3449: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

No error message if jupylet is used in a helper file

For example, suppose you have a file game.py with

from jupylet.label import Label as Label
from jupylet.app import App as App

app = App(width=320, height=64)

sitting next to a notebook in which you have

import game

hello = game.Label('hello, world', color='cyan', font_size=32, x=game.app.width, y=16)

@game.app.run_me_every(1/30)
def scroll(ct, dt):
    hello.x = hello.x - 1

    if hello.right < 0:
        hello.x = app.width
        
@game.app.event
def render(ct, dt):
    game.app.window.clear()
    hello.draw()
    
game.app.run()

This all runs fine. However, if syntax errors are introduced into scroll and render, no error message will appear.

App.run() does not automatically exit / quit

Hi, thanks for this amazing jupylet.
Installed and now trying the examples to understand how to use jupylet.
On Windows 10, using Python 3.6, I can't close all examples started from IDLE.
The same goes for all examples run on jupyter. When I close the jupyter's browser tabs, all jupylet examples are still running.
The only way to close the examples are thru Task Managers.

Is there any flag to set so that App.run() can automatically exit / quit when its window / display is closed ?
Or maybe "exit/quit event" that needs to be handled ?

Thank you

Running as stand-alone script on Windows

When run as a stand-alone script on Windows 10 (Python 3.7.9), example programs just die silently after the first jupylet import (e.g. from jupylet.sprite import Sprite in spaceship.py)

"SystemError: error return without exception set" when creating App

Hi,

I'm trying to run jupylet on Windows, with Python 3.9.1. After installing the libraries following the instructions on the docs, if I try to run any example that creates an App I am getting the error:

app = App()
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-5-91042f890017> in <module>
----> 1 app = App()

~\Source\Repos\jupylet\jupylet\app.py in __init__(self, width, height, mode, resource_dir, quality, **kwargs)
    236 
    237         shader = set_shader_2d(self.load_program('shaders/sprite.glsl'))
--> 238         shader['projection'].write(glm.ortho(
    239             0, width, 0, height, -1, 1
    240         ))

~\Miniconda3\envs\jupylet\lib\site-packages\moderngl\program_members\uniform.py in write(self, data)
    176         '''
    177 
--> 178         self.mglo.data = data

SystemError: error return without exception set

Any idea what could be wrong?

Thank you!

NameError: name 'sys' is not defined in env.py

Hello

I have just tried to integrate jupylet into my script. However I am getting the following error:
packages/jupylet/env.py:68: in has_display if 'pyglet' in sys.modules: E NameError: name 'sys' is not defined
when simply importing jupylet

It has been fixed for me by simply adding import sys in the head of that file locally.

Could you please fix that on the file?

Thanks!

Not working in Jupyter

When I try to test the game in Jupyter (notebook or lab) I can't play the game. When I try to press the up/down keys it responds by moving up or down a cell and when I try left/right it does nothing. It kinda seems like it might be displaying as a just image, I'm not sure.

Is there something I'm missing? Did I miss a step somewhere?

Method descriptions missing from Sounds Modules

I'm starting to get interested in exploring audio in Python and was excited to discover the capabilities of your Jupylet project.

But I've just realized that although the documentation is extensive, many of the classes in the Sound and related modules only have the attributes defined, not the methods. Is this an oversight, or because they are waiting updating for the latest code changes or just because you have not got around to documenting them yet?

I note that the code itself is quite well documented, so perhaps there is an issue with documentation not getting automatically generated from the docstrings correctly?

I know that I can find out basic information about the classes using the Python "help" function but this does give any explanation of the methods, just the bare bones of class definitions.

Anyway, you're the expert and I'm only guessing but if you would like help in this area, then I've got the time (if only limited expertise) so I could have a go at helping with documentation.

how to run an App() in a separate thread?

Hi,

I'd like to run an (headless) App in a separate thread.

I'd like to render some shaders, and use the framebuffer into another part of my application.

I tried this simple code:

#!/usr/bin/python3

import time
from jupylet.app import App

if __name__ == '__main__':

    def create_and_run_app():
        app = App(width=512, height=512, quality=100, fullscreen=False, mode="hidden")  #, log_level=logging.INFO)
        app.start()

    import _thread
    _thread.start_new_thread(create_and_run_app, ())

    time.sleep(10)

but I get this error:

Exception ignored in thread started by: <function create_and_run_app at 0x7f807b0060d0>
Traceback (most recent call last):
  File "p.py", line 9, in create_and_run_app
    app = App(width=512, height=512, quality=100, fullscreen=False, mode="hidden")  #, log_level=logging.INFO)
  File "/home/eric/tmp/jupylet/jupylet/app.py", line 184, in __init__
    self.window = window_cls(size=(width, height), **conf)
  File "/home/eric/tmp/jupylet/jupylet/event.py", line 81, in __init__
    self.init_mgl_context()
  File "/home/eric/tmp/jupylet/jupylet/event.py", line 103, in init_mgl_context
    self._ctx = moderngl.create_standalone_context(
  File "/home/eric/.local/lib/python3.9/site-packages/moderngl/context.py", line 1672, in create_standalone_context
    raise ValueError('Requested OpenGL version {}, got version {}'.format(
ValueError: Requested OpenGL version 330, got version 0

I also tried to use mode="auto" and app.run(), but I get:

Exception ignored in thread started by: <function create_and_run_app at 0x7f34e3fc30d0>
Traceback (most recent call last):
  File "p.py", line 10, in create_and_run_app
    app.run()
  File "/home/eric/tmp/jupylet/jupylet/app.py", line 333, in run
    loop = asyncio.get_event_loop()
  File "/usr/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Dummy-1'.

Is there a way to call a render iteration x times per second, or in a separate thread?

Thank you

support python 3.9

Hi,

When trying to install jupylet on archlinux, with python 3.9.2, I get:

$ pip install jupylet --user --verbose

I get:

$ pip install jupylet --user --verbose
Using pip 20.2.3 from /home/eric/.local/lib/python3.9/site-packages/pip (python 3.9)
User install by explicit request
Created temporary directory: /tmp/pip-ephem-wheel-cache-3wvo_4kp
Created temporary directory: /tmp/pip-req-tracker-_m4zqxh6
Initialized build tracking at /tmp/pip-req-tracker-_m4zqxh6
Created build tracker: /tmp/pip-req-tracker-_m4zqxh6
Entered build tracker: /tmp/pip-req-tracker-_m4zqxh6
Created temporary directory: /tmp/pip-install-ui97ta1b
1 location(s) to search for versions of jupylet:
* https://pypi.org/simple/jupylet/
Fetching project page and analyzing links: https://pypi.org/simple/jupylet/
Getting page https://pypi.org/simple/jupylet/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/jupylet/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/jupylet/ HTTP/1.1" 304 0
  Link requires a different Python (3.9.2 not in: '>=3.6, <3.9'): https://files.pythonhosted.org/packages/04/43/73317ed5ac537cc113f15ba8961a82b0becf58dd38d208b8aa53f6c6cd71/jupylet-0.8.2.tar.gz#sha256=65b29691461836ff56800596f74f4bf10620c7734982babe7e44c145bebef712 (from https://pypi.org/simple/jupylet/) (requires-python:>=3.6, <3.9)
  Link requires a different Python (3.9.2 not in: '>=3.6, <3.9'): https://files.pythonhosted.org/packages/d5/4a/759e69ce9edb0faf295efd9852354c810ba2d126f9d01d666694ab56a91e/jupylet-0.8.3.tar.gz#sha256=d8587839e785976ede70b54c2281044d3c6ab3ef99655c46d25259807cad4205 (from https://pypi.org/simple/jupylet/) (requires-python:>=3.6, <3.9)
  Link requires a different Python (3.9.2 not in: '>=3.6, <3.9'): https://files.pythonhosted.org/packages/39/ce/b57320a8f4338dddc64a17065b9c61c8a8513a309043bda3d8731152bc66/jupylet-0.8.4.tar.gz#sha256=796637f1bca3e1d63d2838a69f4cd4bd7f4e449f210feb2e7360c4ce20bcc85c (from https://pypi.org/simple/jupylet/) (requires-python:>=3.6, <3.9)
  Link requires a different Python (3.9.2 not in: '>=3.6, <3.9'): https://files.pythonhosted.org/packages/a0/71/b99740ec81e8e5450e3a2c40ee439a765c86f1f63eedc9e76d0c54f66fa7/jupylet-0.8.5.tar.gz#sha256=3a02ce9816cd7dd9067c7712befe0f8b4416819dc52771f9718230d1f8641d2a (from https://pypi.org/simple/jupylet/) (requires-python:>=3.6, <3.9)
  Link requires a different Python (3.9.2 not in: '>=3.6, <3.9'): https://files.pythonhosted.org/packages/c7/40/97e4e17afb76dda53df66f8b7d96794e3eb8b628195bc224b9df1985e6ac/jupylet-0.8.6.tar.gz#sha256=5b803c8dcbd7b69998cc24380c44d1764de2071df728206f9c6bc18a62a7cca6 (from https://pypi.org/simple/jupylet/) (requires-python:>=3.6, <3.9)
  Link requires a different Python (3.9.2 not in: '>=3.6, <3.9'): https://files.pythonhosted.org/packages/56/66/14403cfa25c6cc6d44d16d1b4b1e644a22315e4b9de5bce4cab8f3e7fcdb/jupylet-0.8.7.tar.gz#sha256=9b3323acd71db6e5df3e684ed66f2fb1d8c267331b2fc2b4dddcae973c0c86a9 (from https://pypi.org/simple/jupylet/) (requires-python:>=3.6, <3.9)
Given no hashes to check 0 links for project 'jupylet': discarding no candidates
ERROR: Could not find a version that satisfies the requirement jupylet (from versions: none)
ERROR: No matching distribution found for jupylet
Exception information:
Traceback (most recent call last):
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
    status = self.run(options, args)
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 323, in run
    requirement_set = resolver.resolve(
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 339, in _get_abstract_dist_for
    self._populate_link(req)
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 305, in _populate_link
    req.link = self._find_requirement_link(req)
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 270, in _find_requirement_link
    best_candidate = self.finder.find_requirement(req, upgrade)
  File "/home/eric/.local/lib/python3.9/site-packages/pip/_internal/index/package_finder.py", line 926, in find_requirement
    raise DistributionNotFound(
pip._internal.exceptions.DistributionNotFound: No matching distribution found for jupylet
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
Removed build tracker: '/tmp/pip-req-tracker-_m4zqxh6'

Is there anything I can do about it?

Thank you

instantiating App() ovverrides argparse.parse_args()

For example, take this code:

#!/usr/bin/python3

import argparse
from jupylet.app import App
# app = App(width=512, height=512)

parser = argparse.ArgumentParser(description='bla')
args = parser.parse_args()

if I run:

$ ./p.py  --help

I get:

usage: p.py [-h]

bla

optional arguments:
  -h, --help  show this help message and exit

as expected.

But if I uncomment the line that instantiates app, I get:

$ ./p.py  --help

usage: p.py [-h] [--window {pyglet,glfw}] [--log_level {DEBUG,INFO,WARNING,ERROR}]

optional arguments:
  -h, --help            show this help message and exit
  --window {pyglet,glfw}
                        Windowing library to use.
  --log_level {DEBUG,INFO,WARNING,ERROR}
                        logging level.

So it makes it hard to import App outside of jupylet

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.