[Tutor] A little help with TKinter please ....!!

BELSEY, Dylan dylan.belsey@baesystems.com
Wed, 21 Aug 2002 12:22:23 +0930


	Alternatively, you can separate the mainloop call from the object
instantiation.  Tkinter will ultimately require a root window to hold your
frames and it will create this by default if the user does not.
	So....you 'could' do something like this:

from Tkinter import *
root = Tk()

object_name = Install(root,"textfile")	# notice the "root" for parent.
object_name.GetData()	# Like the function suggested by "SA" in previous
posting.
# do other stuff.

root.mainloop() 	# mainloop will operate as "Gregor Lingl" posted.

	This represents one common method of creating/displaying the widgets
(in some textbook examples) and I also see that the method you have posted
is also used in other examples to create the visuals (I assume that
Frame.__init__() will create the root window???). However, if you want to
use that method then you will have to do some sort of callbacks as Gregor
has explained.
	HTH,
		Dylan






-----Original Message-----
From: Graeme Andrew [mailto:glide@slingshot.co.nz]
Sent: Tuesday, 20 August 2002 19:23
To: Tutor@python.org
Subject: [Tutor] A little help with TKinter please ....!!


Hi there ...

I am new to TKinter but have managed to write a  basic user interface, I
however am puzzled as to how to get data out of the class ?   See following
code.  Sorry if this is obvious but I am pretty new to this .....

My interface routine is wrapped up in a class and is started with a main
loop call ...  ie

class Install(Frame):
   def __init__(self,parent,myFileName):
     Frame.__init__(self,parent)
     self.pack()
     self.data = 0
     self.make_widgets(self.filecontents)

    .... more methods and code here

Install(None,"textfile").mainloop()

My question is how do I get self.data out of the class and back to the code
after the 'mainloop' call  ?

Many thanks for any help !!

Cheers
Graeme Andrew
New Zealand




_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor