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


Groups > comp.lang.python > #44288

Re: My gui

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <arnodel@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.057
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'tkinter': 0.07; 'width': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '24,': 0.16; 'frame,': 0.16; 'spotted': 0.16; 'stuff.': 0.16; 'subject:gui': 0.16; 'underscores': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'wed,': 0.18; 'bit': 0.19; 'seems': 0.21; 'command': 0.22; 'import': 0.22; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'copied': 0.24; 'looks': 0.24; 'cc:no real name:2**0': 0.24; 'compare': 0.26; 'daniel': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'container': 0.31; 'helpful.': 0.31; 'class': 0.32; 'text': 0.33; 'url:python': 0.33; 'skip:_ 10': 0.34; "i'd": 0.34; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'idle': 0.36; 'right?': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'being': 0.38; 'pm,': 0.38; 'does': 0.39; 'sure': 0.39; 'url:mail': 0.40; 'skip:t 30': 0.61; 'today,': 0.61; 'forward': 0.65; 'distance': 0.65; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'sample': 0.67; 'home': 0.69; '8bit%:43': 0.74; 'unusual': 0.74; 'day': 0.76; 'textbook': 0.84; 'don\xe2\x80\x99t': 0.91; 'serious': 0.97; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; bh=v5XOv6sw6wUiPMHdxhNYLsW1SeRjXZ+x6IEZkZCpFgI=; b=MpPk8cHONZXIz3/qFV4kzgO+3LMRb0HnVFz3HM21ibNe36NiRQOPj63SYddY+M50cf GhykbgB2d6t4f822V08qTf93Eu4AbfajvKT0kIFMbWCC+sjZJwq5EAqhS9MQizooGaGR C4QR+kxQwYba2H5F6g2xBwuijk+G5VpvSB2J5k4dPuigxF6WRJVWtvemlG5XcGQwCIBv 2pUWw/4V1BAb1PJw2fbUg+nu0+jFHscV0IvAZk+sgZ179bIHXcHZVuUSEi/ZTcoXQRlt cLKhyEi6Rvuvzwz1gB72ops0zIRmDnyBOEMMb3Ta9cTAvhfFEJT5NRQEk2Vc2WsJWbGd g5pg==
MIME-Version 1.0
X-Received by 10.112.147.99 with SMTP id tj3mr18264440lbb.94.1366832569129; Wed, 24 Apr 2013 12:42:49 -0700 (PDT)
In-Reply-To <CAMw+j7+g44HHSsjeu320d7JkMMn==LN+X_8FLrcLTWm3NPZb9g@mail.gmail.com>
References <09b96d6b-6db3-42a2-88d3-5fe16984fed1@googlegroups.com> <CAMw+j7+g44HHSsjeu320d7JkMMn==LN+X_8FLrcLTWm3NPZb9g@mail.gmail.com>
Date Wed, 24 Apr 2013 20:42:48 +0100
Subject Re: My gui
From Arnaud Delobelle <arnodel@gmail.com>
To Chris “Kwpolska” Warrick <kwpolska@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org, Daniel Kersgaard <danielkersgaard@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.1031.1366832576.3114.python-list@python.org> (permalink)
Lines 69
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366832576 news.xs4all.nl 15900 [2001:888:2000:d::a6]:44458
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44288

Show key headers only | View raw


On 24 April 2013 18:53, Chris “Kwpolska” Warrick <kwpolska@gmail.com> wrote:
> On Wed, Apr 24, 2013 at 7:08 PM, Daniel Kersgaard
> <danielkersgaard@gmail.com> wrote:
>> Today, being the last day of lectures at school, my instructor ran briefly through Tkninter and GUIs. I'd been looking forward to this particular lesson all semester, but when I got home and copied a sample program from my textbook verbatim, IDLE does nothing. No error, no nothing. Any ideas? Here  is the code from my program. I'm not sure if this is appropriate, but suggestions are helpful.
>>
>> import tkinter
>> import tkinter.messagebox
>>
>> class MyGui:
>>     def _init_(self):
>>         self.main_window = tkinter.Tk()
>>
>>         self.top_frame = tkinter.Frame(self.main_window)
>>         self.bottom_frame = tkinter.Frame(self.main_window)
>>
>>         self.prompt_label = tkinter.Label(self.top_frame, text = 'Enter a distance in Kilometers: ')
>>         self.kilo_entry = tkinter.Entry(self.top_frame, width = 10)
>>
>>         self.prompt_label.pack(side = 'left')
>>         self.kilo_entry.pack(side = 'left')
>>
>>         self.calc_button = tkinter.Button(self.bottom_frame, text = 'Convert', command = self.convert)
>>
>>         self.quit_button = tkinter.Button(self.bottom_frame, text = 'Quit', command = self.main_window.destroy)
>>
>>         self.calc_button.pack(side = 'left')
>>         self.quit_button.pack(side = 'left')
>>
>>         self.top_frame.pack()
>>         self.bottom_frame.pack()
>>
>>         tkinter.mainloop()
>>
>>     def convert(self):
>>         kilo = float(self.kilo_entry.get())
>>
>>         miles = kilo * 0.6214
>>
>>         tkinter.messagebox.showinfo('Result', str(kilo) + ' kilometers is equal to ' + str(miles) + 'miles.')
>>
>> poop = MyGui()
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
> poop?  Seriously?  You aren’t serious about that copying, right?
>
> Your code seems to be missing a lot of important stuff.  You don’t
> inherit from tkinter.Frame.  Compare your program to the sample “Hello
> world!” program:

His class is not a frame, it's just a container for the tkinter code.
It's a bit unusual but it looks correct to me (apart from the single
underscores in __init__() as spotted by Ned Batchelder).

-- 
Arnaud

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


Thread

My gui Daniel Kersgaard <danielkersgaard@gmail.com> - 2013-04-24 10:08 -0700
  Re: My gui Dave Angel <davea@davea.name> - 2013-04-24 13:46 -0400
  Re: My gui Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-04-24 19:53 +0200
  Re: My gui Ned Batchelder <ned@nedbatchelder.com> - 2013-04-24 14:08 -0400
  Re: My gui Arnaud Delobelle <arnodel@gmail.com> - 2013-04-24 20:42 +0100
    Re: My gui Neil Cerutti <neilc@norwich.edu> - 2013-04-24 20:26 +0000
  Re: My gui Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-24 22:51 -0400
  Re: My gui Chris Angelico <rosuav@gmail.com> - 2013-04-25 13:17 +1000

csiph-web