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


Groups > comp.lang.python > #105689

Re: Tkinter --> Why multiple windows

X-Received by 10.66.246.230 with SMTP id xz6mr8457642pac.29.1458913308810; Fri, 25 Mar 2016 06:41:48 -0700 (PDT)
X-Received by 10.50.43.194 with SMTP id y2mr684892igl.9.1458913308759; Fri, 25 Mar 2016 06:41:48 -0700 (PDT)
Path csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!nt3no4439759igb.0!news-out.google.com!pn7ni16831igb.0!nntp.google.com!nt3no4439754igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Fri, 25 Mar 2016 06:41:48 -0700 (PDT)
In-Reply-To <OYWdncAt39_MDmnLnZ2dnUU7-I-dnZ2d@giganews.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=167.230.96.10; posting-account=CENwKQoAAADcqkiA-afkm1ytLR3rGX_o
NNTP-Posting-Host 167.230.96.10
References <d1b257d3-6d27-4201-b3db-e363409b2623@googlegroups.com> <OYWdncAt39_MDmnLnZ2dnUU7-I-dnZ2d@giganews.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <7d191efb-fe80-488f-87db-268b4b893d42@googlegroups.com> (permalink)
Subject Re: Tkinter --> Why multiple windows
From kevind0718@gmail.com
Injection-Date Fri, 25 Mar 2016 13:41:48 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:105689

Show key headers only | View raw


On Thursday, March 24, 2016 at 9:24:44 PM UTC-4, Wildman wrote:
> On Thu, 24 Mar 2016 13:24:16 -0700, kevind0718 wrote:
> 
> > Hello:
> > 
> > newbie Tkinter question
> > 
> > If I run the code below two windows appear.
> > One empty and one with the text box and button.
> > 
> > Why?  please
> > 
> > KD
> > 
> > 
> > 
> > from Tkinter import *
> > 
> > class MyDialog:
> >     def __init__(self, parent):
> > 
> >         top = self.top = Toplevel(parent)
> > 
> >         Label(top, text="Value").pack()
> > 
> >         self.e = Entry(top)
> >         self.e.pack(padx=5)
> > 
> >         b = Button(top, text="OK", command=self.ok)
> >         b.pack(pady=5)
> > 
> >     def ok(self):
> > 
> >         print "value is", self.e.get()
> > 
> >         self.top.destroy()
> > 
> > 
> > root = Tk()
> > 
> > d = MyDialog(root)
> > 
> > root.wait_window(d.top)
> 
> Try this:
> 
> from Tkinter import *
> 
> class MyDialog(Frame):
> 
>     def __init__(self, parent):
>         Frame.__init__(self, parent)
>         self.parent = parent
>         self.pack(fill=BOTH, expand=1)
>         self.parent.title("MyDialog")
>         Label(self, text="Value").pack()
>         self.e = Entry(self)
>         self.e.pack(padx=5)
>         self.b = Button(self, text="OK", command=self.ok)
>         self.b.pack(pady=5)
> 
>     def ok(self):
>         print "value is", self.e.get()
> 
> root = Tk()
> d = MyDialog(root)
> root.mainloop()
> 
> -- 
> <Wildman> GNU/Linux user #557453
> May the Source be with you.


Looking at the lines below 
As related to the code I posted above.
I believe this code will allow me to instantiate the class
MyDialog, wait until the window is destroyed and then 
continue on my merry way.

root = Tk()
d = MyDialog(root)
root.wait_window(d.top) 


Now if I pass an instance of  Unamepword into the constructor of
MyDialog(unamepword) , I can modify uStr and pWord in MyDialog and 
the local copy will get updated.  
Correct?

class Unamepword:
    ## 
    ## class to hold user name and pWord for Database
    uName = None
    pWord = None
    def __init__(self, uStr, pStr):
        self.uName = uStr
        self.pWord = pStr

Many thanks for your attention to this matter.

KD

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


Thread

Tkinter -->  Why multiple windows kevind0718@gmail.com - 2016-03-24 13:24 -0700
  Re: Tkinter -->  Why multiple windows Random832 <random832@fastmail.com> - 2016-03-24 16:28 -0400
    Re: Tkinter -->  Why multiple windows kevind0718@gmail.com - 2016-03-24 13:43 -0700
      Re: Tkinter --> Why multiple windows Terry Reedy <tjreedy@udel.edu> - 2016-03-24 21:27 -0400
  Re: Tkinter -->  Why multiple windows Wildman <best_lay@yahoo.com> - 2016-03-24 20:24 -0500
    Re: Tkinter -->  Why multiple windows kevind0718@gmail.com - 2016-03-25 06:41 -0700
      Re: Tkinter -->  Why multiple windows Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-25 13:03 -0400

csiph-web