Bug in DirectScrolledList?

Hi there,
today i hit another problem while using the DirectScrolledList for a chat-system.
what i want to do: scrolling to the latest chat-message when it arrives.
the manual says that: addItem() returns the ItemID of the added item which can then be used to scroll there.
so i create a directscrolledlist with:

self.chatList = DirectScrolledList(
    incButton_pos= (-2,1,0),
    #incButton_scale= (0.1,0.1,0.1),
    incButton_text = "down",
    decButton_pos= (-2,0,1),
    #decButton_scale= (0.1,0.1,0.1),
    decButton_text = "up",
    frameColor= (0,1,1,0.5),
    numItemsVisible = 4

the problem:

itemID = self.chatList.addItem(newText, True)

doesnt return any value other than “None”
the newText is a directLable in my case(cause i want unicodes which are working fine)… but a plain string didnt work either.
the text is added and displayed correctly but i cant get the itemID.
it this a bug or did i simply miss something?

It seems that addItem doesn’t actually respect string type.
This is my own revision of addItem :

    def addItem(self, item, refresh=1):
        Add this string and extraArg to the list
        assert self.notify.debugStateCall(self)
        if(type(item) == types.InstanceType):
            # cant add attribs to non-classes (like strings & ints)
            item.itemID = self.nextItemID
        if type(item) != type(''):
        if refresh:
            # update the list index
            # not refreshed, so enable the forward button
            self.incButton['state'] = DGG.NORMAL
        self.nextItemID += 1
        if(type(item) == types.InstanceType):
            return item.itemID  # to pass to scrollToItemID
           return self.nextItemID-1

It updates the list index before refresh, so you’ll get an automatic scroll to the latest item upon calling addItem.

well but then a directLabel should work, shoudln’t it?
ahm… aside from that… where would i have to apply your code… i sortof cant think of the right place it belongs to.

dunno, I didn’t try it with label.
addItem belongs to DirectScrolledList.py. Perhaps you’d like to look at the CVS version, it’s updated 2 weeks ago, quite much changes there, but addItem is still the same. heh… :stuck_out_tongue:
panda3d.cvs.sourceforge.net/pand … t/src/gui/

Any good news ?
The revised one works for labels too.

still returns None
i added a few print arguments in the directscrolledlist.py … well i noticed that the two

if(type(item) == types.InstanceType):

statements seems to block the code which counts up the itemID’s and the code which returns the ID’s.
putting the counting and returning outside these if statements returns correct values.
when i add print type(item) i’ll get:
<class ‘direct.gui.DirectLabel.DirectLabel’> (since i created a label with my text thats correct)
so why is the code testing for an instance-type for counting and returning the item id :question:

In Panda 1.5.3 I have noticed that addItem is returning None rather than the item id. Is this the correct behavior? Has this changed in 1.5.4?