OOP and Tkinter

Ronny Mandal ronnyma at math.uio.no
Mon May 15 20:41:27 CEST 2006


I am stuck; provided is the code and error-msg:

file front_ui.py:

class Front(object):
    _images = [] # Holds image refs to prevent GC
    def __init__(self, root):

        # Widget Initialization
        self._listbox_1 = Tkinter.Listbox(root,
            height = 0,
            width = 0,

other file:

from Front_ui import Front

class CustomFront(Front):

     Front._listbox_1.insert( 0, 'foo' ) 

  File "H:\My Documents\Komodo\Front.py", line 63, in CustomFront
    Front._listbox_1.insert( 0, foo' )
AttributeError: type object 'Front' has no attribute '_listbox_1'

i.e., it cannot find the listbox! Strange, both files is in the same
folder. What is wrong here?


Ronny Mandal

More information about the Python-list mailing list