File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,9 +60,21 @@ \section{PEP 309: Partial Function Application}
6060server_log = functional.partial(log, subsystem='server')
6161\end {verbatim }
6262
63- Here's another example, from a program that uses PyGTk.
63+ Here's another example, from a program that uses PyGTk. Here a
64+ context-sensitive pop-up menu is being constructed dynamically. The
65+ callback provided for the menu option is a partially applied version
66+ of the \method {open_item()} method, where the first argument has been
67+ provided.
6468
65- % XXX add example from my GTk programming
69+ \begin {verbatim }
70+ ...
71+ class Application:
72+ def open_item(self, path):
73+ ...
74+ def init (self):
75+ open_func = functional.partial(self.open_item, item_path)
76+ popup_menu.append( ("Open", open_func, 1) )
77+ \end {verbatim }
6678
6779
6880\begin {seealso }
You can’t perform that action at this time.
0 commit comments