Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86051

Re: Design thought for callbacks

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.030
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'correct.': 0.07; '22,': 0.09; 'callback': 0.09; 'chunk': 0.09; 'terminates': 0.09; 'cc:addr:python-list': 0.11; 'gui': 0.12; 'closed,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'uncommon': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'program,': 0.31; 'code': 0.31; 'breaking': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'window': 0.38; 'little': 0.38; 'most': 0.60; 'simple': 0.61; "you're": 0.61; 'making': 0.63; 'close': 0.67; 'subject:Design': 0.78; '2015': 0.84; 'everything.': 0.84; 'subject:thought': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=hhnwJOs3N0rkUSfSdmvnA2PtjWrc2Z7O2C8qEnkrqeg=; b=ZCxqduEXmGZewv+XwwrRcyS7BwGJuTKIs2sn6f9xV3xtFLVLo5LVbwpU0aedYlIoZ6 cPZlEec7dekE6Jun9etJOFCGuuUXmclYBkhQpzE+Goecj3VnPwAIwyZIzPpJJ4ft592m n6h7NMV8eX3kDw889P0OOiDo2esPgoOGFgc1HINQZkCFDFf+pWRqtvocrNq3erF8W6W1 6GHWg+7R1c14XVYmn9mgBUXp2iqrp15HMluwy6bPsf64bql+XBWyroqAPYtbgcsDHRpF 7b0r7OUsR/BWhNLY70xceCMO6bffuO4rEghGV3eH19o8Pgspr43Ti8M3yv9IQzdmWn2O Zp3g==
MIME-Version 1.0
X-Received by 10.42.13.193 with SMTP id e1mr3221451ica.59.1424534113130; Sat, 21 Feb 2015 07:55:13 -0800 (PST)
In-Reply-To <C82546F4-1CBB-4D83-834F-CF1BAE52E8E9@gmail.com>
References <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <CAPTjJmpEHQV2PpaZvszuTGn0_GNg0sWV6aLenbQsZrSXCy2YKQ@mail.gmail.com> <39813568-6DB8-4341-A130-C256CFF352EE@gmail.com> <CAPTjJmrfMowbK7z+eN7xfMv2Ck5peJpBPyBRHvhXM4-ocxRR6w@mail.gmail.com> <BB15CAE6-4C31-4544-A9DE-DC9D6F827B45@gmail.com> <CAPTjJmrA2suEdKDZkn44Xxsq4m_mZ=Jf6C19GvBjoBfCaTEyzg@mail.gmail.com> <C82546F4-1CBB-4D83-834F-CF1BAE52E8E9@gmail.com>
Date Sun, 22 Feb 2015 02:55:13 +1100
Subject Re: Design thought for callbacks
From Chris Angelico <rosuav@gmail.com>
Cc "comp.lang.python" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18974.1424534116.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424534116 news.xs4all.nl 2840 [2001:888:2000:d::a6]:39284
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86051

Show key headers only | View raw


On Sun, Feb 22, 2015 at 2:45 AM, Cem Karan <cfkaran2@gmail.com> wrote:
> OK, so if I'm reading your code correctly, you're breaking the cycle in your object graph by making the GUI the owner of the callback, correct?  No other chunk of code has a reference to the callback, correct?

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.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Design thought for callbacks Chris Angelico <rosuav@gmail.com> - 2015-02-22 02:55 +1100

csiph-web