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


Groups > comp.lang.python > #41559

Re: Python GUI questions

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jason.swails@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'reject': 0.05; 'character,': 0.07; 'e.g.,': 0.07; 'tkinter': 0.07; 'python': 0.09; 'derived': 0.09; 'input,': 0.09; 'occurrences': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'bind': 0.16; 'frame,': 0.16; 'luck,': 0.16; 'optionally': 0.16; 'subject:GUI': 0.16; 'subject:questions': 0.16; 'tk()': 0.16; 'tkinter.': 0.16; '\xa0you': 0.16; 'string': 0.17; 'wrote:': 0.17; 'instance,': 0.17; 'widget': 0.17; 'input': 0.18; 'are:': 0.20; 'email addr:gmail.com&gt;': 0.20; 'skip:= 10': 0.20; 'import': 0.21; 'meant': 0.21; 'accommodate': 0.22; 'questions:': 0.22; '\xa0if': 0.22; 'cc:2**0': 0.23; 'work.': 0.23; '&gt;': 0.23; 'seems': 0.23; 'raise': 0.24; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; '(unless': 0.29; 'changed.': 0.29; 'container': 0.29; 'unlikely': 0.29; 'character': 0.29; 'skip:& 10': 0.29; 'class': 0.29; "i'm": 0.29; 'classes': 0.30; 'checks': 0.30; 'window': 0.30; 'button': 0.30; 'johnson': 0.32; 'suggestion': 0.32; 'skip:_ 30': 0.32; 'equal': 0.33; 'entry': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'updated': 0.34; 'filter': 0.35; 'generic': 0.35; 'jason': 0.35; 'pm,': 0.35; 'but': 0.36; 'url:org': 0.36; 'method': 0.36; 'quite': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'hello,': 0.39; 'skip:w 30': 0.61; 'side': 0.61; "you'll": 0.62; 'is.': 0.62; 'road': 0.63; 'show': 0.63; 'making': 0.64; 'here': 0.65; 'believe': 0.69; 'url:htm': 0.71; '2013': 0.84; 'brick': 0.84; 'say:': 0.84; 'yellow': 0.84; '"how': 0.91; 'rick': 0.91
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; bh=CWxpMqrTF1vg1IOOE29R+6PlxcL3n4YPNDPqVYtbW1U=; b=xXLXArcYPtTTRQiy0737bVD2UfAJ5987pfwytvWNSpxWq5Rbb5CfsF1zm6W3bzna7p lsKhDnRO2kLqkZgmg/pWispI4vKi48eYmJlXWR3+OIe2kBNRJ8tiOl80TlVgOyL5BRn3 q7XeSWF4WpOKtfD4Gm+RGx7lYx5yrd2knInlBxD7TYzmyldGrMpzby2pxj/4CWsJQypx 8Zk0BdWR1Cv/Ygm8DzSN40VqkrDb6hHOnB4Sh2P8qJ4XVc/l817u3/MiPjL0gEWFABeu 3sRHC3xwI6oyKzAdPJrji8kiWzHPnVtG+eSHMsXw07LsFjaaQsdgv89+tcK+yzveGvOf alfw==
MIME-Version 1.0
X-Received by 10.50.190.233 with SMTP id gt9mr3020345igc.80.1363745648066; Tue, 19 Mar 2013 19:14:08 -0700 (PDT)
In-Reply-To <262b7363-f980-4926-bb36-1f795769b359@googlegroups.com>
References <4250fe44-c09c-48a8-aca2-51c1a8bc3a48@googlegroups.com> <e745739b-a9bb-49a3-8a06-1b4ae3f4d901@googlegroups.com> <262b7363-f980-4926-bb36-1f795769b359@googlegroups.com>
Date Tue, 19 Mar 2013 22:14:07 -0400
Subject Re: Python GUI questions
From Jason Swails <jason.swails@gmail.com>
To maiden129 <sengokubasarafever@gmail.com>
Content-Type multipart/alternative; boundary=14dae9341177eacb6804d851c605
Cc python-list@python.org
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.3541.1363745651.2939.python-list@python.org> (permalink)
Lines 240
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363745651 news.xs4all.nl 6966 [2001:888:2000:d::a6]:41041
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41559

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Mar 19, 2013 at 9:25 PM, maiden129 <sengokubasarafever@gmail.com>wrote:

> On Tuesday, March 19, 2013 8:57:42 PM UTC-4, Rick Johnson wrote:
> > On Tuesday, March 19, 2013 2:01:24 PM UTC-5, maiden129 wrote:
> >
> > > Hello,
> >
> > >
> >
> > > I'm using python 3.2.3 and I'm making a program that show
> >
> > > the of occurrences of the character in the string in
> >
> > > Tkinter.
> >
> > >
> >
> > > My questions are:
> >
> > >
> >
> > > How can I make an empty Entry object that will hold a word
> >
> > > that a user will enter?
> >
> >
> >
> > I believe you meant to say: "How can i CREATE an entry field to
> accommodate user input?"
> >
> >
> >
> > Easy.
> >
> >
> >
> > > How to make an empty Entry object that will hold a single
> >
> > > character that the user will enter?
> >
> >
> >
> > Not as easy, but still quite doable. Do you want to filter the input,
> allowing only a single character?
> >
> >
> >
> > > How to A Button object with a text equal to "Count"?
> >
> >
> >
> > Easy-pee-see. Follow this yellow brick road to enlightenment.
> >
> >
> >
> >   http://effbot.org/tkinterbook/tkinter-whats-tkinter.htm
>
> Hello,
>
> Here is my try to answer some of questions:
>
>
> from tkinter import *
>
> class word:
>     def __init__(self,Entry,Character):
>         window = Tk()
>         window.title("Widget")
>
>         top = Tk()
>         L1 = Label(top, text="Enter a string")
>         L1.pack( side = LEFT)
>         E1 = Entry(top, bd =5)
>

This is unlikely to work.  You have overwritten the Entry widget from
tkinter, meaning that E1 will not be an Entry (unless you pass
tkinter.Entry to a word() instance, which seems redundant).

My suggestion is actually to generate classes derived from tkinter widgets
(I often use Frame, since it's quite generic and can act as a container for
any other widget easily).


>         E1.pack(side = RIGHT)
>
>         top.mainloop()
>
>         L2 = Label(bottom, text="Number of single characters")
>         L2.pack( side = LEFT)
>         E2 = Entry(bottom, bd =5)
>
>         button = Tkinter.Button(bottom, text ="Count", command =
>  countCharacter).pack()
>
>         def countChacater(self):
>             count = word.count(character)
>
> I'm just struggling with only how to create an object that will hold a
> single character that the user will enter.
>

This is tricky.  The approach I would take is to generate an entry widget
and then bind all key-press events in that widget to a method that checks
how long the input string is.  If it is longer than a single character,
reject the new letter and optionally raise an alert (using, e.g.,
tkMessageBox.showwarning).

If you want the count on the button to be updated continuously, you'll need
to update that counter every time either the input string or character is
changed.

Good luck,
Jason

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


Thread

Python GUI  questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 12:01 -0700
  Re: Python GUI questions Chris Angelico <rosuav@gmail.com> - 2013-03-20 08:39 +1100
    Re: Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 15:50 -0700
    Re: Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 15:50 -0700
  Re: Python GUI  questions Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-19 17:57 -0700
    Re: Python GUI  questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 18:25 -0700
      Re: Python GUI questions Ranting Rick <rantingrickjohnson@gmail.com> - 2013-03-19 19:16 -0700
        Re: Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 19:36 -0700
          Re: Python GUI questions Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-19 20:06 -0700
        Re: Python GUI questions Terry Reedy <tjreedy@udel.edu> - 2013-03-19 23:21 -0400
          Re: Python GUI questions Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-20 10:37 -0700
      Re: Python GUI questions Jason Swails <jason.swails@gmail.com> - 2013-03-19 22:14 -0400
  Re: Python GUI  questions Jan Riechers <janpeterr@freenet.de> - 2013-03-31 16:33 +0300

csiph-web