mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
*** empty log message ***
This commit is contained in:
parent
c8264dc33b
commit
a6de4d64f4
@ -9,4 +9,4 @@ guiTop.node().setMouseWatcher(base.mouseWatcher.node())
|
|||||||
from DirectFrame import *
|
from DirectFrame import *
|
||||||
from DirectButton import *
|
from DirectButton import *
|
||||||
from DirectLabel import *
|
from DirectLabel import *
|
||||||
|
from DirectScrolledList import *
|
||||||
|
@ -656,6 +656,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
|
|||||||
('pgFunc', PGItem, None),
|
('pgFunc', PGItem, None),
|
||||||
('numStates', 1, None),
|
('numStates', 1, None),
|
||||||
('invertedFrames', (), None),
|
('invertedFrames', (), None),
|
||||||
|
('sortOrder', 0, None),
|
||||||
# Widget's initial state
|
# Widget's initial state
|
||||||
('state', NORMAL, self.setState),
|
('state', NORMAL, self.setState),
|
||||||
# Widget's frame characteristics
|
# Widget's frame characteristics
|
||||||
@ -684,7 +685,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
|
|||||||
self.guiItem.setId(self['guiId'])
|
self.guiItem.setId(self['guiId'])
|
||||||
self.guiId = self.guiItem.getId()
|
self.guiId = self.guiItem.getId()
|
||||||
# Attach button to parent and make that self
|
# Attach button to parent and make that self
|
||||||
self.assign(parent.attachNewNode( self.guiItem ) )
|
self.assign(parent.attachNewNode( self.guiItem, self['sortOrder'] ) )
|
||||||
# Update pose to initial values
|
# Update pose to initial values
|
||||||
if self['pos']:
|
if self['pos']:
|
||||||
pos = self['pos']
|
pos = self['pos']
|
||||||
|
81
direct/src/gui/DirectScrolledList.py
Normal file
81
direct/src/gui/DirectScrolledList.py
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
from DirectFrame import *
|
||||||
|
from DirectButton import *
|
||||||
|
import GuiGlobals
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
def choseAvatar(name, avId):
|
||||||
|
print name, avId
|
||||||
|
|
||||||
|
model = loader.loadModel("phase_4/models/gui/friendslist_gui")
|
||||||
|
|
||||||
|
s = DirectScrolledList(
|
||||||
|
image = model.find("**/FriendsBox_Open"),
|
||||||
|
relief = None,
|
||||||
|
# inc and dec are DirectButtons
|
||||||
|
incButton_text = "inc",
|
||||||
|
incButton_text_scale = 0.1,
|
||||||
|
incButton_pos = (0,0,0.1),
|
||||||
|
decButton_text = "dec",
|
||||||
|
decButton_text_scale = 0.1,
|
||||||
|
decButton_pos = (0,0,-0.1),
|
||||||
|
# itemFrame is a DirectFrame
|
||||||
|
itemFrame_pos = (0,0,0),
|
||||||
|
itemFrame_relief = FLAT,
|
||||||
|
itemFrame_frameColor = (1,1,1,1),
|
||||||
|
# each item is a button with text on it
|
||||||
|
numItemsVisible = 3,
|
||||||
|
items = ('Top', 'Flippy', 'Joe', 'Flippy', 'Ashy', 'Bottom'),
|
||||||
|
items_text_scale = 0.1,
|
||||||
|
items_relief = FLAT,
|
||||||
|
command = choseAvatar,
|
||||||
|
extraArgs = ([1], [2], [3]),
|
||||||
|
)
|
||||||
|
|
||||||
|
s.addItem(string, extraArg)
|
||||||
|
s.removeItem(index)
|
||||||
|
s.setItems(stringList, extraArgList)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class DirectScrolledList(DirectFrame):
|
||||||
|
def __init__(self, parent = guiTop, **kw):
|
||||||
|
# Inherits from DirectFrame
|
||||||
|
optiondefs = (
|
||||||
|
# Define type of DirectGuiWidget
|
||||||
|
('items', [], None),
|
||||||
|
('command', None, None),
|
||||||
|
('extraArgs', [], None),
|
||||||
|
('numItemsVisible', 1, None),
|
||||||
|
)
|
||||||
|
# Merge keyword options with default options
|
||||||
|
self.defineoptions(kw, optiondefs, dynamicGroups = ("items",))
|
||||||
|
|
||||||
|
# Initialize superclasses
|
||||||
|
DirectFrame.__init__(self, parent)
|
||||||
|
|
||||||
|
self.createcomponent("incButton", (), "incButton",
|
||||||
|
DirectButton, (),
|
||||||
|
parent = self,
|
||||||
|
)
|
||||||
|
self.createcomponent("decButton", (), "decButton",
|
||||||
|
DirectButton, (),
|
||||||
|
parent = self,
|
||||||
|
)
|
||||||
|
self.createcomponent("itemFrame", (), "itemFrame",
|
||||||
|
DirectFrame, (),
|
||||||
|
parent = self,
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(len(self["items"])):
|
||||||
|
item = self["items"][i]
|
||||||
|
self.createcomponent("item"+str(i), (), "items",
|
||||||
|
DirectButton, (),
|
||||||
|
parent = self.component("itemFrame"),
|
||||||
|
text = item,
|
||||||
|
command = self["command"],
|
||||||
|
extraArgs = [item] + self["extraArgs"][i],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.initialiseoptions(DirectScrolledList)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user