Perhaps what may be more clear is having an add_window function in
pyglet.app.
It's there, but it is not currently that callable. But I think the
problem here is that the whole layout of pyglet is based off the idea
that the module is running the show rather than an instance of a class.
It is workable, but a little strange feeling.
What I would like is access to the default clock (or the clock I should
use) as like an event_queue, the ability to add events and run all from
one place.
My first thought is something like:
import pyglet
app = pyglet.app
app.set_main_window(caption="Main window")
app.add_window(pyglet.window.Window(caption="window2"))
@app.event
def on_key_press(key, mods):
pass
@app.window_list[1].event
def on_key_press(key, mods):
pass
app.run()
But honestly, I like classes.
thanks,
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
On 3/10/2015 5:51 PM, Rob wrote:
Making app instantiation like that does seem to make sense. However
you do need to allow multiple windows, so the window
property/attribute might be a little different. Also the handling of
different events can be window specific.
The current app class with the built-in event loop seems to be rather
new. It does not seem to be fully implemented even. I noticed that
using the app class or calling dispatch_events directly on a window
causes different behaviour.
Maybe it is an idea to make the app class the event dispatcher/router
and then make the other classes (now implementing EventDispatcher)
just event sources and observers? For backwards compatibility the
dispatch_events method can forward calls to the app class in case the
event loop is not running. It could even be changed that if the event
loop is not started (eg when just using pyglet.media) events are
directly forwarded to the observers. That would also solve a few
problems for people who just want to use the media playback.
Sorry, my thoughts about it are still a bit murky. I see something
needs to be changed, just do not know the right way yet.
Rob
Op dinsdag 10 maart 2015 16:05:41 UTC+1 schreef Brandon Keith Biggs:
Hello,
Wouldn't both of these problems be fixed if there was a proper App
class?
Tell people to have this at the top of their script:
import pyglet
my_app = pyglet.App(caption="My test app")
#code
my_app.run()
Inside the App class you have window, clock and everything is
sub-classed or has an instance of event_loop so you can just do:
def on_key_press(key, mods):
pass
my_app.set_handlers(on_key_press)
This is just a new-comer's idea of what would be practical and
make a whole lot more sense than what is going on currently.
Would it be against any principals to add an App class with this
functionality?
Thanks,
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
On 3/10/2015 10:23 AM, Richard Jones wrote:
I believe Brandon meant to say "explicit", since his example is
certainly more explicit than the current pyglet behaviour.
For the record, I argued against the implicit behavior. It's
related to the automatic shadow window which has caused a bunch
of issues over time. On the other hand, we don't (generally, when
the shadow window works) get errors from people loading images
before there's a valid GL context. So it's a tough call to make.
And in the end Alex had the final say, and I think he was right
to err on the side of programmer-friendliness, so that's why we
have it now.
On Tue, 10 Mar 2015 at 19:09 Adam Bark <[email protected]
<javascript:>> wrote:
That would seem to be unpythonic as it contradicts the zen of
python "explicit is better than implicit"
On 10 Mar 2015 08:05, "Brandon Keith Biggs"
<[email protected] <javascript:>> wrote:
Hello,
I am wondering if there is a way to make the window and
app more implicit in pyglet? Something like:
import pyglet
my_app = pyglet.app() #is the window, just under the name
of app
my_app.run()
or:
import pyglet
window = pyglet.window.Window()
pyglet.app.window = window
pyglet.app.run()
As it is right now, it is not pythonic at all and I am
wondering if there was a good reason for this? Also, is
there a way to make it more implicit?
If not, I can create a wrapper class over it to make it
more pythonic, but I would rather not...
thanks,
--
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
--
You received this message because you are subscribed to
the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to
[email protected] <javascript:>.
To post to this group, send email to
[email protected] <javascript:>.
Visit this group at
http://groups.google.com/group/pyglet-users
<http://groups.google.com/group/pyglet-users>.
For more options, visit
https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the
Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to [email protected]
<javascript:>.
To post to this group, send email to
[email protected] <javascript:>.
Visit this group at
http://groups.google.com/group/pyglet-users
<http://groups.google.com/group/pyglet-users>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the
Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected] <javascript:>.
To post to this group, send email to [email protected]
<javascript:>.
Visit this group at http://groups.google.com/group/pyglet-users
<http://groups.google.com/group/pyglet-users>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google
Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.