mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
fix scrollist crash for non-class lists
This commit is contained in:
parent
ff208ad0b8
commit
a0c06b4554
@ -1,6 +1,7 @@
|
||||
from DirectFrame import *
|
||||
from DirectButton import *
|
||||
import Task
|
||||
import types
|
||||
|
||||
class DirectScrolledList(DirectFrame):
|
||||
def __init__(self, parent = aspect2d, **kw):
|
||||
@ -104,6 +105,13 @@ class DirectScrolledList(DirectFrame):
|
||||
#for i in range(len(self["items"])):
|
||||
# print "buttontext[",i,"]",self["items"][i]["text"]
|
||||
|
||||
if(len(self["items"])==0):
|
||||
return
|
||||
|
||||
if(type(self["items"][0])!=types.InstanceType):
|
||||
print "warning: getItemIndexForItemID: cant find itemID for non-class list items!"
|
||||
return
|
||||
|
||||
for i in range(len(self["items"])):
|
||||
if(self["items"][i].itemID == itemID):
|
||||
return i
|
||||
@ -218,14 +226,18 @@ class DirectScrolledList(DirectFrame):
|
||||
"""
|
||||
Add this string and extraArg to the list
|
||||
"""
|
||||
item.itemID = self.nextItemID
|
||||
self.nextItemID += 1
|
||||
if(type(item) == types.InstanceType):
|
||||
# cant add attribs to non-classes (like strings & ints)
|
||||
item.itemID = self.nextItemID
|
||||
self.nextItemID += 1
|
||||
self['items'].append(item)
|
||||
if type(item) != type(''):
|
||||
item.reparentTo(self.itemFrame)
|
||||
if refresh:
|
||||
self.refresh()
|
||||
return item.itemID # to pass to scrollToItemID
|
||||
if(type(item) == types.InstanceType):
|
||||
return item.itemID # to pass to scrollToItemID
|
||||
return
|
||||
|
||||
def removeItem(self, item, refresh=1):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user