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


Groups > comp.lang.python > #63870

Re: Tkinter GUI Error

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.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.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'elif': 0.05; 'subject:Error': 0.07; 'string': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'itself.': 0.14; 'digits.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'length,': 0.16; 'lengths': 0.16; 'subject:GUI': 0.16; 'subject:Tkinter': 0.16; 'true:': 0.16; 'zeroes': 0.16; 'wrote:': 0.18; 'numerical': 0.19; 'pieces': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'specified': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'skip:= 20': 0.31; 'this.': 0.32; 'beginning': 0.33; 'could': 0.34; 'knows': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'doing': 0.36; 'entry': 0.36; 'two': 0.37; 'represent': 0.38; 'needed': 0.38; 'number,': 0.60; 'most': 0.60; 'numbers': 0.61; 'range': 0.61; 'simply': 0.61; "you've": 0.63; 'skip:n 10': 0.64; 'careful': 0.91; '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=3WZ4ysaDCwpZCuolB37e1w+fmTSeClnpBTzZGwTPsbw=; b=WHiaWWqj6jqa0PqciXytCu3mUMyPl9eXkVYB1mvPPIogT/ewy6AYa0ITHsP1lm/AH2 +wgZSYWF81eZpIpYuP6BC66XkZn38uYkbcEfY/yxe/K8X0WXDavfgYEXiNFRf1Ho2mue JkU7jRmxvA/jhkdoyfgrUNW6RLd9ocIKCF7eDPI9r9x2XXb5TEvehTL9ReyovXk678/h o2FKxJ8ApxAfehvW6U6Onf2hxkp2ADvZDcCIbV2S3eNAIjtIx6Wz5n+kaZd+8qkU0VDT SAqAJIVagUvcxN553wSv42tK8KP6YU7c02X0PumIZgQFbtyqxRChLD2NkepBr8QqcKgE gNRw==
MIME-Version 1.0
X-Received by 10.68.98.3 with SMTP id ee3mr34005729pbb.31.1389669121345; Mon, 13 Jan 2014 19:12:01 -0800 (PST)
In-Reply-To <1ab2aa93-1ba6-48b0-a5f4-5fb05cb523d1@googlegroups.com>
References <1ab2aa93-1ba6-48b0-a5f4-5fb05cb523d1@googlegroups.com>
Date Tue, 14 Jan 2014 14:12:01 +1100
Subject Re: Tkinter GUI Error
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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.5435.1389669132.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389669133 news.xs4all.nl 2867 [2001:888:2000:d::a6]:42949
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63870

Show key headers only | View raw


On Tue, Jan 14, 2014 at 5:49 AM,  <fluttershy363@gmail.com> wrote:
>     entry = entry1var.get()
>     if entry == num1:
>     elif entry > num1:
>     elif entry < num1:
>
> num1 =str(random.randint(10,99))
> num2 =str(random.randint(10,99))
> num3 =str(random.randint(10,99))
> mastercode = num1+num2+num3

Be careful of code like this. You've specified that your three parts
range from 10 through 99, so this will work as long as the user knows
this and enters exactly two digits. Doing inequality comparisons on
strings that represent numbers will work as long as they're the same
length, but if the lengths vary, the string comparisons will start at
the beginning - not what most people will expect. These are all true:

"2" > "10"
"3.14159" > "2,000,000"
"42" < "Life, the universe, and everything"
"00012" < "12"

If your intention is to have a six-digit number, you could simply ask
for one, and then format the pieces accordingly:

num = random.randint(1,999999)
num_str = "%06d" % num

You can then slice up num_str as needed (it'll have leading zeroes if
it needs them), or you can do numerical comparisons against num
itself.

ChrisA

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


Thread

Tkinter GUI Error fluttershy363@gmail.com - 2014-01-13 10:49 -0800
  Re: Tkinter GUI Error Lewis Wood <fluttershy363@gmail.com> - 2014-01-13 10:51 -0800
  Re: Tkinter GUI Error Christian Gollwitzer <auriocus@gmx.de> - 2014-01-13 20:03 +0100
    Re: Tkinter GUI Error Lewis Wood <fluttershy363@gmail.com> - 2014-01-13 11:21 -0800
  Re: Tkinter GUI Error Peter Otten <__peter__@web.de> - 2014-01-13 20:36 +0100
  Re: Tkinter GUI Error Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-13 20:39 -0500
  Re: Tkinter GUI Error Rick Johnson <rantingrickjohnson@gmail.com> - 2014-01-13 18:47 -0800
  Re: Tkinter GUI Error Chris Angelico <rosuav@gmail.com> - 2014-01-14 14:12 +1100
    Re: Tkinter GUI Error Lewis Wood <fluttershy363@gmail.com> - 2014-01-14 11:11 -0800
      Re: Tkinter GUI Error Lewis Wood <fluttershy363@gmail.com> - 2014-01-14 13:27 -0800
        Re: Tkinter GUI Error Christian Gollwitzer <auriocus@gmx.de> - 2014-01-14 22:33 +0100

csiph-web