Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'correct.': 0.07; 'patterns.': 0.07; '22,': 0.09; 'callback': 0.09; 'e.g.,': 0.09; 'function,': 0.09; 'latter': 0.09; 'objects,': 0.09; 'parameter': 0.09; 'terminates': 0.09; 'cc:addr:python-list': 0.11; 'gui': 0.12; "wouldn't": 0.14; 'closed,': 0.16; 'closure,': 0.16; 'expects': 0.16; 'parameters,': 0.16; 'somewhere.': 0.16; 'uncommon': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'cc:2**0': 0.24; 'query': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'thus': 0.29; 'program,': 0.31; 'code': 0.31; 'url:wiki': 0.31; 'information?': 0.31; 'object.': 0.31; 'url:wikipedia': 0.31; 'probably': 0.32; "we're": 0.32; 'text': 0.33; 'sense': 0.34; "i'd": 0.34; 'could': 0.34; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'event,': 0.36; 'returning': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'window': 0.38; 'handle': 0.38; 'pm,': 0.38; 'little': 0.38; 'structure': 0.39; 'sure': 0.39; 'either': 0.39; 'how': 0.40; 'most': 0.60; 'new': 0.61; 'simple': 0.61; "you're": 0.61; 'header:Message-Id:1': 0.63; 'kind': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'close': 0.67; 'subject:Design': 0.78; '2015': 0.84; 'dag': 0.84; 'everything.': 0.84; 'hub': 0.84; 'partially': 0.84; 'subject:thought': 0.84; 'spoke': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=wXXX0ltwBvApKCBnxmGNKNLwNlptKesOzSEXagCboBo=; b=gMADVn9HKPYu2Td/Ck19FpJR3HHm/tV7DgIj+6tXqPFsytO5g/IWlv5a2UMpJVFnev GXxgTZTUFZO3pUdich+MGmQjmapUW0M6jeFBIjjO0iFjbcpJ88slmjR/wXiWKsUcVgz4 isxarOcm8EisiVS/rEFEPUMFzGlH7Um8F/nbEQyEai4GT00Q/YaUEQRbblyG/Yf1NHqO 8KS6jkWAfmyPOnFy1sNDhoZBe2C4qJlAepZiOmgxMc1f1Gn/kDkvT+P6sh1Wl0qoVKc2 JfhSk6+NQzpzPXkJnC9v06+ao8M6xf+l55VC+g5j4Bb5zhzU6xi/fDaTVJigE7eI5upY VcRg== X-Received: by 10.53.4.39 with SMTP id cb7mr6420638vdd.37.1424613270468; Sun, 22 Feb 2015 05:54:30 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Design thought for callbacks From: Cem Karan In-Reply-To: Date: Sun, 22 Feb 2015 08:54:28 -0500 Content-Transfer-Encoding: quoted-printable References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <39813568-6DB8-4341-A130-C256CFF352EE@gmail.com> <1444051E-DBD0-4162-94DF-50BC6CF62A92@gmail.com> To: Chris Angelico X-Mailer: Apple Mail (2.1510) Cc: "comp.lang.python" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424613279 news.xs4all.nl 2939 [2001:888:2000:d::a6]:37443 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 6308 X-Received-Body-CRC: 2416758939 Xref: csiph.com comp.lang.python:86116 On Feb 22, 2015, at 7:24 AM, Chris Angelico wrote: > On Sun, Feb 22, 2015 at 11:07 PM, Cem Karan = wrote: >>> Correct. The GUI engine ultimately owns everything. Of course, this = is >>> a very simple case (imagine a little notification popup; you don't >>> care about it, you don't need to know when it's been closed, the = only >>> event on it is "hit Close to destroy the window"), and most usage >>> would have other complications, but it's not uncommon for me to = build >>> a GUI program that leaves everything owned by the GUI engine. >>> Everything is done through callbacks. Destroy a window, clean up its >>> callbacks. The main window will have an "on-deletion" callback that >>> terminates the program, perhaps. It's pretty straight-forward. >>=20 >> How do you handle returning information? E.g., the user types in a = number and expects that to update the internal state of your code = somewhere. >=20 > Not sure what you mean by "returning". If the user types in a number > in a GUI widget, that would trigger some kind of on-change event, and > either the new text would be a parameter to the callback function, or > the callback could query the widget. In the latter case, I'd probably > have the callback as a closure, and thus able to reference the object. We're thinking of the same thing. I try to structure what little GUI = code I write using the MVP pattern = (http://en.wikipedia.org/wiki/Model-view-presenter), so I have these hub = and spoke patterns. But you're right, if you have a partially evaluated = callback that has the presenter as one of the parameters, that would do = it for a GUI. I was thinking more of a DAG of objects, but now that I = think about it, callbacks wouldn't make sense in that case. Thanks, Cem Karan=