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


Groups > comp.lang.python > #35670

learning curve

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tdldev@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'none):': 0.07; 'override': 0.07; 'tkinter': 0.07; 'buttons': 0.09; 'hooks': 0.09; 'overridden': 0.09; 'semantics': 0.09; 'def': 0.10; 'event=none):': 0.16; 'widget': 0.17; 'import': 0.21; 'file:': 0.22; 'second': 0.24; 'command': 0.24; 'pass': 0.25; 'header:User- Agent:1': 0.26; 'skip:m 30': 0.26; 'coding': 0.27; 'first,': 0.27; "doesn't": 0.28; 'skip:( 20': 0.28; 'initial': 0.28; 'received:10.0.0': 0.28; 'dialog': 0.29; 'parent': 0.29; 'subject:learning': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'window': 0.30; 'button': 0.30; 'code': 0.31; 'print': 0.32; 'getting': 0.33; 'skip:s 30': 0.33; 'received:10.0': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'self': 0.34; 'received:209.85': 0.35; 'something': 0.35; 'add': 0.36; 'message-id:@gmail.com': 0.36; 'method': 0.36; 'anything': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'why': 0.37; 'received:209': 0.37; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'first': 0.61; 'back': 0.62; 'box.': 0.65; 'construction': 0.72
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding; bh=D1/fqFw2kqJNiNaKo7zfO7EJmHjxtz9uOFDGhCeoHIM=; b=Ogj6kvgmzMYrG7GTPCt5u/mRGCi7/kxqd8sKMZ5BFFMWI+76l7Pj2sbrsnldetOipL bul94Vvgt75RzOGt5tPtJ4osD3NfK9SAtqG48R40G4gXxUfHmZ39pjnbPC4l2PzFnSbe 2V8giTerpsMgHBl0xIY2rXvG51jBbjAZNkWQ9bkRIFAKiI8PWrM/HVnkZEcO/9VuBbzN pB3LSkDJwFgyKnE1EgEfj+2v1iCS77VJDx/bihDl+hJnFgMzXRxczAG2KdMfqZwSv3kx WX0dWw63mbIOY0+APnqqlCHBlajzxjRiEi86nGR7gDCXbKFnjuJcunvkOVHfONTdpnGa oLRQ==
X-Received by 10.236.118.193 with SMTP id l41mr29841042yhh.50.1356657587757; Thu, 27 Dec 2012 17:19:47 -0800 (PST)
Date Thu, 27 Dec 2012 20:20:30 -0500
From Verde Denim <tdldev@gmail.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20121215 Iceowl/1.0b1 Icedove/3.0.11
MIME-Version 1.0
To python-list@python.org
Subject learning curve
X-Enigmail-Version 1.0.1
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1379.1356660991.29569.python-list@python.org> (permalink)
Lines 98
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1356660991 news.xs4all.nl 6932 [2001:888:2000:d::a6]:33637
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35670

Show key headers only | View raw


Just getting into Py coding and not understanding why this code doesn't
seem to do anything -

# File: dialog2.py
import dialog_handler

class MyDialog(dialog_handler.Dialog):
    def body(self, master):
        Label(master, text="First:").grid(row=0)
        Label(master, text="Second:").grid(row=1)
        self.e1 = Entry(master)
        self.e2 = Entry(master)
        self.e1.grid(row=0, column=1)
        self.e2.grid(row=1, column=1)
        return self.e1 # initial focus

    def apply(self):
        first = string.atoi(self.e1.get())
        second = string.atoi(self.e2.get())
        print first, second # or something

# File: dialog_handler.py

from Tkinter import *
import os

class Dialog(Toplevel):

    def __init__(self, parent, title = None):
        Toplevel.__init__(self, parent)
        self.transient(parent)

        if title:
            self.title(title)
        self.parent = parent
        self.result = None
        body = Frame(self)
        self.initial_focus = self.body(body)
        body.pack(padx=5, pady=5)
        self.buttonbox()
        self.grab_set()

        if not self.initial_focus:
            self.initial_focus = self

        self.protocol("WM_DELETE_WINDOW", self.cancel)
        self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
                                  parent.winfo_rooty()+50))
        self.initial_focus.focus_set()
        self.wait_window(self)

        #
        # construction hooks
        def body(self, master):
            # create dialog body.  return widget that should have
            # initial focus.  this method should be overridden
            pass

        def buttonbox(self):
            # add standard button box. override if you don't want the
            # standard buttons
            box = Frame(self)

            w = Button(box, text="OK", width=10, command=self.ok,
                       default=ACTIVE)
            w.pack(side=LEFT, padx=5, pady=5)
            w = Button(box, text="Cancel", width=10,
                       command=self.cancel)
            w.pack(side=LEFT, padx=5, pady=5)

            self.bind("&lt;Return>", self.ok)
            self.bind("&lt;Escape>", self.cancel)

            box.pack()

        #
        # standard button semantics
        def ok(self, event=None):
            if not self.validate():
                self.initial_focus.focus_set() # put focus back
                return
            self.withdraw()
            self.update_idletasks()
            self.apply()
            self.cancel()

        def cancel(self, event=None):
            # put focus back to the parent window
            self.parent.focus_set()
            self.destroy()

        #
        # command hooks
        def validate(self):
            return 1 # override

        def apply(self):
            pass # override

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


Thread

learning curve Verde Denim <tdldev@gmail.com> - 2012-12-27 20:20 -0500
  Re: learning curve alex23 <wuwei23@gmail.com> - 2012-12-27 18:32 -0800
    Re: learning curve Verde Denim <tdldev@gmail.com> - 2012-12-28 13:29 -0500
    Re: learning curve Terry Reedy <tjreedy@udel.edu> - 2012-12-28 21:03 -0500

csiph-web