Panda3D Manual: DirectScrolledList
<<prev | top | next>> |
DirectScrolledLists create a list of DirectGuiWidgets. Each object is created individually and can then be added to the list. Some useful methods are:
addItem(item, refresh) getItemIndexForItemID(self, itemID) getSelectedIndex(self) getSelectedText(self) removeItem(self, item, refresh) scrollBy(self, delta) scrollTo(self, index, centered) scrollToItemID(self, itemID, centered) selectListItem(self, item)
In the above methods, item is a new item, either a string or a DirectGUI element, and itemID is an arbitrary identification number for each item (but not necessarily a zero-based index number). The itemID for a new item is the return value of addItem(). The centered parameter is a boolean; if true, the list scrolls so that the given index is centered, otherwise it scrolls so that the index is on top of the list. The items option should either be a list of DirectGUI items or of strings. If strings are used, the itemMakeFunction (and possibly itemMakeExtraArgs) option should be defined to point to a function that will take the supplied string, the index, and the extra args as parameters and return a DirectGUI object to insert into the list. If items is a list of strings and itemMakeFunction is not specified, it will create a list of DirectLabels. itemMakeFunction is redundant if a list of DirectGUI objects is passed into items to begin with. DirectScrolledLists come with two scroll buttons for navigating through the list. By default, they both start at (0,0,0) relative to the list with size 0, and their positions and size need to be set explicitly. You can set any of the values except relief appearance as you initialize the list:
myScrolledList = DirectScrolledList(incButton_propertyName = value, decButton_propertyName = value)
incButton scrolls forward through the list; decButton backward. Note that this only works for initialization. To change a property of the scroll buttons later in the program, you must use:
myScrolledList.incButton['propertyName'] = value myScrolledList.decButton['propertyName'] = value
Unlike the first method, this does not work with NodePath options like position; use setPos(...) for that. For example, the following creates a scrolled list and resizes and moves the buttons appropriately.
myScrolledList = DirectScrolledList(incButton_pos= (.5,0,0), incButton_text = "Inc", decButton_pos= (-.5,0,0), decButton_test = "Dec") myScrolledList.incButton['frameSize'] = (0, 0.2, 0, 0.2) myScrolledList.decButton['framesize'] = (0, 0.2, 0, 0.2) myScrolledList.incButton['text_scale'] = .2 myScrolledList.decButton['text_scale'] = .2
Keyword | Definition | Value
command | Function called when the list is scrolled | Function
extraArgs | Extra arguments to the function specified in command | [Extra Arguments]
text_scale | Scale of the displayed text | (sx,sz)
items | List of the objects to appear in the ScrolledList | [DirectGUI items] or [Strings]
numItemsVisible | Number of items visible at a time | Number
forceHeight | Forces the height of the list to be a given number | Number
itemMakeFunction | Function that makes DirectGUI items out of strings | Function
itemMakeExtraArgs | Extra arguments to the function in itemMakeFunction | [Extra Arguments]

<<prev | top | next>> |