Tkinter question

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Mon Oct 21 03:40:22 EDT 2002


On Monday 21 Oct 2002 5:42 am, dsavitsk wrote:
> Every now and again I get it in my head that some new project would be best
> done in Tkinter.  Every time I find myself struggling horribly.  I have the
> Grayson book, I have a Fredrik Lundh pdf book from '99.  Somewhere,
>
> Thanks for any enlightenment.
>
> -doug

Doug,

this is my implementation of the Dialog.....
I have subclassed Toplevel but you don't need to

class DialogInterface(Toplevel):
    def __init__(self, parent):
        Toplevel.__init__(self, parent)
        l = Label(self, text="Value")
        l.pack()
        
        self.value = StringVar()
        
        e = Entry(self, textvariable=self.value)
        e.pack(padx=5)
        b = Button(self, text="OK", command=self.ok)
        b.pack(pady=5)
        
        
        ## now make a grab so the 'main' window can't be touched
        ## could also call focus_set() on the entry.....
        self.grab_set()
        
        ## kick up the mainloop for this dialog so we wait for 
        ## it to be closed...
        self.mainloop()
        
        ## this stuff is reached after self.quit() is called
        
        ## first release the grab!
        self.grab_release()
        
        ## now un-draw the window
        self.withdraw()
        
    def getValue(self):
        """return the value!!!"""
        return self.value.get()
        
    def ok(self):
        ## self.quit will release the mainloop()
        self.quit()
        


HTH
Martin
-- 
### Python Powered Signature
I started writting this email on 
Mon Oct 21 07:37:47 2002





More information about the Python-list mailing list