I've been searching the archives for a while and the Pmw 'known
bugs' page so I hope this is not an old question.
I am attempting to subclass the Pmw.ScrolledListBox widget as I want
to make a few changes. However, when I create an instance of my
subclass it no longer has its scroll bars. I am using Python 2.2.2
and Pmw 1.1 on Linux. If anyone has any suggestions or information I
would be most greatful. At the bottom is my example which
demonstrates this problem.
Thanks,
Joshua
------------------------------------
#!/usr/bin/env python
from Tkinter import *
import Pmw
class mylistbox(Pmw.ScrolledListBox):
def __init__(self,parent=None,**kw):
self.defineoptions(kw, ())
Pmw.ScrolledListBox.__init__(self,parent)
root = Pmw.initialise()
items = ('dog','cat','pig','horse','cow','donkey','chicken','goat',
'dog','cat','pig','horse','cow','donkey','chicken','goat')
Pmw.ScrolledListBox(root, items=items).pack()
mylistbox(root, items=items).pack()
root.mainloop()
------------------------------------
Joshua Gerth (hrak...@yahoo.com) wrote:
>
> Hello,
>
> I've been searching the archives for a while and the Pmw 'known
> bugs' page so I hope this is not an old question.
>
> I am attempting to subclass the Pmw.ScrolledListBox widget as I want
> to make a few changes. However, when I create an instance of my
> subclass it no longer has its scroll bars. I am using Python 2.2.2
> and Pmw 1.1 on Linux. If anyone has any suggestions or information I
> would be most greatful. At the bottom is my example which
> demonstrates this problem.
>
> Thanks,
> Joshua
>
> ------------------------------------
> #!/usr/bin/env python
>
> from Tkinter import *
> import Pmw
>
> class mylistbox(Pmw.ScrolledListBox):
> def __init__(self,parent=None,**kw):
>
> self.defineoptions(kw, ())
> Pmw.ScrolledListBox.__init__(self,parent)
self.initialiseoptions(mylistbox)
>
> root = Pmw.initialise()
>
> items = ('dog','cat','pig','horse','cow','donkey','chicken','goat',
> 'dog','cat','pig','horse','cow','donkey','chicken','goat')
>
> Pmw.ScrolledListBox(root, items=items).pack()
>
> mylistbox(root, items=items).pack()
>
> root.mainloop()
You left that out. From the docs (emphasis mine):
initialiseoptions(myClass)
Check keyword arguments and call option callback functions. This
must be called at the end of a megawidget constructor with myClass
^^^^
set to the class being defined.