[Tutor] Python question
vicki@stanfield.net
vicki@stanfield.net
Thu Mar 27 15:28:02 2003
I'm getting better at this Python stuff, but I still
have a question. If creating a class with several
methods in it, is it typical to create the widgets
themselves in that same class? For example, I am
creating an entry box like this:
--------------------Class itself-----------------
class EntryClass:
import Pmw
EntryWidget = Pmw.EntryField(Frame2,
label_text='Enter command:',
labelpos='w')
def Callback(self):
value=self.getvalue()
print value
if value:
SendCommand(value)
------------------main code----------------------
entry=EntryClass()
callback=SimpleCallback(entry.Callback)
entry.EntryWidget.configure(command=callback)
entry.EntryWidget.pack(pady=25)
-------------------
This all looks okay to me, but how is the Frame2 which
I want to be the parent of the EntryWidget accessed
from outside the function? Do I have to create a class
for it too?