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


Groups > comp.lang.python > #86104

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!newsfeed4a.news.xs4all.nl!xs4all!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.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'correct.': 0.07; '22,': 0.09; 'callback': 0.09; 'e.g.,': 0.09; 'function,': 0.09; 'latter': 0.09; 'parameter': 0.09; 'terminates': 0.09; 'cc:addr :python-list': 0.11; 'gui': 0.12; 'closed,': 0.16; 'closure,': 0.16; 'expects': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'somewhere.': 0.16; 'uncommon': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'query': 0.26; 'header:In-Reply-To:1': 0.27; 'thus': 0.29; 'message-id:@mail.gmail.com': 0.30; 'program,': 0.31; 'code': 0.31; 'information?': 0.31; 'object.': 0.31; 'probably': 0.32; 'text': 0.33; "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; 'window': 0.38; 'handle': 0.38; 'pm,': 0.38; 'little': 0.38; 'sure': 0.39; 'either': 0.39; 'how': 0.40; 'most': 0.60; 'new': 0.61; 'simple': 0.61; 'kind': 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=2uYF7y+j1MUCvugtUE+IbgKTCVpdafPPctZ9Ely2evE=; b=BQn4UHTaDa3y48b1la+bl8mE1RYxVjOFUr/TIDF4ZQlmEbLE4XBH9Gbtoa1A2D00Rb UifHUOYHfz6l/mBM+QLSSI9HVQ2zQFWbqoJ8aUIxjXlfHQ8zQK/vu1wunxXjUgs13dG9 SBhgXUjbWyWJSypGm204FKOXP1uMlebUEPuynjuHSkHOuxueMCgn/+cEvw44D2pno6m/ pv/pEdMAx0nmB1tdxaEfDTndo7bOSYA05pak6FZjSUWqUhA64EBLaOZH2xKMGesBHsps uPwefB5K2zXN6nLmZtP2wtntGglcExbHVae4XHLW0AYrvjwIixcuUlwrziCkdbuav7RF VAeA==
MIME-Version 1.0
X-Received by 10.50.62.110 with SMTP id x14mr7330174igr.2.1424607849782; Sun, 22 Feb 2015 04:24:09 -0800 (PST)
In-Reply-To <1444051E-DBD0-4162-94DF-50BC6CF62A92@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> <CAPTjJmoZsB8=xpadFp_S5TFqHcSjW9kO-SfmJzM2dLvq+yCPRA@mail.gmail.com> <1444051E-DBD0-4162-94DF-50BC6CF62A92@gmail.com>
Date Sun, 22 Feb 2015 23:24:09 +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.19004.1424607858.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424607858 news.xs4all.nl 2894 [2001:888:2000:d::a6]:34664
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86104

Show key headers only | View raw


On Sun, Feb 22, 2015 at 11:07 PM, Cem Karan <cfkaran2@gmail.com> 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.
>
> 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.

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.

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 23:24 +1100

csiph-web