Subclass problem

Russell E. Owen owen at astroNOJNK.washington.edu.invalid
Wed Aug 2 18:35:55 EDT 2000


I'm trying to work with inheritance and getting some odd failures. 
Having minimized my code down to practically nothing and still seeing 
errors, I figure I must be missing some fundamental point about Python 
inheritance, but I have no idea what it might be. Any help would be 
appreciated.

The following minimal code results in a stunning array of error messages 
when run (errors shown below).

----- begin code -----

import Pmw, Tkinter

class MySubclass(Pmw.EntryField):
    def __init__(self, master):
        Pmw.EntryField.__init__(self, master)

if __name__ == "__main__":
    root = Tkinter.Tk()
    anObj = MySubclass(root)
    anObj.pack()
    root.mainloop()

----- end code -----

If I stop trying to subclass and just create a Pmw.EntryField (e.g. with 
anObj = Pmw.EntryField(master)), everything works fine, 

I realize Pmw has its own recommended way to create megawidgets, and I'm 
willing to try it. But meanwhile I cannot figure out how Python can know 
or care that I am doing the simple subclassing shown above. It's as if 
object inheritance doesn't work anything like I'm used to (from 
Smalltalk).

Here are the error messages that result from trying to click in the text 
entry field from the given example. Typing in the text entry field also 
gives errors, though not quite such a lot of them.

Exception in Tkinter callback
Traceback (innermost last):
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:lib-tk:Tkinter.py", line 764, in __call__
    return apply(self.func, args)
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:Pmw:Pmw_0_8_3:lib:PmwEntryField.py", line 447, in 
_postProcess
    _entryCache[event.widget]._postProcess()
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:Pmw:Pmw_0_8_3:lib:PmwEntryField.py", line 204, in 
_postProcess
    return self.valid()
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:Pmw:Pmw_0_8_3:lib:PmwEntryField.py", line 302, in valid
    return self._valid == OK
AttributeError: _valid
Exception in Tkinter callback
Traceback (innermost last):
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:lib-tk:Tkinter.py", line 764, in __call__
    return apply(self.func, args)
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:Pmw:Pmw_0_8_3:lib:PmwEntryField.py", line 447, in 
_postProcess
    _entryCache[event.widget]._postProcess()
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:Pmw:Pmw_0_8_3:lib:PmwEntryField.py", line 204, in 
_postProcess
    return self.valid()
  File "RussMain:Applications:Languages:Python 
1.5.2c1:Lib:Pmw:Pmw_0_8_3:lib:PmwEntryField.py", line 302, in valid
    return self._valid == OK
AttributeError: _valid



More information about the Python-list mailing list