Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105689
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2016-03-25 06:41 -0700 |
| References | <d1b257d3-6d27-4201-b3db-e363409b2623@googlegroups.com> <OYWdncAt39_MDmnLnZ2dnUU7-I-dnZ2d@giganews.com> |
| Message-ID | <7d191efb-fe80-488f-87db-268b4b893d42@googlegroups.com> (permalink) |
| Subject | Re: Tkinter --> Why multiple windows |
| From | kevind0718@gmail.com |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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