Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.straub-nv.de!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.05; 'method.': 0.05; 'that?': 0.05; 'class,': 0.07; 'classes.': 0.07; 'tkinter': 0.07; 'script,': 0.09; 'def': 0.10; 'gui': 0.11; 'listbox': 0.16; 'received:66.96.186': 0.16; 'received:66.96.186.5': 0.16; 'received:bosmailout05.eigbox.net': 0.16; 'stuff,': 0.16; 'subject:gui': 0.16; 'wrote:': 0.17; 'config': 0.17; 'why.': 0.17; 'examples': 0.18; 'module': 0.19; 'import': 0.21; 'thanks.': 0.21; 'object.': 0.22; 'defined': 0.22; 'cc:2**0': 0.23; '>': 0.23; 'class.': 0.23; "i've": 0.23; 'somewhere': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'creating': 0.26; 'cc:addr:gmail.com': 0.27; 'question': 0.27; 'correct': 0.28; 'depth': 0.29; 'second,': 0.29; 'manual': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'this.': 0.29; "i'm": 0.29; 'button': 0.30; 'print': 0.32; 'getting': 0.33; 'event.': 0.33; 'to:addr:python-list': 0.33; 'form.': 0.33; 'another': 0.33; 'or,': 0.34; 'done': 0.34; 'clear': 0.35; 'described': 0.35; 'something': 0.35; 'there': 0.35; 'created': 0.36; 'but': 0.36; 'url:org': 0.36; 'data.': 0.36; 'received:71': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'url:rec-html40': 0.37; 'why': 0.37; 'far': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'some': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'release': 0.39; 'where': 0.40; 'your': 0.60; 'within': 0.64; 'here': 0.65; 'url:dtd': 0.81; '2013': 0.84; 'rex': 0.84; 'relate': 0.91; 'technically': 0.91; 'url:strict': 0.91; 'browsing': 0.93 X-Authority-Analysis: v=2.0 cv=FqCHDhXq c=1 sm=1 a=W1gMpi6WenUqNE29FwEQzw==:17 a=spKFjZujUncA:10 a=2Cs5qbXtQ68A:10 a=OmMKortqy18A:10 a=tTExfe6FAAAA:8 a=joyhpO1Jcc0A:10 a=8ONGxiEqAAAA:8 a=lJt14sT-d66tVnnn7QQA:9 a=CjuIK1q_8ugA:10 a=P3uMDV8RXKwA:10 a=SSmOFEACAAAA:8 a=AmSbatVQUPwvxV4cnNMA:9 a=_W_S_7VecoQA:10 a=frz4AuCg-hUA:10 a=qMDZ_Ezp4_0A:10 a=e4zGuOhZi9LT0v2R:21 a=FLmnjis/JmE4jomwi6pJ+A==:117 X-EN-OrigOutIP: 10.20.18.1 X-EN-IMPSID: 4H2R1l00701P9Sa01H2RjT From: inq1ltd To: python-list@python.org Subject: Re: tkinter / gui Date: Sun, 24 Feb 2013 12:00:09 -0500 User-Agent: KMail/4.7.2 (Linux/2.6.37.6-24-desktop; KDE/4.7.2; i686; ; ) In-Reply-To: <724fdb01-d042-4e2f-b19e-18df25507abb@googlegroups.com> References: <724fdb01-d042-4e2f-b19e-18df25507abb@googlegroups.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="nextPart3571081.HFj5nu583Z" Content-Transfer-Encoding: 7Bit X-EN-UserInfo: ea107384e720a598200e9790e8ca8002:9d89a6cbd5a73a41b134431a25286195 X-EN-AuthUser: inq1ltd@inqvista.com Sender: inq1ltd X-EN-OrigIP: 71.127.134.214 X-EN-OrigHost: pool-71-127-134-214.rcmdva.east.verizon.net Cc: Rex Macey X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 153 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361727157 news.xs4all.nl 6915 [2001:888:2000:d::a6]:42968 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39759 --nextPart3571081.HFj5nu583Z Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Saturday, February 23, 2013 02:50:43 PM Rex Macey wrote: > Here is one general and one specific question about creating GUIs using > tkinter from a newbie. I have created a class in which to hold some data. > I want to create a GUI to get the data from the user and store it in the > object. Browsing the web I see that a lot of examples on GUIs have the > forms put into classes. I'm not clear why. Why is that? Second, I've > created a form with a bunch of widgets on it, one of which is a listbox. > This is done with a script, not a class. I've defined a method that > responds to a Button Release event. I know this works because I can print > the value selected in the listbox while within the method. However, I want > the value of the listbox after I've closed the form. How do I get that? > Thanks. There are a few ways to approach this. without getting to far in depth here, you can do something like this. This is not technically correct but a simple concept of how to. make a class class Klbox lbox = '' def __init__(self): self.FmkLbox() def FmkLbox(self): mkLbox = Listbox(masterTK) ## create the listbox in TK config.mkLbox( stuff, morestuff, ## config it however you want selectmode = ???) ## you may have to import your class Klbox, here #depending where you are in your program then relate Klbox.lbox = (?? something selected from listbox) # from somewhere else in your program you can import Klbox x = Klbox.lbox print x, Or, you can also learn how to use the Tkinter StringVar Class, available in Tkinter manual but you will need to relate the StringVar to an attribute as I described above so you can get it from another module or class in your program. jd inqvista.com --nextPart3571081.HFj5nu583Z Content-Transfer-Encoding: 7Bit Content-Type: text/html; charset="us-ascii"

On Saturday, February 23, 2013 02:50:43 PM Rex Macey wrote:

> Here is one general and one specific question about creating GUIs using

> tkinter from a newbie. I have created a class in which to hold some data.

> I want to create a GUI to get the data from the user and store it in the

> object. Browsing the web I see that a lot of examples on GUIs have the

> forms put into classes. I'm not clear why. Why is that? Second, I've

> created a form with a bunch of widgets on it, one of which is a listbox.

> This is done with a script, not a class. I've defined a method that

> responds to a Button Release event. I know this works because I can print

> the value selected in the listbox while within the method. However, I want

> the value of the listbox after I've closed the form. How do I get that?

> Thanks.

 

There are a few ways to approach this.

without getting to far in depth here,

you can do something like this.

 

This is not technically correct but a

simple concept of how to.

 

make a class

class Klbox

lbox = ''

 

def __init__(self):

self.FmkLbox()

 

def FmkLbox(self):

mkLbox = Listbox(masterTK) ## create the listbox in TK

config.mkLbox( stuff, morestuff, ## config it however you want

selectmode = ???)

 

 

## you may have to import your class Klbox, here

#depending where you are in your program

then relate Klbox.lbox = (?? something selected from listbox)

 

# from somewhere else in your program you can

import Klbox

x = Klbox.lbox

print x,

 

Or, you can also learn how to use the

Tkinter StringVar Class, available in Tkinter manual

but you will need to relate the StringVar to an attribute

as I described above so you can get it from another

module or class in your program.

 

jd

inqvista.com

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

--nextPart3571081.HFj5nu583Z--