This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年07月18日 12:52 by gpolo, last changed 2022年04月11日 14:56 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| event_generate__data2.diff | gpolo, 2008年07月19日 15:33 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 7142 | open | mkiever, 2018年05月27日 17:09 | |
| Messages (8) | |||
|---|---|---|---|
| msg69951 - (view) | Author: Guilherme Polo (gpolo) * (Python committer) | Date: 2008年07月18日 12:52 | |
Follows a patch that adds support for the new data option supported
event generate. It allows virtual events to pass a tcl object.
This patch is only intended to correctly support tcl objects, trying to
pass other objects (like a dict) will result in None being returned. If
you want to correctly pass and receive a dict, make it an attribute of
the tcl object being passed.
E.g.:
import Tkinter
def handle_it(event):
print event.data.something
root = Tkinter.Tk()
root.something = {1: 2}
root.after(1, lambda: root.event_generate('<<Test>>', data=root))
root.bind('<<Test>>', handle_it)
root.mainloop()
|
|||
| msg70040 - (view) | Author: Guilherme Polo (gpolo) * (Python committer) | Date: 2008年07月19日 15:33 | |
Actually, it could be the "detail" field too according to http://www.tcl.tk/man/tcl8.5/TkCmd/bind.htm#M24 And this field may not exist, so I'm checking for that now. New patch added. |
|||
| msg127658 - (view) | Author: O.C. (dghjfrdj) | Date: 2011年01月31日 20:44 | |
Hello, I read the proposed patch "event_generate__data2.diff" and the Tcl/Tk manual http://www.tcl.tk/man/tcl8.5/TkCmd/bind.htm#M24 * Could you please also add a field "e.user_data" ? This would simply be a copy of 'd' : --- e.detail = d e.user_data = d --- My reasoning is that the Tcl/Tk manual mentions the two names "detail" and "user_data". However, "user_data" may often be preferred because it has a clear meaning, whereas "detail" is quite vague. * I did not understand why you try to get a widget reference from the "%d" field. Is it supposed to contain a widget name at some point ? According to the manual (and if I understood it well), it should never. Best regards, O.C. |
|||
| msg165234 - (view) | Author: Mark Summerfield (mark) * | Date: 2012年07月11日 08:29 | |
According to the Tcl/Tk docs the 'data' field is a string (i.e., for any user data) and the 'detail' field contains some internal data (so shouldn't be messed with); see http://www.tcl.tk/man/tcl8.5/TkCmd/event.htm#M16 Anyway, I hope you add a data field for user created virtual events. |
|||
| msg165254 - (view) | Author: O.C. (dghjfrdj) | Date: 2012年07月11日 12:13 | |
I don't agree with this comment. 1) The 'detail' field also contains a string, one of the following: "NotifyAncestor", "NotifyNonlinearVirtual",... 2) When an event is received, the 'detail' and 'user_data' fields are de facto mixed up. Indeed, the "%d" field contains "the detail or user_data field from the event". This information comes form the documentation I cited, http://www.tcl.tk/man/tcl8.5/TkCmd/bind.htm#M24 : * The "%d" field contains "the detail or user_data field from the event". * They are both strings: * "the %d is replaced by a string identifying the detail" * "For virtual events, the string will be whatever value is stored in the user_data field when the event was created (typically with event generate), or the empty string if the field is NULL" From the document cited in msg165234 (http://www.tcl.tk/man/tcl8.5/TkCmd/event.htm#M16), my understanding is: * For virtual events, the "data" string parameter given to "event generate" will be stored in the "user_data field" for the event. This string will then be available from the event through the "%d" substitution. * For events "Enter", "Leave", "FocusIn" and "FocusOut", the "detail" field will store a string among "NotifyAncestor", etc. This string will then be available from the event through the "%d" substitution. So, from the point of view of the guy who receives the event, the "%d" field can EITHER be a "detail" string like "NotifyAncestor" if event was "Enter"/"Leave"/"FocusIn"/"FocusOut" OR a "user_data" string in the case of a virtual event. It seems sensible that the Python interface provides both names. As a consequence, I think the patch should read: + # value passed to the data option is not a widget, take it + # as the detail field + e.data = None + e.detail = d + e.user_data = d I hope I understood the doc correctly. |
|||
| msg315621 - (view) | Author: Matthias Kievernagel (mkiever) * | Date: 2018年04月22日 17:09 | |
I have a patched Python 3.5.3 running mostly following the comments by O.C. If no one else is active on this I can try to prepare something for submission. |
|||
| msg315624 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2018年04月22日 17:33 | |
Fill free to create a pull request. It may need tests and documentation though. |
|||
| msg318035 - (view) | Author: Matthias Kievernagel (mkiever) * | Date: 2018年05月29日 14:18 | |
So I pulled, but it seems the CLA is stuck somewhere. Investigating... |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:36 | admin | set | github: 47655 |
| 2018年05月29日 14:18:00 | mkiever | set | messages: + msg318035 |
| 2018年05月27日 17:09:44 | mkiever | set | pull_requests: + pull_request6776 |
| 2018年04月22日 17:33:22 | serhiy.storchaka | set | messages: + msg315624 |
| 2018年04月22日 17:09:37 | mkiever | set | messages: + msg315621 |
| 2018年03月19日 23:04:49 | mkiever | set | nosy:
+ mkiever |
| 2013年09月15日 11:03:03 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka versions: + Python 3.4, - Python 3.3 |
| 2013年05月04日 10:45:45 | alex.rodas | set | nosy:
+ alex.rodas |
| 2012年07月11日 12:13:48 | dghjfrdj | set | messages: + msg165254 |
| 2012年07月11日 08:29:57 | mark | set | nosy:
+ mark messages: + msg165234 |
| 2012年04月03日 18:50:48 | asvetlov | set | nosy:
+ asvetlov |
| 2011年01月31日 20:44:31 | dghjfrdj | set | nosy:
+ dghjfrdj messages: + msg127658 |
| 2010年12月22日 02:29:21 | r.david.murray | set | stage: patch review type: enhancement versions: + Python 3.3, - Python 2.6, Python 3.0 |
| 2008年07月19日 16:35:41 | gpolo | set | files: - event_generate__data.diff |
| 2008年07月19日 15:33:10 | gpolo | set | files:
+ event_generate__data2.diff messages: + msg70040 |
| 2008年07月18日 12:52:45 | gpolo | create | |