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


Groups > comp.lang.python > #35681

Re: learning curve

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'startup': 0.05; 'lines.': 0.07; 'none):': 0.07; 'override': 0.07; 'run,': 0.07; 'tkinter': 0.07; 'buttons': 0.09; 'hooks': 0.09; 'overridden': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'semantics': 0.09; 'terry': 0.09; 'def': 0.10; 'suggest': 0.11; 'library': 0.15; '(ie,': 0.16; 'event=none):': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'version.': 0.17; 'widget': 0.17; 'jan': 0.18; 'import': 0.21; 'file:': 0.22; 'runs': 0.22; 'example': 0.23; 'second': 0.24; 'command': 0.24; 'specifically': 0.24; 'pass': 0.25; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:m 30': 0.26; 'coding': 0.27; 'first,': 0.27; 'older': 0.27; 'mind.': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'skip:( 20': 0.28; 'initial': 0.28; 'dialog': 0.29; 'informative': 0.29; 'parent': 0.29; 'subject:learning': 0.29; 'case,': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'classes': 0.30; 'window': 0.30; 'button': 0.30; 'code': 0.31; '(and': 0.32; 'print': 0.32; 'getting': 0.33; 'says': 0.33; 'skip:s 30': 0.33; 'to:addr:python- list': 0.33; 'that,': 0.34; 'self': 0.34; 'third': 0.34; 'pm,': 0.35; 'something': 0.35; 'add': 0.36; 'received:org': 0.36; 'but': 0.36; 'method': 0.36; 'anything': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'beyond': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'advice': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'first': 0.61; 'back': 0.62; 'box.': 0.65; 'construction': 0.72; 'received:fios.verizon.net': 0.84; 'subjects': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: learning curve
Date Fri, 28 Dec 2012 03:26:43 -0500
References <50DCF3DE.7030600@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
In-Reply-To <50DCF3DE.7030600@gmail.com>
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.1385.1356683244.29569.python-list@python.org> (permalink)
Lines 116
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1356683244 news.xs4all.nl 6918 [2001:888:2000:d::a6]:50832
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35681

Show key headers only | View raw


On 12/27/2012 8:20 PM, Verde Denim wrote:
> Just getting into Py coding and not understanding why this code doesn't
> seem to do anything -

Part of your 'learning curve' should be learning to write informative 
subjects lines. The above says almost nothing. For this I suggest 
"Problem with classes and tkinter". In this case, you specifically need 
to add the tkinter startup code; check the example in the manual. If you 
do add that, you code may run, but it may required advice with someone 
with tkinter expertise (and interest) beyond mind.

Also, if you are just starting, I recommend you start with 3.3 unless 
you have a good reason to start with an older version. (IE, you need to 
use a third party library that only runs with 2.x.)

> # 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
>


-- 
Terry Jan Reedy

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


Thread

Re: learning curve Terry Reedy <tjreedy@udel.edu> - 2012-12-28 03:26 -0500

csiph-web