[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] ev.__dict__ does not include ev.type?
- To: pygame-users@xxxxxxxx
- Subject: [pygame] ev.__dict__ does not include ev.type?
- From: Martin Kühne <mysatyre@xxxxxxxxx>
- Date: Thu, 18 Aug 2016 14:18:13 +0200
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Thu, 18 Aug 2016 08:18:37 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=64hZpgQVJdU/qQvaay21opqEU1yX55squrAocqLF3Dg=; b=P4pvBZtPUGCXxQVT/zv/x+aWinPs8lx/StvP+024QEv9cuslRE12XCZO9GOnlkv/oM dNVfKv/q5UyDYyOly+EWqfDTAETkmpC5g/UYDzqzNvDKDa17IHRYtcTNJANCLQBmzUdw dtkjFUu2Gf0httYyClQH/G+ShVo5jOpvTEtfqXNNrINftlwcctekqSMReKxS8iDJXCM2 AFfrr7jijYaBWX1cHEul2gLCBiBzx7pSOgVv1j3EER9D+sula4n8LKzT2/U3CyuHHZw4 YTx19eW4DdXXKQlU6rDnq4pXse/bilmocxa7cAUy6gNQHQNuG01/WH+I3zRkWSkfdjQE ofSw==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hello list,
I have another minor gripe to report. Building my general input
decorator pattern [0] was fun, but as I started using it, I noticed
that ev.__dict__ doesn't add the type of the event to the dictionary.
Incidentally, though, that is the most significant designator for
event filters. So I just build a complete dictionary using that 3.5
syntax again [1], which is awkward. Attached is a patch which would
just represent all of the event's data in the resulting dict.
cheers!
mar77i
[0] https://github.com/mar77i/pygametower/blob/master/util.py#L25
[1] https://github.com/mar77i/pygametower/blob/master/tower.py#L77
From ff1960affaea9ebfe6303e5f7ffc7b6b0241f6f9 Mon Sep 17 00:00:00 2001
From: mar77i <mar77i@xxxxxxxxx>
Date: Thu, 18 Aug 2016 14:08:24 +0200
Subject: [PATCH] add event type to pygame.Event.{dict,__dict__} objects
---
src/event.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/event.c b/src/event.c
index eb3d8e7..0854312 100644
--- a/src/event.c
+++ b/src/event.c
@@ -259,6 +259,7 @@ dict_from_event (SDL_Event* event)
if (!(dict = PyDict_New ()))
return NULL;
+ insobj (dict, "type", PyInt_FromLong (event->type));
switch (event->type)
{
case SDL_ACTIVEEVENT:
--
2.9.3